我正在尝试使用“ gensim.models.doc2vec.TaggedDocument”读取然后合并2个列表,但问题是“'list'对象不可调用”。怎么办呢?
import csv
listOfTags = []
listOfTokens = []
with open('coreTag.csv', 'r') as csvfile: #reading of the 1st file
reader = csv.reader(csvfile)
for row in reader:
listOfTags.append(row)
with open('1core.csv', encoding="utf8") as csvfile: #reading and tokenizing the 2nd file
reader = csv.reader(csvfile)
for row in reader:
token = gensim.utils.simple_preprocess(str(row))
listOfTokens.append(token)
for i in listOfTokens: #trying to combine them here
for x in listOfTags:
train_corpus = list(gensim.models.doc2vec.TaggedDocument([i], [x])) #<-error is here
完整错误消息:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-92-2217e7edd027> in <module>
17 for i in listOfTokens:
18 for x in listOfTags:
---> 19 train_corpus = list(gensim.models.doc2vec.TaggedDocument([i], [x]))
TypeError: 'list' object is not callable