from cfgen import GrammarModel

# can turn these off:
%load_ext autoreload
%autoreload 2
# %autoreload 0

"""
Explanation: cfgen demos
Import package
End of explanation
"""


CORPUS_PATH = './resources/corpora/frankenstein.txt'
MODEL_ORDER = 2
my_model = GrammarModel(CORPUS_PATH, MODEL_ORDER)    

"""
Explanation: Initialize model
End of explanation
"""


from random import seed
seed(5)

simple_sentence = 'The cow jumped over the moon, and the little dog laughed.'
for ii in range(3):
    print(my_model.make_sentence(fixed_grammar=True, sample_sentence=simple_sentence))

"""
Explanation: Make a random sentence with fixed grammar
End of explanation
"""


from random import seed
seed(5)

simple_sentence = 'The cow jumped over the moon, and the little dog laughed.'

for ii in range(3):
    print(my_model.make_sentence(fixed_grammar=True, sample_sentence=simple_sentence, do_markov=False))

"""
Explanation: Compare to a CFG without Markov
End of explanation
"""


from random import seed
seed(5)

for ii in range(2):
    print(my_model.make_sentence(do_markov=False))

"""
Explanation: Base style on a random sentence from the input text, but don't use Markov chain to select words
End of explanation
"""


from random import seed
seed(5)

for ii in range(2):
    print(my_model.make_sentence(do_markov=True))

"""
Explanation: Parse a random sentence from the input text, and use Markov chain to select words
End of explanation
"""


for ii in range(2):
    print(my_model.make_sentence_markov(10))

"""
Explanation: Make a sentence using a vanilla Markov chain
End of explanation
"""


