最佳答案
我有一个标记文件的格式令牌/标记,并尝试使用一个函数返回一个元组,其中包含来自(word,tag)列表的单词。
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
有人能帮忙吗?