0
你好下面是我的功能在PythonTFIDF在Python
def tf_idf(self,job_id,method='local'):
jobtext = self.get_job_text (job_id , method=method)
tfidf_vectorizer = TfidfVectorizer(max_df=0.8 , max_features=200000 ,
min_df=0.2 , stop_words='english' ,
use_idf=True , tokenizer=self.tokenize_and_stem(jobtext), ngram_range=(1, 3))
#tfidf_vectorizer.fit(jobtext)
tfidf_matrix = tfidf_vectorizer.fit_transform(jobtext) #fit the vectorizer to synopses
print(tfidf_matrix.shape)
創建TFIDF矩陣,我收到以下錯誤:
回溯(最近通話最後一個):
File ".../employment_skills_extraction-master/api/process_request.py", line 206, in <module> main() File ".../employment_skills_extraction-master/api/process_request.py", line 202, in main print pr.process(json.dumps(test)) File ".../employment_skills_extraction-master/api/process_request.py", line 188, in process termVector=self.tf_idf(job_id) File ".../employment_skills_extraction-master/api/process_request.py", line 174, in tf_idf tfidf_matrix = tfidf_vectorizer.fit_transform(jobtext) #fit the vectorizer to synopses File "/usr/local/lib/python2.7/dist-packages/sklearn/feature_extraction/text.py", line 1285, in fit_transform X = super(TfidfVectorizer, self).fit_transform(raw_documents) File "/usr/local/lib/python2.7/dist-packages/sklearn/feature_extraction/text.py", line 804, in fit_transform self.fixed_vocabulary_) File "/usr/local/lib/python2.7/dist-packages/sklearn/feature_extraction/text.py", line 739, in _count_vocab for feature in analyze(doc): File "/usr/local/lib/python2.7/dist-packages/sklearn/feature_extraction/text.py", line 236, in <lambda> tokenize(preprocess(self.decode(doc))), stop_words) TypeError: 'list' object is not callable
請幫助我爲什麼得到這個錯誤?