Using Wordnet syntaxes from Python for Italian

I am starting to program with NLTK in Python for natural Italian language processing. I've seen some simple examples of the WordNet library that has a nice SynSet that allows you to navigate from a word (eg: "dog") to its synonyms and its antonyms, its hyonyms and hyperimages, etc.

My question is: If I start with an Italian word (ex: "cane" means "dog"), is there a way to navigate between synonyms, antonyms, hyponyms ... for an Italian word the same as for English? Or ... Is there a WordNet equivalent for Italian?

Thank you in advance

+3


source to share


1 answer


You're lucky. nltk

provides an interface to Open Multilingual Wordnet , which does include Italian among the languages ​​it describes. Just add an argument specifying the language you want to the regular wordnet functions like:

>>> cane_lemmas = wn.lemmas("cane", lang="ita")
>>> print(cane_lemmas)
[Lemma('dog.n.01.cane'), Lemma('cramp.n.02.cane'), Lemma('hammer.n.01.cane'),
 Lemma('bad_person.n.01.cane'), Lemma('incompetent.n.01.cane')]

      

Synthes have English names because they are combined with the English wordnet. But you can navigate the network of values ​​and extract the Italian lemmas for whatever synchronization you want:

>>> hypernyms = cane_lemmas[0].synset().hypernyms()
>>> print(hypernyms)
[Synset('canine.n.02'), Synset('domestic_animal.n.01')]
>>> print(hypernyms[1].lemmas(lang="ita"))
[Lemma('domestic_animal.n.01.animale_addomesticato'), 
 Lemma('domestic_animal.n.01.animale_domestico')]

      



Or, since you mentioned "cattiva_persona" in the comments:

>>> wn.lemmas("bad_person")[0].synset().lemmas(lang="ita")
[Lemma('bad_person.n.01.cane'), Lemma('bad_person.n.01.cattivo')]

      

I went from English lemma to independent synth to Italian lemmas.

+5


source







All Articles