def getTrigramsSet(pos_bigrams): s = set() for x in pos_bigrams: for bigram in x: s.add(bigram) return list(s) #calculate bigrams of every item of the list l