【问题标题】:How to find the Lexical Category of a word in wordnet using NLTK(python)如何使用 NLTK(python)在 wordnet 中查找单词的词汇类别
【发布时间】:2015-03-05 11:07:41
【问题描述】:

shown here 的 wordnet 演示在其搜索结果中显示文件的词法信息。例如,motion这个词有很多词汇类别(因为它有很多“意义”),其中一个是“verb.motion”。我见过另一个questions,但他们没有解释你如何在NLTK中做到这一点.如何使用 NLTK 获取该信息。

【问题讨论】:

  • 恕我直言,您正在搜索可能的引理。您是否访问过这个网站:nltk.org/howto/wordnet.html
  • @frankov 那是我实际查找的第一个地方。无论如何,根据我对引理的理解,它们只不过是一个单词的基本形式,独立于感官。例如,我们有“内容”这个词,它具有“材料的比例”和“被竞争的状态”的含义,而这些含义的引理就是“内容”这个词。我想要的是与之相关的词汇信息,即对于上述两个示例,它将是“noun.relation”和“noun.state”。如果我错了,请纠正我。
  • 也许您正在搜索词法词典?
  • 好的,看这里:nltk.org/book/ch05.html 在“7 如何确定单词的类别”和“7.2 句法线索”小节 - 它有点简洁,但你可以从那里开始 - 如果它是你在搜索什么。
  • @frankov 首先感谢您的努力,但 POS 标记不是我想要的。这里看一下 wordnet 网站上“转移”这个词的示例定义: S: (v) 转移、重新分配(将某人转移到不同的职位或工作地点)S: (v ) 转移(从一个地方移动到另一个地方)“转移数据”。正如您在此处看到的,您有诸如“”之类的类别。我想使用 NLTK 提取这些类别。

标签: python nltk wordnet


【解决方案1】:

@基兰·亚拉班迪

我不知道你想要什么。但现在,我有例子:

In [1]: from nltk.corpus import wordnet as wn

In [35]: for synset in wn.synsets('move'):
    print "<%s> (%s) %s" % (synset.lexname, synset.definition, 

synset.examples)
   ....:     
<noun.act> (the act of deciding to do something) ["he didn't make a move to help", 'his first move was to hire a lawyer']
<noun.act> (the act of changing your residence or place of business) ['they say that three moves equal one fire']
<noun.act> (a change of position that does not entail a change of location) ['the reflex motion of his eyebrows revealed his surprise', 'movement is a sign of life', 'an impatient move of his hand', 'gastrointestinal motility']
<noun.act> (the act of changing location from one place to another) ['police controlled the motion of the crowd', 'the movement of people from the farms to the cities', 'his move put him directly in my path']
<noun.act> ((game) a player's turn to take some action permitted by the rules of the game) []
<verb.motion> (change location; move, travel, or proceed, also metaphorically) ['How fast does your new car go?', 'We travelled from Rome to Naples by bus', 'The policemen went from door to door looking for the suspect', 'The soldiers moved towards the city in an attempt to take it before night fell', 'news travelled fast']
<verb.motion> (cause to move or shift into a new position or place, both in a concrete and in an abstract sense) ['Move those boxes into the corner, please', "I'm moving my money to another bank", 'The director moved more responsibilities onto his new assistant']
<verb.motion> (move so as to change position, perform a nontranslational motion) ['He moved his hand slightly to the right']
<verb.motion> (change residence, affiliation, or place of employment) ['We moved from Idaho to Nebraska', 'The basketball player moved from one team to another']
<verb.social> (follow a procedure or take a course) ['We should go farther in this matter', 'She went through a lot of trouble', 'go about the world in a certain manner', 'Messages must go through diplomatic channels']
<verb.body> (be in a state of action) ['she is always moving']
<verb.change> (go or proceed from one point to another) ['the debate moved from family values to the economy']
<verb.social> (perform an action, or work out or perform (an action)) ['think before you act', 'We must move quickly', 'The governor should act on the new energy bill', 'The nanny acted quickly by grabbing the toddler and covering him with a wet towel']
<verb.emotion> (have an emotional or cognitive impact upon) ['This child impressed me as unusually mature', 'This behavior struck me as odd']
<verb.creation> (give an incentive for action) ['This moved me to sacrifice my career']
<verb.emotion> (arouse sympathy or compassion in) ['Her fate moved us all']
<verb.possession> (dispose of by selling) ['The chairman of the company told the salesmen to move the computers']
<verb.change> (progress by being changed) ['The speech has to go through several more drafts', 'run through your presentation before the meeting']
<verb.social> (live one's life in a specified environment) ['she moves in certain circles only']
<verb.competition> (have a turn; make one's move in a game) ['Can I go now?']
<verb.communication> (propose formally; in a debate or parliamentary meeting) []

这是你需要的吗?您必须通过 nltk 下载器下载 wordnet 语料库。

【讨论】:

    【解决方案2】:

    太糟糕了,它不允许我添加评论,我必须提交作为答案。

    要添加到 404pio 的答案,

    而不是这个:

    synset.lexname
    

    你想要这个:

    synset.lexname()
    

    原因:他们只是对 nltk 进行了更新和更改。

    来源:https://stackoverflow.com/a/27796656

    【讨论】:

      猜你喜欢
      • 2023-03-11
      • 1970-01-01
      • 2013-07-14
      • 1970-01-01
      • 1970-01-01
      • 2014-08-31
      • 1970-01-01
      • 2013-02-26
      • 1970-01-01
      相关资源
      最近更新 更多