Python NLTK中的形容词名词化

abh*_*hgh 5 python nlp nltk wordnet

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

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

谢谢!

msw*_*msw 4

快速而肮脏的答案是 wordnet已经这样做了

  • <adj.all>S:(adj)快乐(享受或表现出或以喜悦或快乐为标志)“幸福的微笑”;“在海滩上度过了许多快乐的日子”;“幸福的婚姻”

    • 属性
      • <名词.状态>S: (n) 幸福、幸福(以从满足到强烈喜悦的情绪为特征的幸福状态)
      • <名词.feeling>S:(n) 幸福(处于幸福状态时所经历的情绪)
    • 派生相关形式
      • <名词.状态> W:(n) 幸福 [相关:快乐](以从满足到强烈喜悦的情绪为特征的幸福状态)
      • <名词.feeling> W:(n) 幸福 [相关:快乐](处于幸福状态时所经历的情绪)

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

添加:

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
Run Code Online (Sandbox Code Playgroud)

所以,从 Python 角度来说,你可以subprocess使用有点草率的 wn 命令,或者使用 NLTK 中已经内置的 wordnet 工具。

在 ubuntu(大概还有 debian)上,可以通过以下方式方便地使用 wordnet 库和工具:

sudo apt-get install wordnet wordnet-dev
Run Code Online (Sandbox Code Playgroud)

唉:

$ wn pythonic
No information available for pythonic
Run Code Online (Sandbox Code Playgroud)