def build(self):
    '\n        Build LM from text corpus\n        '
    if self.uniform:
        self.uniform_table = get_uniform_tables(self.V)
    elif (self.ngram == 1):
        self.unigram_table = get_unigram_tables(self.V, self.N, self.counter_1gram, self.word_to_idx)
    elif (self.ngram == 2):
        self.corpus_2gram = [(self.corpus_1gram[i], self.corpus_1gram[(i + 1)]) for i in range((len(self.corpus_1gram) - 1))]
        self.counter_2gram = get_counter(self.corpus_2gram)
        self.bigram_table = get_bigram_tables(self.V, self.counter_1gram, self.counter_2gram, self.word_to_idx, self.idx_to_word)
    elif (self.ngram == 3):
        self.corpus_2gram = [(self.corpus_1gram[i], self.corpus_1gram[(i + 1)]) for i in range((len(self.corpus_1gram) - 1))]
        self.counter_2gram = get_counter(self.corpus_2gram)
        self.corpus_3gram = [(self.corpus_1gram[i], self.corpus_1gram[(i + 1)], self.corpus_1gram[(i + 2)]) for i in range((len(self.corpus_1gram) - 2))]
        self.counter_3gram = get_counter(self.corpus_3gram)
        self.trigram_table = get_trigram_tables(self.V, self.counter_2gram, self.counter_3gram, self.word_to_idx)
Build LM from text corpus
def build(self):
    '\n        \n        '
    if self.uniform:
        self.uniform_table = get_uniform_tables(self.V)
    elif (self.ngram == 1):
        self.unigram_table = get_unigram_tables(self.V, self.N, self.counter_1gram, self.word_to_idx)
    elif (self.ngram == 2):
        self.corpus_2gram = [(self.corpus_1gram[i], self.corpus_1gram[(i + 1)]) for i in range((len(self.corpus_1gram) - 1))]
        self.counter_2gram = get_counter(self.corpus_2gram)
        self.bigram_table = get_bigram_tables(self.V, self.counter_1gram, self.counter_2gram, self.word_to_idx, self.idx_to_word)
    elif (self.ngram == 3):
        self.corpus_2gram = [(self.corpus_1gram[i], self.corpus_1gram[(i + 1)]) for i in range((len(self.corpus_1gram) - 1))]
        self.counter_2gram = get_counter(self.corpus_2gram)
        self.corpus_3gram = [(self.corpus_1gram[i], self.corpus_1gram[(i + 1)], self.corpus_1gram[(i + 2)]) for i in range((len(self.corpus_1gram) - 2))]
        self.counter_3gram = get_counter(self.corpus_3gram)
        self.trigram_table = get_trigram_tables(self.V, self.counter_2gram, self.counter_3gram, self.word_to_idx)