def get_backoff(self, ngram):
        assert(len(ngram) == 3)
        ngram = tuple(ngram)
        # trigram (1, 2, 3)
        if ngram in self.lm:
            return 1.0
        # two bigrams (1, 2) and (2, 3)
        elif ngram[:2] in self.lm and ngram[1:] in self.lm:
            return 0.8
        # bigram (2, 3)
        elif ngram[1:] in self.lm:
            return 0.6
        # bigram (1, 2) and unigram (3)
        elif ngram[:2] in self.lm and ngram[2:] in self.lm:
            return 0.4
        # unigrams (2) and (3)
        elif ngram[1:2] in self.lm and ngram[2:] in self.lm:
            return 0.3
        # unigram (3)
        elif ngram[2:] in self.lm:
            return 0.2
        # all words unknown
        else:
            return 0.1


    # returns a set of features related to LM
    # currently extracting: highest order ngram including the word and its LEFT context,
    #                       highest order ngram including the word and its RIGHT context
dataset/ETHPy150Open qe-team/marmot/marmot/features/lm_feature_extractor.py/LMFeatureExtractor.get_backoff/original