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 of
opts['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
and upc_db.xml
, put your script and change it to:
from AWNDatabaseManagement import wn
synsets = wn.get_synsetids_from_word(u"جَمِيل")
for s in synsets:
wn._items[s].describe()
Output will be:
itemid jamiyl_a1AR
offset 300218842
name جَمِيل
type synset
pos a
input links [[u'be_in_state', u'jamaAl_n1AR'], [u'near_antonym', u'qabiyH_a1AR']]
output links [[u'near_antonym', u'qabiyH_a1AR']]