Ich habe eine getaggte Datei im Format Token / Tag und versuche eine Funktion, die ein Tupel mit Wörtern aus einer (Wort-, Tag-) Liste zurückgibt.
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
In Python 2.7 hat es gut funktioniert, aber in Python 3.4 gibt es folgenden Fehler:
return " ".join(list[zip(*ngram)[0]])
TypeError: 'zip' object is not subscriptable
Kann jemand helfen?