示例#1
0
        def gen():
            ply = randint(1, 4)
            length = randint(5, 20)

            markov_dict = markov.train([licenses], ply)  # 2 is the ply
            text = markov.generate(markov_dict, length,
                                   ply)  # 2 is the ply, 10 is the length
            return text
示例#2
0
def markovtitle(text):
    markov_dict = markov.train([text], 2)
    return markov.generate(markov_dict, randrange(4,10), 2)
示例#3
0
def markovtitle(text):
    markov_dict = markov.train([text], 2)
    return markov.generate(markov_dict, randrange(4, 10), 2)
示例#4
0
from pymarkov import markov
import sys


with open(sys.argv[1]) as file_in:
    aye = file_in.read()
    m_dict = markov.train([aye], 2)
no_of_ideas =  int(sys.argv[2]) + 1
ideas = [markov.generate(m_dict, 4, 2) for i in range(1, no_of_ideas)]

for i in ideas:
    print(i)
示例#5
0
import nltk as n
from itertools import islice
from pymarkov import markov

corpus = open('queensdelight.txt', 'r')
names = open('curious.txt', 'r')
output = open('output.txt', 'w')

corpus_raw = [line.rstrip('\n') for line in islice(corpus,68,2339)]

dict = markov.train(corpus_raw,2)

for i in range(0, 99):
    #print(markov.generate(dict, 60, 2))
    output.write(markov.generate(dict, 70, 2) + "\n")