【问题标题】:Lemmatizing German Texts with Textblob-de使用 Textblob-de 对德语文本进行词形还原
【发布时间】:2019-06-25 09:18:11
【问题描述】:

Textblob-de 是 Textblob 的德语扩展名,记录在 https://textblob-de.readthedocs.io/en/latest/#

我想将诸如 hast -> haben、Häuser -> Haus 之类的德语单词与 Textblob-de 进行词形还原

我从 J. Schneider 那里找到了这篇关于 Python 中不同的词形还原方法的帖子,它是为英语量身定制的,其中还包括关于 Textblob 的部分(英文版):https://www.machinelearningplus.com/nlp/lemmatization-examples-python/

我想知道德语扩展中是否也有可能进行词形还原。

根据 J. Schneider 的文字,应该可以通过以下几行进行词形还原

from textblob_de import TextBlobDE, Word
word = 'hast Häuser'
w = Word(word)
w.lemmatize()

我收到以下 NotImplementedError:

NotImplementedError                       Traceback (most recent call last)
<ipython-input-5-16cfb68c1c58> in <module>
      2 word = 'hast Häuser'
      3 w = Word(word)
----> 4 w.lemmatize()

/anaconda3/lib/python3.7/site-packages/textblob/decorators.py in decorated(*args, **kwargs)
     33     def decorated(*args, **kwargs):
     34         try:
---> 35             return func(*args, **kwargs)
     36         except LookupError as err:
     37             print(err)

/anaconda3/lib/python3.7/site-packages/textblob_de/blob.py in lemmatize(self, pos)
    161         #lemmatizer = nltk.stem.WordNetLemmatizer()
    162         # return lemmatizer.lemmatize(self.string, pos)
--> 163         raise NotImplementedError
    164 
    165     @cached_property

NotImplementedError: 

我希望输出如下:

haben Haus

【问题讨论】:

    标签: python lemmatization textblob


    【解决方案1】:

    试试下面的代码:

    from textblob_de import TextBlobDE
    
    word = 'hast Häuser'
    w = TextBlobDE(word)
    print(w.words.lemmatize())
    

    输出:

    ['hast', 'Häuser']
    

    有关TextBlob 的德语支持的更多信息,请查看this

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-01
      • 1970-01-01
      • 2014-12-05
      • 2020-10-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-15
      • 2018-11-03
      相关资源
      最近更新 更多