How to get similar words using wordnet, and not only the synonyms using synsets and their lemmas?
For example, if you search for "happy" on the wordnet online tool ( http://wordnetweb.princeton.edu/ ). For the first synset there is only one synonym (happy) but if you click on it (on the S: link) you get additional words in "see also" and "similar to" words, like "cheerful".
How do I get these words and what are they called in wordnet terminology? I am using python with nltk and can only get the synsets and lemmas at best (excluding the hypernyms etc.)
"also_sees()" and "similar_tos()".
>>> from nltk.corpus import wordnet as wn
>>> wn.synsets("happy")[0].also_sees()
[Synset('cheerful.a.01'), Synset('contented.a.01'), Synset('elated.a.01'), Synset('euphoric.a.01'), Synset('felicitous.a.01'), Synset('glad.a.01'), Synset('joyful.a.01'), Synset('joyous.a.01')]
>>> wn.synsets("happy")[0].similar_tos()
[Synset('blessed.s.06'), Synset('blissful.s.01'), Synset('bright.s.09'), Synset('golden.s.02'), Synset('laughing.s.01')]
If you want to see the full list of what a WordNet synset can do, try the "dir()" command. (It'll be full of objects you probably don't want, so I stripped out the underscored below.)
>>> [func for func in dir(wn.synsets("happy")[0]) if func[0] != "_"]
['acyclic_tree', 'also_sees', 'attributes', 'causes', 'closure', 'common_hypernyms', 'definition', 'entailments', 'examples', 'frame_ids', 'hypernym_distances', 'hypernym_paths', 'hypernyms', 'hyponyms', 'in_region_domains', 'in_topic_domains', 'in_usage_domains', 'instance_hypernyms', 'instance_hyponyms', 'jcn_similarity', 'lch_similarity', 'lemma_names', 'lemmas', 'lexname', 'lin_similarity', 'lowest_common_hypernyms', 'max_depth', 'member_holonyms', 'member_meronyms', 'min_depth', 'mst', 'name', 'offset', 'part_holonyms', 'part_meronyms', 'path_similarity', 'pos', 'region_domains', 'res_similarity', 'root_hypernyms', 'shortest_path_distance', 'similar_tos', 'substance_holonyms', 'substance_meronyms', 'topic_domains', 'tree', 'usage_domains', 'verb_groups', 'wup_similarity']
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.