使用wordnet通过JWNL运行时出错,在props文件中出错

时间:2013-12-30 12:09:11

标签: java wordnet

嘿,我已经在netbeans中尝试了这个但它不会起作用,无论我做什么,它都会给我同样的错误!有人可以帮忙吗?


JWNL.initialize(new FileInputStream("C:\\Users\\Desktop\\file_properties.xml"));

wordnet = Dictionary.getInstance();
IndexWord word = wordnet.getIndexWord(POS.VERB,"run");
Synset[] senses = word.getSenses();
for (int i = 0; i < senses.length; i++) 
{
   System.out.println(word + ": " + senses[i].getGloss());
}

并且丢失了文件异常:

Exception in thread "main" 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 testss.Testss.main(Testss.java:43)
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)
    ... 2 more
Caused by: net.didion.jwnl.JWNLException: Could not create a file manager of type class net.didion.jwnl.princeton.file.PrincetonRandomAccessDictionaryFile
    at net.didion.jwnl.dictionary.file_manager.FileManagerImpl.create(FileManagerImpl.java:98)
    at net.didion.jwnl.util.factory.AbstractValueParam.create(AbstractValueParam.java:32)
    ... 4 more
Caused by: java.io.FileNotFoundException: C:\Program Files\WordNet\2.1\dict\index.adv (The system cannot find the file specified)
    at java.io.RandomAccessFile.open(Native Method)
    at java.io.RandomAccessFile.<init>(RandomAccessFile.java:241)
    at net.didion.jwnl.princeton.file.PrincetonRandomAccessDictionaryFile.openFile(PrincetonRandomAccessDictionaryFile.java:76)
    at net.didion.jwnl.dictionary.file.AbstractDictionaryFile.open(AbstractDictionaryFile.java:58)
    at net.didion.jwnl.dictionary.file.DictionaryCatalog.open(DictionaryCatalog.java:45)
    at net.didion.jwnl.dictionary.file.DictionaryCatalogSet.open(DictionaryCatalogSet.java:34)
    at net.didion.jwnl.dictionary.file_manager.FileManagerImpl.<init>(FileManagerImpl.java:71)
    at net.didion.jwnl.dictionary.file_manager.FileManagerImpl.create(FileManagerImpl.java:96)
    ... 5 more

2 个答案:

答案 0 :(得分:0)

更新jwnlProperties.xml中使用的Wordnet数据库版本

<version publisher="Princeton" number="3" language="en"/>

db中的文件名已经更改了版本,JWNL支持它们。

这应该可以解决您的问题,也可以在其他地方讨论。 http://sourceforge.net/p/jwordnet/discussion/106153/thread/5ccfc039/

答案 1 :(得分:0)

我遇到了同样的问题。我解决了这个问题,在 dict 文件夹中添加了一些丢失的文件。

     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:157)   at getHypernyms.main(getHypernyms.java:27) 
        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:100)   at net.didion.jwnl.util.factory.Element.install(Element.java:32)    ... 2 more Caused by: net.didion.jwnl.JWNLException: Could not create a file manager of type class 

net.didion.jwnl.princeton.file.PrincetonRandomAccessDictionaryFile  at net.didion.jwnl.dictionary.file_manager.FileManagerImpl.create(FileManagerImpl.java:71)  at net.didion.jwnl.util.factory.AbstractValueParam.create(AbstractValueParam.java:32)   ... 4 more Caused by: java.io.FileNotFoundException: E:\WordNet\WordNet-2.0\dict\adj.dat 

(The system cannot find the file specified)     at java.io.RandomAccessFile.open0(Native Method)    at java.io.RandomAccessFile.open(RandomAccessFile.java:316)     at java.io.RandomAccessFile.<init>(RandomAccessFile.java:243)   at net.didion.jwnl.princeton.file.PrincetonRandomAccessDictionaryFile.openFile(PrincetonRandomAccessDictionaryFile.java:76)     at net.didion.jwnl.dictionary.file.AbstractDictionaryFile.open(AbstractDictionaryFile.java:58)  at net.didion.jwnl.dictionary.file.DictionaryCatalog.open(DictionaryCatalog.java:46)    at net.didion.jwnl.dictionary.file.DictionaryCatalogSet.open(DictionaryCatalogSet.java:34)  at net.didion.jwnl.dictionary.file_manager.FileManagerImpl.<init>(FileManagerImpl.java:54)  at net.didion.jwnl.dictionary.file_manager.FileManagerImpl.create(FileManagerImpl.java:69)  ... 5 more

我只是复制了现有文件,并将其重命名为所需的名称。并重新运行该程序,它可以完美运行。丢失的文件是 adj.dat noun.dat adj.dat .idx 等。 示例:现有文件名为 data.verb ==>复制并粘贴并重命名为 verb.dat ,与其他文件相同。并将 index.adj 重命名为 adj.idx 。 对于任何查询,您都可以ping我。 anysocialmedia / nabilraza456

这是输出 enter image description here