Suppose for any word I want to access its IS-A parent value and HAS-A value then is it possible using any api?
Asked
Active
Viewed 5,154 times
3 Answers
11
You can use the python API of the Natural Language Toolkit. In Wordnet, the IS-A-relation is called hypernym (opposite: hyponym) and the HAS-A relation is called meronym (opposite: holonym).
from nltk.corpus import wordnet
book = wordnet.synsets('book')[0]
book.hypernyms()
>>> [Synset('publication.n.01')]
book.part_meronyms()
>>> [Synset('running_head.n.01'), Synset('signature.n.05')]
I also found the NodeBox Linguistics API easier to use:
import en
en.noun.hypernym('book')
>>> [['publication']]

Jack Valmadre
- 888
- 7
- 23

Suzana
- 4,251
- 2
- 28
- 52
1
Shameless plug:
I'm writing a Scala library to access WordNet. While not all the similarity measures have been implemented, all the word senses and relations are available. I use it for my research so its in active development.
import com.github.mrmechko.swordnet._
SKey("book",SPos.Noun)
//> List(SKey("publication%1:10:00::"))
SKey("publication%1:10:00::").getRelation(SRelationType.hypernym) //Hypernyms
SKey("publication%1:10:00::").getRelation(SRelationType.hyponym) //Hyponyms etc
SWordNet is available on GitHub and Sonatype

Suzana
- 4,251
- 2
- 28
- 52

Ritwik Bose
- 5,889
- 8
- 32
- 43