I am using python 2.7, I am trying to get synonyms of Arabic words using Arabic WordNet
I downloaded both needed files:
Based on this answer, I made few edits in AWNDatabaseManagement.py:
line 320 is
opts['i']='upc_db.xml'
instead ofopts['i']='E:/usuaris/horacio/arabicWN/AWNdatabase/upc_db.xml'
I added that at the end
wn.get_synsets_from_word(u"جَمِيل")
I added that at line 2:
# -*- coding: utf-8 -*-
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>
Yet when I run my original py file:
from nltk.corpus import wordnet as wn
jan = wn.synsets('wait')[0]
print(jan) #this works fine
print(jan.lemma_names(lang='arb')) #this works fine
wn.get_synsets_from_word(u"جَمِيل")
I get :
`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.
Arabic Wordnet works independent of nltk. In the folder where you have
AWNDatabaseManagement.py
andupc_db.xml
, put your script and change it to:Output will be: