def next_word(self, previous_words):
        """The next word that is generated by the Markov Chain
        depends on a tuple of the previous words from the Chain"""
        # The previous words may never have appeared in order in the corpus used to
        # generate the word_dict. Consequently, we want to try to find the previous 
        # words in orde, but if they are not there, then we remove the earliest word
        # one by one and recheck. This means that next word depends on the current state
        # but possible not on the entire state
        previous_words = tuple(previous_words)
        if previous_words != ("",): # the empty string 1-tuple (singleton tuple) is always there
            while previous_words not in self.word_dict:
                previous_words = tuple(previous_words[1:])
                if not previous_words:
                    return ""
        frequencies = self.word_dict[previous_words]
        inv = [(v.prob,k) for k, v in frequencies.items()]
        p, w = zip(*inv)
        return np.random.choice(w,1,p)[0]
The next word that is generated by the Markov Chain
        depends on a tuple of the previous words from the Chain