我是这些框架以及 NLP 的新手。我正在关注一个示例,该示例为我提供了以下代码片段来计算推文中所有标记的 tf-idf 分数。但是,我不断收到导入错误或未定义的 Vectorizer。
代码:
import spacy
from textacy.vsm import Vectorizer
import textacy.vsm
vectorizer = Vectorizer(weighting = 'tfidf')
term_matrix = vectorizer.fit_transform([tok.lemma_ for tok in doc] for doc
in spacy_tweets)
收到的错误:
from textacy.vsm import Vectorizer
ImportError: cannot import name 'Vectorizer
//
import textacy
vectorizer = textacy.Vectorizer(weighting='tfidf')
AttributeError: module 'textacy' has no attribute 'Vectorizer'
//
import textacy
vectorizer = Vectorizer(weighting='tfidf')
NameError: name 'Vectorizer' is not defined
我的环境
operating system: windows 10 64bit
python version: Python 3.6.4 :: Anaconda, Inc.
spacy version: 1.9.0-np111py36_vc14_1 installed
spacy models: en_core_web_sm
textacy version: 0.3.4-py36_0
访问 textacy vectorizer 类的正确导入语句是什么?