我最近决定为 WordNet 的 Java 接口下载 JWNL。按照各种教程(如http://jwordnet.sourceforge.net/handbook.html),我下载了 WordNet(2.1),然后下载了 JWNL,将 file_properties.xml 中的 dictionary_path 行设置为 WordNet 的路径。
<param name="dictionary_path" value="c:/res/wordnet/2.1/dict"/>
我将所有 jars 添加到我的类路径中,并且在 Eclipse 中,我创建了以下简单的测试类:
public static void main(String[] args) throws FileNotFoundException,
JWNLException {
JWNL.initialize(new FileInputStream("C:\\path\\file_properties.xml"));
Dictionary wordnet = Dictionary.getInstance();
IndexWord word = wordnet.getIndexWord(POS.NOUN, "monarch");
for(Synset syn : word.getSenses()) {
System.out.println(syn.getGloss());
}
}
在 Eclipse 中运行会产生以下错误:
Exception in thread "main" java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at net.didion.jwnl.util.factory.Element.install(Element.java:31)
at net.didion.jwnl.JWNL.initialize(JWNL.java:169)
at TestingOnWordNet.main(TestingOnWordNet.java:28)
Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException) (Caused by org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException))
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
at net.didion.jwnl.util.MessageLog.<init>(MessageLog.java:11)
at net.didion.jwnl.dictionary.Dictionary.<clinit>(Dictionary.java:24)
... 5 more
Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException)
at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:397)
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
... 10 more
Caused by: java.lang.NullPointerException
at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:374)
... 11 more
有什么我想念的吗?我正准备寻找像 JAWS 这样的替代方案,但我希望有办法解决这个问题。
谢谢!