API

MarkovPy

class markov.MarkovPy(store)
learn(line, prepared=False)

learn from line

Parameters:
  • line (str) – line to add
  • prepared (bool) – line was already split to words
process(line, learn=True, reply=True)

process line

Parameters:
  • line (str) – line to process
  • learn (bool) – learn from line
  • reply (bool) – reply to line (and return answer)
Returns:

answer if reply

Return type:

str

reply(start, min_length=5, max_length=10, prepared=False)

generate a reply to start

Parameters:
  • min_length (int) – minimal length of reply
  • max_length (int) – max length of reply
  • prepared (bool) – line was already split to words
Returns:

response

Return type:

str

Prepare

markov.markov.is_smiley(word)

check if word is a smiley

Parameters:word (str) – word to check
Returns:result of check
Return type:bool
markov.markov.prepare_line(line)

split words to line, lower words, add newlines and remove invalid chars

Parameters:line (str) – line to prepare
Returns:prepared line
Return type:list

Stores