尽管我已经安装了 Pattern,但无法从 'gensim.utils' 导入名称 'lemmatize'
Cannot import name 'lemmatize' from 'gensim.utils' although I have installed Pattern
我尝试使用 gensim
中的 lemmatize()
函数。他们说我还必须安装 pattern
才能使用此功能。我已经安装了 gensim
和模式,但每次我尝试从 gensim
导入词形还原时,它一直显示此错误
我使用 pip install gensim
和 pip install pattern
来安装库。我的gensim版本是4.0.1,pattern是3.6
Traceback (most recent call last):
File "c:\Users\huynh\Desktop\machine_learning\test.py", line 1, in <module>
from gensim.utils import lemmatize
ImportError: cannot import name 'lemmatize' from 'gensim.utils' (C:\Users\huynh\AppData\Local\Programs\Python\Python39\lib\site-packages\gensim\utils.py)
我试图查找关于此的文档,但我只能找到我必须安装 pattern
才能使用它。有谁知道为什么我仍然没有 lemmatize()
?谢谢
目前,最好的办法是使用 gensim
3.x.x 版本,如 API 版本 4.0.0, gensim.utils.lemmatize() is not listed, while it is listed for the 3.8.3 version here 文档中所述。
编辑:
在进一步阅读文档的过程中,我发现了一个使用 nltk
包实现 lemmatize()
功能的教程。您可能想看看 this。好像他们已经放弃了 utils.lemmatize()
Gensim 以前只包装了另一个库的词形还原例程 (Pattern
) – 这不是一个特别现代或维护良好的选项,因此它已从 Gensim-4.0 中删除。
如果用户认为有必要,可以选择并应用他们自己的词形还原操作,作为应用 Gensim 算法之前的预处理步骤。
一些 Python 提供词形还原的库包括:
- Pattern(Gensim 之前自带的选项,可以直接使用,无需通过 Gensim 的旧支持):https://github.com/clips/pattern
- NLTK:https://www.nltk.org/api/nltk.stem.html#nltk.stem.wordnet.WordNetLemmatizer
- UDPipe: https://ufal.mff.cuni.cz/udpipe
- 斯帕西:https://spacy.io/api/lemmatizer
- 节:https://stanfordnlp.github.io/stanza/
我尝试使用 gensim
中的 lemmatize()
函数。他们说我还必须安装 pattern
才能使用此功能。我已经安装了 gensim
和模式,但每次我尝试从 gensim
导入词形还原时,它一直显示此错误
我使用 pip install gensim
和 pip install pattern
来安装库。我的gensim版本是4.0.1,pattern是3.6
Traceback (most recent call last):
File "c:\Users\huynh\Desktop\machine_learning\test.py", line 1, in <module>
from gensim.utils import lemmatize
ImportError: cannot import name 'lemmatize' from 'gensim.utils' (C:\Users\huynh\AppData\Local\Programs\Python\Python39\lib\site-packages\gensim\utils.py)
我试图查找关于此的文档,但我只能找到我必须安装 pattern
才能使用它。有谁知道为什么我仍然没有 lemmatize()
?谢谢
目前,最好的办法是使用 gensim
3.x.x 版本,如 API 版本 4.0.0, gensim.utils.lemmatize() is not listed, while it is listed for the 3.8.3 version here 文档中所述。
编辑:
在进一步阅读文档的过程中,我发现了一个使用 nltk
包实现 lemmatize()
功能的教程。您可能想看看 this。好像他们已经放弃了 utils.lemmatize()
Gensim 以前只包装了另一个库的词形还原例程 (Pattern
) – 这不是一个特别现代或维护良好的选项,因此它已从 Gensim-4.0 中删除。
如果用户认为有必要,可以选择并应用他们自己的词形还原操作,作为应用 Gensim 算法之前的预处理步骤。
一些 Python 提供词形还原的库包括:
- Pattern(Gensim 之前自带的选项,可以直接使用,无需通过 Gensim 的旧支持):https://github.com/clips/pattern
- NLTK:https://www.nltk.org/api/nltk.stem.html#nltk.stem.wordnet.WordNetLemmatizer
- UDPipe: https://ufal.mff.cuni.cz/udpipe
- 斯帕西:https://spacy.io/api/lemmatizer
- 节:https://stanfordnlp.github.io/stanza/