Python NLTK 中的形容词名词化

发布于 2024-09-01 13:30:20 字数 117 浏览 6 评论 0原文

有没有办法使用 NLTK 获取 Wordnet 形容词名词化? 例如,对于happy,所需的输出将是happiness

我试图四处挖掘,但什么也没找到。

Is there a way to obtain Wordnet adjective nominalizations using NLTK?
For example, for happy the desired output would be happiness.

I tried to dig around, but couldn't find anything.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

固执像三岁 2024-09-08 13:30:20

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

  • S:(形容词)快乐(享受或表现出或以喜悦或快乐为标志)
    “幸福的微笑”; “度过了很多快乐
    海滩上的日子”;“幸福的婚姻”

    • 属性
      • S: (n) 幸福、幸福(幸福的状态)
        以情绪为特征的幸福感
        从满足到强烈
        喜悦)
      • S: (n) 幸福(当
        处于健康状态)
    • 派生相关形式
      • <名词.状态>; W:(n)幸福[相关:快乐](状态
        幸福感的特征是
        情绪范围从满足到
        强烈的喜悦)
      • <名词.感觉>; 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

因此,从 Python 角度来说,您可以对有点草率的 wn 命令进行 subprocess ,或者使用wordnet 设施已内置于 NLTK 中。

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

sudo apt-get install wordnet wordnet-dev

唉:

$ wn pythonic
No information available for pythonic

The quick and dirty answer is that 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)

The remaining question is how to do this programmatically (without web-scraping).

Added:

The wordnet library wrapper tool is pretty powerful and demonstrates what appears to be the breadth of the C library 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

So, Pythonically, you could either subprocess to the wn command which is kinda sloppy, or use the wordnet facilities already built into NLTK.

On ubuntu (and presumably debian) the wordnet libraries and tools are conveniently available with:

sudo apt-get install wordnet wordnet-dev

Alas:

$ wn pythonic
No information available for pythonic
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文