9

Suppose for any word I want to access its IS-A parent value and HAS-A value then is it possible using any api?

Cœur
  • 37,241
  • 25
  • 195
  • 267

3 Answers3

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

You can use commandline. The command is "wn book -hypen" to get the hypernyms of the noun book. For meronyms, use the command "wn book -meron". Also the -o option gives the synset offset. Here is the link for further information.

Legaph
  • 13
  • 5
shs
  • 66
  • 1
  • 3
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