Created
October 8, 2015 19:20
-
-
Save XericZephyr/462043957ee2a23ace73 to your computer and use it in GitHub Desktop.
WordNet Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from nltk.corpus import wordnet as wn | |
# get synset from offset string, e.g. 'n09208496' for asterism | |
a = wn._synset_from_pos_and_offset('n', 9208496) # got Synset('asterism.n.02') | |
# then got hypernym_paths | |
print a.hypernym_paths() | |
# got | |
""" | |
[[Synset('entity.n.01'), | |
Synset('physical_entity.n.01'), | |
Synset('object.n.01'), | |
Synset('whole.n.02'), | |
Synset('natural_object.n.01'), | |
Synset('asterism.n.02')]] | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment