def __init__(self, corpus, order=1, tokenize=lambda x: x):
        """ Initializes the Markov Chain with a given corpus and order """
        assert order >= 1, "Invalid Markov chain order"
        assert order <= 20, "Markov chain order too high"
        assert corpus is not None, "Corpus is empty"
        self.order = order
        self._start_symbol = '^'
        self._end_symbol = '$'
        self.tokenize = tokenize
        self._compute_transitions(corpus, self.order)
def __init__ ( self , corpus , order = 1 , tokenize = lambda x : x ) : assert order >= 1 , "Invalid Markov chain order" assert order <= 20 , "Markov chain order too high" assert corpus is not None , "Corpus is empty" self . order = order self . _start_symbol = '^' self . _end_symbol = '$' self . tokenize = tokenize self . _compute_transitions ( corpus , self . order )
Initializes the Markov Chain with a given corpus and order