TypeError: unhashable type: 'list' for text summarization
TypeError: unhashable type: 'list' for text summarization
from nltk.corpus import indian
sentence_score={}
#word=nltk.word_tokenize(text)
for sent in sentences:
word_count_in_sentence = (len(nltk.word_tokenize(sentence)))
if word in wordfreq.keys():
if sent not in sentence_score.keys():
sentence_score[sent]=wordfreq[word]
else:
senetence_score[sent]+=wordfreq[word]
我收到这个错误我该怎么办
TypeError: unhashable type: 'list' for line 7 i.e if word in wordfreq.keys():
使用 defaultdict
from nltk.corpus import indian
from collections import defaultdict
sentence_score=defaultdict(int)
#word=nltk.word_tokenize(text)
for sent in sentences:
word_count_in_sentence = (len(nltk.word_tokenize(sentence)))
if word in wordfreq:
senetence_score[sent]+=wordfreq[word]
from nltk.corpus import indian
sentence_score={}
#word=nltk.word_tokenize(text)
for sent in sentences:
word_count_in_sentence = (len(nltk.word_tokenize(sentence)))
if word in wordfreq.keys():
if sent not in sentence_score.keys():
sentence_score[sent]=wordfreq[word]
else:
senetence_score[sent]+=wordfreq[word]
我收到这个错误我该怎么办
TypeError: unhashable type: 'list' for line 7 i.e if word in wordfreq.keys():
使用 defaultdict
from nltk.corpus import indian
from collections import defaultdict
sentence_score=defaultdict(int)
#word=nltk.word_tokenize(text)
for sent in sentences:
word_count_in_sentence = (len(nltk.word_tokenize(sentence)))
if word in wordfreq:
senetence_score[sent]+=wordfreq[word]