diff options
Diffstat (limited to 'priv/irc')
-rw-r--r-- | priv/irc/txt/markov.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/priv/irc/txt/markov.py b/priv/irc/txt/markov.py new file mode 100644 index 0000000..b72016e --- /dev/null +++ b/priv/irc/txt/markov.py @@ -0,0 +1,27 @@ +import markovify +import os +import string +import sys +import shlex +import unidecode + +combined_model = None +text = "" + +dir = sys.argv[1] + +for (dirpath, _, filenames) in os.walk(dir): + for filename in filenames: + with open(os.path.join(dirpath, filename)) as f: + text = text + unidecode.unidecode(f.read().lower()) + + +# Build the model. +text_model = markovify.NewlineText(text, well_formed = False) + +if len(sys.argv) > 1: + insp = " ".join(map(shlex.quote, sys.argv[2:])).lower() + print(text_model.make_sentence_with_start(unidecode.unidecode(insp), strict = False, tries = 1000)) +else: + print(text_model.make_short_sentence(280, tries=1000)) + |