gpt4 book ai didi

python - 使用 Wordnet Lemmatizer 获取词根

转载 作者:行者123 更新时间:2023-11-28 21:08:52 24 4
gpt4 key购买 nike

我需要为关键字提取器找到与所有相关词匹配的公共(public)词根。

如何使用 python nltk 词形还原器将单词转换为相同的词根?

  • 例如:
    1. generalized, generalization -> general
    2. 优化的,优化的 -> 优化(也许)
    3. 配置,配置,配置 -> 配置

python nltk lemmatizer 在使用词性 (pos) 标记参数但不用于“泛化”时为“泛化”和“泛化”提供“泛化”。

有办法吗?

最佳答案

使用 SnowballStemmer:

>>> from nltk.stem.snowball import SnowballStemmer
>>> stemmer = SnowballStemmer("english")
>>> print(stemmer.stem("generalized"))
general
>>> print(stemmer.stem("generalization"))
general

Note: Lemmatisation is closely related to stemming. The difference is that a stemmer operates on a single word without knowledge of the context, and therefore cannot discriminate between words which have different meanings depending on part of speech.

我在词形还原器中看到的一个普遍问题是它会将更大的词识别为词元

例子:在 WordNet Lemmatizer(在 NLTK 中检查),

  • 泛化 => 泛化
  • 泛化=>泛化
  • 概括 => 概括

在上述情况下,POS 标记未作为输入给出,因此始终被视为名词

关于python - 使用 Wordnet Lemmatizer 获取词根,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39302880/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com