Python NLTK中的形容词名词化

前端之家收集整理的这篇文章主要介绍了Python NLTK中的形容词名词化前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

有没有办法使用NLTK获得Wordnet形容词标称化?
例如,对于“快乐”,期望的输出将是“快乐”.

我试图四处搜寻,但找不到任何东西.

谢谢!

最佳答案
快速而肮脏的答案是wordnet does this already

  • “a happy smile”; “spent many happy
    days on the beach”; “a happy marriage”

    • attribute
      • well-being characterized by emotions
        ranging from contentment to intense
        joy)
      • in a state of well-being)
    • derivationally related form
      • of well-being characterized by
        emotions ranging from contentment to
        intense joy)
      • (emotions experienced when in a state
        of well-being)

剩下的问题是如何以编程方式执行此操作(无需网络抓取).

添加

wordnet库包装器工具非常强大,它展示了C库接口的广度:

$wn happy
No information available for noun happy
No information available for verb happy
Information available for adj happy
    -antsa      Antonyms
    -synsa      Synonyms (ordered by estimated frequency)
    -attra      Attributes
    -deria      Derived Forms
    -famla      Familiarity & Polysemy Count
    -grepa      List of Compound Words
    -over       Overview of Senses
$wn happy -deria -n1
Derived Forms of adj happy
Sense 1
happy (vs. unhappy)
       RELATED TO->(noun) happiness#1
           => happiness,felicity
       RELATED TO->(noun) happiness#2
           => happiness

所以,从Python的角度来说,你可以对wn命令进行子处理,这有点邋or,或者使用已经内置到NLTK中的wordnet工具.

在ubuntu(可能是debian)上,wordnet库和工具可以方便地使用:

sudo apt-get install wordnet wordnet-dev

唉:

$wn pythonic
No information available for pythonic
原文链接:/python/439032.html

猜你在找的Python相关文章