所以我有一个如下所示的列表:
list[[tuple(),tuple(),tuple()], [tuple(),tuple(),tuple()]]
所以基本上是一个列表列表,其中每个内部列表包含元组(word,tag)。 当我尝试训练Bigram Tagger时,它会返回错误
list := list[[tuple(),tuple(),tuple()], [tuple(),tuple(),tuple()]]
bigram_tagger = nltk.BigramTagger(list)
给我回复错误:
Traceback (most recent call last):
File "PATH/project.py", line 123, in <module>
bigram_tagger = nltk.BigramTagger(list)
File "C:\Users\User\AppData\Local\Programs\Python\Python35-32\lib\site-
packages\nltk\tag\sequential.py", line 378, in __init__
backoff, cutoff, verbose)
File "C:\Users\User\AppData\Local\Programs\Python\Python35-32\lib\site-packages\nltk\tag\sequential.py", line 287, in __init__
self._train(train, cutoff, verbose)
File "C:\Users\User\AppData\Local\Programs\Python\Python35-32\lib\site-packages\nltk\tag\sequential.py", line 184, in _train
fd[context][tag] += 1
TypeError: unhashable type: 'list'
答案 0 :(得分:0)
可能是命名约定错误。通常关键词如&#39; list&#39;不应该用于变量名。
这就是为什么你可能会得到这个
TypeError: unhashable type: 'list'