Skip to content
Snippets Groups Projects
Commit dd0af2e4 authored by jmzk96's avatar jmzk96
Browse files

corrected typo

parent afef8a76
Branches
No related tags found
No related merge requests found
import random
class Markov_Chain:
def __init__(self,n):
......@@ -12,13 +14,17 @@ class Markov_Chain:
def learn_tokens(self, text):
tokens = text.split(" ")
n_grams = [(tokens[i],tokens[i+1]) for i in range(0,len(tokens)-1))]
n_grams = [(tokens[i],tokens[i+1]) for i in range(0,len(tokens)-1)]
for gram in n_grams:
self.__learn_token_from_text(gram[0],gram[1])
def predict_next(self,current_state):
def __next(self,current_state):
next_word = self.database.get(current_state)
if not next_word:
next_word = self.database.keys()
\ No newline at end of file
return random.sample(next_word,1)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment