我有一个标记文件/标记格式的标记文件,并且尝试了一个函数,该函数返回带有(单词,标签)列表中单词的元组。
def text_from_tagged_ngram(ngram):
if type(ngram) == tuple:
return ngram[0]
return " ".join(zip(*ngram)[0]) # zip(*ngram)[0] returns a tuple with words from a (word,tag) list
在python 2.7中效果很好,但是在python 3.4中,它给了我以下错误:
return " ".join(list[zip(*ngram)[0]])
TypeError: 'zip' object is not subscriptable
有人可以帮忙吗?
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句