How to compare output of wordnet.synsets?

怎甘沉沦 提交于 2019-12-13 07:15:51

问题


I want compare output from the wordnet.synset function in the NLTK library. In an example when I run:

from nltk.corpus import wordnet as wn
wn.synsets('dog')

I get output:

output:
        [Synset('dog.n.01'),
     Synset('frump.n.01'),
     Synset('dog.n.03'),
     Synset('cad.n.01'),
     Synset('frank.n.02'),
     Synset('pawl.n.01'),
     Synset('andiron.n.01'),
     Synset('chase.v.01')]

Now if I try:

from nltk.corpus import wordnet as wn
    wn.synsets('dogg')

I get output

output: 
[]

How can I compare the outputs in the console to build logic around it? Logic could be "if word not in output then mispelled"

Thank you in advance.

来源:https://stackoverflow.com/questions/39455417/how-to-compare-output-of-wordnet-synsets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!