TypeError:无法损坏的类型:training word2vec中的“list”

2024-09-30 10:37:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我编写了这个函数并得到了TypeError: unhashable type: '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: unhashable type: 'list'


Tags: texttxtgetreturndeftypelinesentence
1条回答
网友
1楼 · 发布于 2024-09-30 10:37:09

用这个替换你的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

相关问题 更多 >

    热门问题