Based on this answer, I made few edits in AWNDatabaseManagement.py:第 320 行是 opts['i']='upc_db.xml' 而不是 opts['i']='E:/usuaris/horacio/arabicWN/AWNdatabase/upc_db.xml'opts['i']='E:/usuaris/horacio/arabicWN/AWNdatabase/upc_db.xml'我在最后添加了wn.get_synsets_from_word(u"جَمِيل")我在第 2 行添加了:# -*- coding: utf-8 -*-I added that at line 2: # -*- coding: utf-8 -*-然后我使用:$ python AWNDatabaseManagement.py -i upc_db.xml 运行它并且没有发现错误:<open file 'upc_db.xml', mode 'r' at0x10156c270> Then I ran it using: $ python AWNDatabaseManagement.py -i upc_db.xml and no errors were found: <open file 'upc_db.xml', mode 'r' at 0x10156c270> 然而,当我运行我的原始 py 文件时:Yet when I run my original py file:from nltk.corpus import wordnet as wnjan = wn.synsets('wait')[0]print(jan) #this works fineprint(jan.lemma_names(lang='arb')) #this works finewn.get_synsets_from_word(u"جَمِيل")我明白了:`Synset('delay.n.01') [u'\u0627\u0650\u0646\u0652\u062a\u0650\u0638\u0627\u0631', u'\u062a\u0623\u062c\u0650\u064a\u0644', u'\u062a\u0623\u062e\u0650\u064a\u0631', u'\u062a\u0648\u0642\u0651\u064f\u0641'] Traceback (most recent call last): File "C:/Users/PycharmProjects20Dec.py" line 492, in <module> wn.get_synsets_from_word("جَمِيل") AttributeError: 'WordNetCorpusReader' object has no attribute 'get_synsets_from_word`我真的不知道这是什么问题.I really don't know what is the problem.推荐答案阿拉伯语 Wordnet 独立于 nltk 工作.在您拥有 AWNDatabaseManagement.py 和 upc_db.xml 的文件夹中,放入您的脚本并将其更改为:Arabic Wordnet works independent of nltk. In the folder where you have AWNDatabaseManagement.py and upc_db.xml, put your script and change it to:from AWNDatabaseManagement import wnsynsets = wn.get_synsetids_from_word(u"جَمِيل")for s in synsets: wn._items[s].describe()输出将是:itemid jamiyl_a1ARoffset 300218842name جَمِيلtype synsetpos ainput links [[u'be_in_state', u'jamaAl_n1AR'], [u'near_antonym', u'qabiyH_a1AR']]output links [[u'near_antonym', u'qabiyH_a1AR']] 这篇关于Python中的阿拉伯语Word Net同义词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 11-01 22:03