diff options
author | href <href@random.sh> | 2020-03-11 21:18:34 +0100 |
---|---|---|
committer | href <href@random.sh> | 2020-03-11 21:18:34 +0100 |
commit | a28d24470ddeca6196219a1333c1ccac1319efef (patch) | |
tree | 4f29e3c8fb6afbb1f99d6b8737f844c95fca54df /priv/irc/txt/markov.py | |
parent | up to 420*100 (diff) |
welp
Diffstat (limited to '')
-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)) + |