2017-12-03 48 views
0

我目前正在尝试训练我的Python NLTK词性标记器以正确标记德语文本。为了做到这一点我使用的ClassifiedBasedGermanTagger,距离:random.shuffle(someLazyMap)

https://github.com/ptnplanet/NLTK-Contributions/tree/master/ClassifierBasedGermanTagger

,并从该网站训练语料库:

http://www.ims.uni-stuttgart.de/forschung/ressourcen/korpora/TIGERCorpus/download/start.html (TIGER语料库2.2版(2012年7月))

我发现有一个关于如何去做这件事的写得很好的教程。所以现在所有我想要做的是重新创建代码:

https://datascience.blog.wzb.eu/2016/07/13/accurate-part-of-speech-tagging-of-german-texts-with-nltk/

不为我工作的一部分是这样的:

tagged_sents = corp.tagged_sents() 
random.shuffle(tagged_sents) 

我得到貌似错误这样的:

File "C:\somedude\lib\random.py", line 274, in shuffle 
    x[i], x[j] = x[j], x[i] 
TypeError: 'LazyMap' object does not support item assignment 

你对此有一个解决办法,甚至是写了一个解释,为什么它理应为君子工作该教程,以及为什么它显示错误˚F或者我?目前我正在使用Python 3.

非常感谢你提前。

回答

1

晚了一点找到一个解决方案,但也许它可以帮助别人。

本教程的作者忘了作为NLTK书中所述的 “清单”: http://www.nltk.org/book/ch06.html#evaluation

所以不是

tagged_sents = corp.tagged_sents()

它必须是:

tagged_sents = list(corp.tagged_sents())

相关问题