In [130]:
text_a = open("2014.txt").read()
text_b = open("2019.txt").read()
In [5]:
import sys
!{sys.executable} -m pip install markovify
Requirement already satisfied: markovify in /opt/anaconda3/lib/python3.8/site-packages (0.8.3)
Requirement already satisfied: unidecode in /opt/anaconda3/lib/python3.8/site-packages (from markovify) (1.1.1)
In [6]:
import markovify
In [116]:
# change to "word" for a word-level model
level = "char"
# controls the length of the n-gram
order = 10
# controls the number of lines to output
output_n = 12
# weights between the models; text A first, text B second.
# if you want to completely exclude one model, set its corresponding value to 0
weights = [0.5, 0.5]
# limit sentence output to this number of characters
length_limit = 250
In [123]:
class SentencesByChar(markovify.Text):
    def word_split(self, sentence):
        return list(sentence)
    def word_join(self, words):
        return "".join(words)
In [139]:
model_cls = markovify.Text if level == "word" else SentencesByChar
gen_a = model_cls(text_a, state_size=order)
gen_b = model_cls(text_b, state_size=order)
gen_combo = markovify.combine([gen_a, gen_b], weights)
for i in range(output_n):
    out = gen_combo.make_short_sentence(length_limit, test_output=False)
    out = out.replace("\n", " ")
At least my hair grows back quickly.

Who knows, maybe moving to New York City is too daunting.

Of course the dentist in Manhattan is not certified for that type of oral surgery.

I’m considering taking half day next year, I literally don’t have that many friends to tell.

I need to develop healthy coping mechanisms.

We can’t afford heat.

My need to be perfect has caused me a lot of time searching, but I’m ready.

I was too close to be getting a B-. It’s not a coincidence.

I felt at home again.

First, I loved the feeling.

I realized that I’m also the type of person who can plan out my work by doing only small doses in a set length of time.

Lately my academics have made me uneasy.

In [ ]: