def addTruncations(lexicon, textwords, truncation_label, min_cut_phonemes=2, min_left_phonemes=2, LEXICON_CONSTANT=1):
    """ Adds truncated lexicon entries for all textwords into the lexicon inplace.
    Returns the added words as a set. 

    Note: LEXICON_CONSTANT is used here to keep compatibility with both lexiconp.txt and lexicon.txt
    formats. It is either 1 or 0, as lexicon[uttid][0] can be a weight or the first phoneme of the
    pronunciation.
    """
    truncation_words = set()
    for word in textwords:
        for pronunciation in lexicon[word]:
            pronunciation_list = pronunciation.split()
            if len(pronunciation_list) - LEXICON_CONSTANT < min_cut_phonemes + min_left_phonemes:
                continue
            for upto_pos in range(min_left_phonemes + LEXICON_CONSTANT, len(pronunciation_list) - min_cut_phonemes):
                truncation = u" ".join(pronunciation_list[:upto_pos])
                truncation_word = truncation_label + word
                lexicon.setdefault(truncation_word, []).append(truncation)
                truncation_words.add(truncation_word)
    return truncation_words