def __init__(self, corpus, ngram, min_freq, uniform=False):
    '\n        Initialize language model\n        :param corpus: input text corpus to build LM on\n        :param ngram: number of n-gram, e.g. 1, 2, 3, ...\n        :param min_freq: minimum frequency threshold to set a word to UNK placeholder\n                         set to 1 to not use this threshold\n        :param uniform: boolean flag, set to True to indicate this model is a simple uniform LM\n                        otherwise will be an N-gram model\n        '
    self.corpus = corpus
    self.ngram = ngram
    self.min_freq = min_freq
    self.uniform = uniform
    self.uniform_table = None
    self.unigram_table = None
    self.bigram_table = None
    self.trigram_table = None
    self.infrequent_words = find_infrequent_words(self.corpus, self.min_freq)
    replace_infrequent_words(self.corpus, self.infrequent_words)
    (self.corpus_1gram, self.vocabulary, self.V, self.N) = get_vocabulary(self.corpus)
    (self.word_to_idx, self.idx_to_word) = get_word_mappings(self.vocabulary)
    self.counter_1gram = get_counter(self.corpus_1gram)
    self.build()
Initialize language model
:param corpus: input text corpus to build LM on
:param ngram: number of n-gram, e.g. 1, 2, 3, ...
:param min_freq: minimum frequency threshold to set a word to UNK placeholder
                 set to 1 to not use this threshold
:param uniform: boolean flag, set to True to indicate this model is a simple uniform LM
                otherwise will be an N-gram model
def __init__(self, corpus, ngram, min_freq, uniform=False):
    '\n        Initialize language model\n        :param corpus: input text corpus to build LM on\n        :param ngram: number of n-gram, e.g. 1, 2, 3, ...\n        :param min_freq: minimum frequency threshold to set a word to UNK placeholder\n                         set to 1 to not use this threshold\n        :param uniform: boolean flag, set to True to indicate this model is a simple uniform LM\n                        otherwise will be an N-gram model\n        '
    self.corpus = corpus
    self.ngram = ngram
    self.min_freq = min_freq
    self.uniform = uniform
    self.uniform_table = None
    self.unigram_table = None
    self.bigram_table = None
    self.trigram_table = None
    self.infrequent_words = find_infrequent_words(self.corpus, self.min_freq)
    replace_infrequent_words(self.corpus, self.infrequent_words)
    (self.corpus_1gram, self.vocabulary, self.V, self.N) = get_vocabulary(self.corpus)
    (self.word_to_idx, self.idx_to_word) = get_word_mappings(self.vocabulary)
    self.counter_1gram = get_counter(self.corpus_1gram)
    self.build()