【问题标题】:getting the lemma of a word using wordnet使用 wordnet 获取单词的引理
【发布时间】:2011-07-21 22:39:50
【问题描述】:

如何使用 Wordnet 获取给定单词的引理。我似乎无法在 wordnet 文档中找到我想要的东西。 http://wordnet.princeton.edu/wordnet/man/wn.1WN.html

例如对于单词“books”,我想得到“book”,ashes => ash,booking => book,apples => apple .... 等等。

我想在命令行中使用 wordnet 来实现这一点,但我找不到准确的选项来检索这种情况。

php 解决方案也会有很大帮助,因为我最初打算使用 wordnet php API,但他们网站上的当前 API 似乎无法正常工作。

【问题讨论】:

    标签: php nlp wordnet lemmatization morphological-analysis


    【解决方案1】:

    Morphy 是 WordNet 原生的形态处理器。作为查找过程的一部分,WordNet 接口调用 Morphy 对单词进行词形还原(例如,您查询“enlightened”,它会返回“enlightened”和通过 Morphy 的“enlighten”的结果)。

    这些界面不包含允许用户直接访问 Morphy 的功能,因此只有在使用 WordNet API 之一编写自己的程序时才能在命令行中使用它。您可以在 WordNet 网站上找到 Morphy 的 documentation

    据我所知,PHP interface 仍然可用,但您可能需要使用 WordNet 2.x。

    【讨论】:

      【解决方案2】:

      如果您可以使用其他工具,请尝试TreeTagger

      【解决方案3】:

      我不确定 WordNet 是否本机实现它。 NLTK 有 Morphy,它正是你想要的,但它是用 Python 实现的。您可以编写一个小型 Python 程序来从命令行获取输入并返回引理。

      在以下链接中搜索“Morphy”: http://nltk.googlecode.com/svn/trunk/doc/api/nltk.corpus.reader.wordnet.WordNetCorpusReader-class.html

      nltk.WordNetLemmatizer() 也可以完成这项工作。在以下链接中搜索“Lemmatization”: http://nltk.googlecode.com/svn/trunk/doc/book/ch03.html

      NLTK 网站:http://www.nltk.org/

      【讨论】:

        【解决方案4】:

        nltk 库中的 WordNetLemmatizer 将满足您的需求。这是python3代码:

        #!Python3 -- this is lemmatize_s.py
        import nltk
        from nltk.stem import WordNetLemmatizer
        from nltk.tokenize import word_tokenize
        print ("This program will lemmatize your input until you ask for it to 'end'.")
        while True:
            sentence = input("Type one or more words (or 'end') and press enter:")
            if (sentence == "end"):
                break
            tokens = word_tokenize(sentence)
            lemmatizer = WordNetLemmatizer()
            Output=[lemmatizer.lemmatize(word) for word in tokens]
            print (Output);
        

        从命令行运行:

        eyeMac2016:james$ python3 lemmatize_s.py
        This program will lemmatize your input until you ask for it to 'end'.
        Type one or more words  (or 'end') and press enter:books ashes
        ['book', 'ash']
        Type one or more words  (or 'end') and press enter:end
        eyeMac2016:james$ 
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2017-01-11
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2012-12-02
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多