wordnet lemmatizer in NLTK is not working for adverbs [duplicate]

牧云@^-^@ 提交于 2020-05-13 14:42:06

问题


from nltk.stem import WordNetLemmatizer
x = WordNetLemmatizer()   
x.lemmatize("angrily", pos='r')
Out[41]: 'angrily'

Here is reference documnetation for pos tags in nltk wordnet, http://www.nltk.org/_modules/nltk/corpus/reader/wordnet.html

I may be missing some basic things. Please let me know


回答1:


Try:

>>> from nltk.corpus import wordnet as wn
>>> wn.synset('angrily.r.1').lemmas()[0].pertainyms()[0].name()
u'angry'

See Getting adjective from an adverb in nltk or other NLP library for more information

The question is why do you have to go through the lemmas to get the pertainyms?

>>> wn.synset('angrily.r.1').pertainyms()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Synset' object has no attribute 'pertainyms'

It's because WordNet sees it as a lexical association between word categories, see http://wordnet.princeton.edu/man/wngloss.7WN.html

Pertainyms are relational adjectives and do not follow the structure just described. Pertainyms do not have antonyms; the synset for a pertainym most often contains only one word or collocation and a lexical pointer to the noun that the adjective is "pertaining to". Participial adjectives have lexical pointers to the verbs that they are derived from.

Then again, if we look at the Java interface, getting a synset's pertainym is as easy as AdjectiveSynset.getPertainyms() (http://lyle.smu.edu/~tspell/jaws/doc/edu/smu/tspell/wordnet/AdjectiveSynset.html)

So I guess it depends on who writes the interface, what sort of perspective they take towards adjective-adverb relationship.

For me I think pertainyms would have been directly related to the synset rather than the lemma.



来源:https://stackoverflow.com/questions/28475620/wordnet-lemmatizer-in-nltk-is-not-working-for-adverbs

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