python - Python NLTK 中的形容词名词化

标签 python nlp nltk wordnet

有没有办法使用 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/

相关文章:

python json unicode - 我如何使用javascript进行评估

python - 如何在Python中的SQL语句中使用变量?

python - 调用在 Python 中如何工作?

neural-network - 如何使用经过训练的 CBOW 预测单词

python - 导入错误: cannot import name porter python

python - 为什么填充词汇的困惑对于 nltk.lm bigram 来说是不定式?

python - SciPy interp2d(linear) 结果不同于 MatLab interp2(linear)

java - Java中的自动语义角色标记(ASRL)(使用Java中的Frame net)

python-3.x - 如何从 TextBlob 翻译中检索翻译

python - 在 Python 中计算 BLEU 分数