TypeError:不可散列的类型:训练word2vec中的'list'

问题描述 投票:0回答:1

我编写了此函数,并得到TypeError:不可哈希类型:'list'。我该如何解决?

def get_words(txt):
a=(lambda x: x not in STOP_WORDS), re.findall(r'\b(\w+)\b', txt)
return a

def sentence_words(text):
line = text.strip().lower()
sent_tokenize1=sent_tokenize(line)
sent_wordsmap=list(map(get_words,sent_tokenize1))
return sent_wordsmap

sent_word=sentence_words(text)

model = Word2Vec(sent_word, size=128, window=3, min_count=5, workers=4)

TypeError:不可散列的类型:'列表'

python typeerror text-mining word2vec word-embedding
1个回答
0
投票

用此替换您的get_words

def get_words(txt):
   a = list(filter(lambda x: x not in STOP_WORDS, re.findall(r'\b(\w+)\b', txt)))
   return a
© www.soinside.com 2019 - 2024. All rights reserved.