def dev(): import core.markovchain as mc mcW = mc.MarkovChain() sm = sentence.SentenceMaker(mcW) ss = sentences_from_thesaurus(["cat", "anger", "sorry", "cat"], mcW) for s in ss: sent = sm.polish_sentence(s) print(" " + sm.to_string(sent))
def dev(): import knowledge.names as names mcW = mc.MarkovChain() nm = names.NameMaker() speakers = [nm.random_person() for i in range(1, 4)] dm = dialogue_maker([n['name'] for n in speakers], [n['pronoun'] for n in speakers], mcW) dlg = dm.make_dialogue(["dog", "run", "spot"]) print(dlg)
def dev(): mcW = mc.MarkovChain() w2vec = w2v.WordVectors() seeds = w2vec.path("swim", 20) print(seeds) generator = sentence.SentenceMaker(mcW) for sd in seeds: sen = generator.generate_sentence_tokens([sd]) sen = generator.polish_sentence(sen) print(" " + sentence.SentenceMaker.to_string(sen)) print('') nm = names.NameMaker() speakers = [nm.random_person() for i in range(1, 4)] dm = dialogue.dialogue_maker([n['name'] for n in speakers], [n['pronoun'] for n in speakers], mcW, seeds) dlg = dm.make_dialogue() for s in dlg: print(" " + sentence.SentenceMaker.to_string(s)) story_grammar.make_story(generator)
def dev(): print("hello!") fileids = range(112, 200) # [102, 103, 105, 107,108, 109, 110, 111] global mcW_store mcW_store = mc.MarkovChain() global ti ti = text_importer.TextImporter() # print(store.random_entry()) # print("Serial test...") # start_time = time.perf_counter() # s3_to_mc(fileids[0]) # elapsed_time = time.perf_counter() - start_time # s_elapsed_time=elapsed_time # print(s_elapsed_time) # print("...serial done!") start_time = time.perf_counter() mass_import(fileids) elapsed_time = time.perf_counter() - start_time p_elapsed_time = elapsed_time print(p_elapsed_time) print("...parallel done! {} files".format(len(fileids)))
import argparse import core.sentence as sentence import core.markovchain as mc import core.paragraphs as paras import nlp.story_grammar as story_grammar import knowledge.names as names import core.dialogue as dialogue mcW = mc.MarkovChain() generator = sentence.SentenceMaker(mcW) def make_seeds(seeds, max=5): if seeds is None: seeds = generator.generate_sentence_tokens(["the"]) # Make a random sentence of seeds seeds = seeds[0:max] return seeds def make_sentences(n, seeds=None): seeds = make_seeds(seeds) # if seeds is None: # seeds = generator.generate_sentence_tokens(["the"]) # Make a random sentence of seeds if isinstance(seeds, str): seeds = seeds.split() p = paras.seq_to_para(seeds[0:n], mcW) for sent in p: print(generator.to_string(generator.polish_sentence(sent))) def make_story():