我正在尝试使用带有 JWNL API 的 WordNet 来阻止字符串。当我尝试加载字典时,它给了我一个 FileNotFoundException。
这是初始化字典的代码:
public static void Initializer(){
try {
JWNL.initialize(new FileInputStream("file_properties.xml"));
dictionary = Dictionary.getInstance();
morphPro = dictionary.getMorphologicalProcessor();
}
catch(FileNotFoundException e){
e.printStackTrace();
} catch (JWNLException e) {
e.printStackTrace();
}
}
这就是我得到的:
net.didion.jwnl.JWNLException: Unable to install net.didion.jwnl.dictionary.FileBackedDictionary
at net.didion.jwnl.util.factory.Element.install(Element.java:34)
at net.didion.jwnl.JWNL.initialize(JWNL.java:169)
at Algorithms.Stemmer.Initializer(Stemmer.java:54)
at Algorithms.Stemmer.WordStemmer(Stemmer.java:33)
at Algorithms.Stemmer.StringStemmer(Stemmer.java:26)
at GUI.ButtonListener.actionPerformed(ButtonListener.java:167)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: net.didion.jwnl.JWNLException: The properties file must specify a dictionary path
at net.didion.jwnl.util.factory.AbstractValueParam.create(AbstractValueParam.java:34)
at net.didion.jwnl.dictionary.FileBackedDictionary.install(FileBackedDictionary.java:111)
at net.didion.jwnl.util.factory.Element.install(Element.java:32)
我很确定它与路径有关,但我无法确切找出问题所在,因为我更改了properties.xml
要使用的文件C:\WordNet\2.1\dict\
- 所以应该没问题吗?