我正在尝试建立一个定制的字典。我正在用 jwnl 进行测试。我收到以下错误:
net.didion.jwnl.JWNLException: Unable to install
net.didion.jwnl.dictionary.FileBackedDictionary
我的 xml 文件 -
<?xml version="1.0" encoding="UTF-8"?>
<jwnl_properties language="en">
<version publisher="Princeton" number="2.0" language="en"/>
<dictionary class="net.didion.jwnl.dictionary.FileBackedDictionary">
<param name="morphological_processor" value="net.didion.jwnl.dictionary.morph.DefaultMorphologicalProcessor">
<param name="operations">
<param value="net.didion.jwnl.dictionary.morph.LookupExceptionsOperation"/>
<param value="net.didion.jwnl.dictionary.morph.DetachSuffixesOperation">
<param name="noun" value="|s=|ses=s|xes=x|zes=z|ches=ch|shes=sh|men=man|ies=y|"/>
<param name="verb" value="|s=|ies=y|es=e|es=|ed=e|ed=|ing=e|ing=|"/>
<param name="adjective" value="|er=|est=|er=e|est=e|"/>
<param name="operations">
<param value="net.didion.jwnl.dictionary.morph.LookupIndexWordOperation"/>
<param value="net.didion.jwnl.dictionary.morph.LookupExceptionsOperation"/>
</param>
</param>
<param value="net.didion.jwnl.dictionary.morph.TokenizerOperation">
<param name="delimiters">
<param value=" "/>
<param value="-"/>
</param>
<param name="token_operations">
<param value="net.didion.jwnl.dictionary.morph.LookupIndexWordOperation"/>
<param value="net.didion.jwnl.dictionary.morph.LookupExceptionsOperation"/>
<param value="net.didion.jwnl.dictionary.morph.DetachSuffixesOperation">
<param name="noun" value="|s=|ses=s|xes=x|zes=z|ches=ch|shes=sh|men=man|ies=y|"/>
<param name="verb" value="|s=|ies=y|es=e|es=|ed=e|ed=|ing=e|ing=|"/>
<param name="adjective" value="|er=|est=|er=e|est=e|"/>
<param name="operations">
<param value="net.didion.jwnl.dictionary.morph.LookupIndexWordOperation"/>
<param value="net.didion.jwnl.dictionary.morph.LookupExceptionsOperation"/>
</param>
</param>
</param>
</param>
</param>
</param>
<param name="dictionary_element_factory" value="net.didion.jwnl.princeton.data.PrincetonWN17FileDictionaryElementFactory"/>
<param name="file_manager" value="net.didion.jwnl.dictionary.file_manager.FileManagerImpl">
<param name="file_type" value="net.didion.jwnl.princeton.file.PrincetonRandomAccessDictionaryFile"/>
<param name="dictionary_path" value="/"/>
</param>
</dictionary>
<resource class="PrincetonResource"/>
我有以下Java代码 -
Document doc = Jsoup.parse(page);
try {
JWNL.initialize(new FileInputStream("file_properties.xml"));
String s = doc.text();
String[] words = s.split(" ");
for (String word: words) {
// check is word is in dictionary
IndexWord aWordIndexNoun = Dictionary.getInstance().getIndexWord(POS.NOUN, word);
IndexWord aWordIndexAdj = Dictionary.getInstance().getIndexWord(POS.ADJECTIVE, word);
}
} catch (Exception e) {
System.out.println("system found an error - " + e);
}
我在 Ubuntu 下使用 Java 1.7 并使用 Eclipse 进行测试。我假设错误在 dictionary_path 但我找不到任何有效的东西。我没有手动下载 wordnet 数据库——我不确定它在哪里。有没有人有任何想法来解决这个问题?