有没有办法使用 NLTK 获取 Wordnet 形容词名词化?
例如,对于happy
,所需的输出将是happiness
。
我试图四处挖掘,但找不到任何东西。
最佳答案
快速而肮脏的答案是 wordnet does this already :
<adj.all>S: (adj) happy (enjoying or showing or marked by joy or pleasure) "a happy smile"; "spent many happy days on the beach"; "a happy marriage"
- attribute
- <noun.state>S: (n) happiness, felicity (state of well-being characterized by emotions ranging from contentment to intense joy)
- <noun.feeling>S: (n) happiness (emotions experienced when in a state of well-being)
- derivationally related form
- <noun.state> W: (n) happiness [Related to: happy] (state of well-being characterized by emotions ranging from contentment to intense joy)
- <noun.feeling> W: (n) happiness [Related to: happy] (emotions experienced when in a state of well-being)
剩下的问题是如何以编程方式执行此操作(无需网络抓取)。
添加:
wordnet 库包装工具非常强大,并且演示了 C 库接口(interface)的广度:
$ 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 命令进行子处理,这有点草率,或者使用 NLTK 中已内置的 wordnet 工具。
在 ubuntu(大概还有 debian)上,可以通过以下方式方便地使用 wordnet 库和工具:
sudo apt-get install wordnet wordnet-dev
唉:
$ wn pythonic
No information available for pythonic
关于python - Python NLTK 中的形容词名词化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2836959/