형식 오류 : 'TfidfModel'객체는TFIDIF 모델 창조 형식 오류 Gensim에서
가없는 이유는 초기화 후 각 문서의 TFIDF 매트릭스를 계산할 수 호출하지? : 999 개의 문단으로 각각 약 5-15 문장으로 시작했습니다. 적응이 모든 것을 토큰 화 한 후, 나는 사전을 만들어 (~ 16K 고유 한 토큰) 및 코퍼스
지금 나는 TFIDF 행렬을 만들 준비가 (나중에 LDA와 w2V 해요 (튜플의리스트 목록) matricies); 그러나합니다 ('IDF'의 계산) 내 코퍼스으로 TFIDF 모델을 초기화 한 후 각 문서의 TFIDF를 참조 할 때 나는 다음과 같은 오류 메시지가 tfidf = models.TfidfModel(corpus)
tfidf(corpus[5])
형식 오류 : 'TfidfModel'객체가 호출되지 않습니다
나는 단지 각각 문장으로 구성된 4 개의 문서가있는 differnt corpus를 사용하여이 모델을 만들 수 있습니다. 여기에 예상 코퍼스 폼이 터플 목록 목록임을 확인할 수 있습니다 : [doc1 [(word1, count), (word2, count), ...], doc2 [(word3, count), (word4, 계산), ...] ...]
from gensim import corpora, models, similarities
texts = [['teenager', 'martha', 'moxley'...], ['ok','like','kris','usual',...]...]
dictionary = corpora.Dictionary(texts)
>>> Dictionary(15937 unique tokens: ['teenager', 'martha', 'moxley']...)
corpus = [dictionary.doc2bow(text) for text in texts]
>>> [[(0, 2),(1, 2),(2, 1)...],[(3, 1),(4, 1)...]...]
tfidf = models.TfidfModel(corpus)
>>> TfidfModel(num_docs=999, num_nnz=86642)
tfidf(corpus[0])
>>> TypeError: 'TfidfModel' object is not callable
corpus[0]
>>> [(0, 2),(1, 2),(2, 1)...]
print(type(corpus),type(corpus[1]),type(corpus[1][3]))
>>> <class 'list'> <class 'list'> <class 'tuple'>