Error using Arabic Wordnet in nltk
<p>I am using NLTK Wordnet for Arabic language. When I run the following code :</p>

<pre><code># -*- coding: UTF-8 -*-
from nltk.corpus import wordnet as wn
print wn.synsets('bank')[0].lemma_names('arb') 
print wn.synsets('Ø¶ÙÙÙÙØ©', lang='arb')0].hypernyms()0].lemma_names(lang='arb') #PROBLEM HERE
</code></pre>

<p>I get this error:</p>

<pre><code>Traceback (most recent call last):
  File "nltk_wordnet.py", line 7, in &lt;module&gt;
    print wn.synsets('Ø¶ÙÙÙÙØ©', lang='arb')[0].hypernyms()    [0].lemma_names(lang='arb')
IndexError: list index out of range
</code></pre>

<p>Your code assumes that word <code>'Ø¶ÙÙÙÙØ©'</code> will find a conceptual relationship using <code>synsets</code> and that the first item in the set will have hypernym(s). That may not be true. You can instead check if the results returned are non-empty before <em>indexing</em>:</p>

<pre><code>word_synsets = wn.synsets('Ø¶ÙÙÙÙØ©', lang='arb')
if word_synsets: # False if word_synsets is an empty list
    word_hyp = word_synsets[0].hypernyms()
    if word_hyp: # False if word_hyp is an empty list
        print(word_hyp[0].lemma_names(lang='arb'))
    else:
        print('first item in Ø¶ÙÙÙÙØ© synset has no hypernym(s)')
else:
    print('synset for Ø¶ÙÙÙÙØ© returned no result')
</code></pre>

python nltk wordnet