Ejemplo n.º 1
0
def test():
    print("Creating new markov dict...")
    print(getDepth())
    corpus_path = "./corpora/test/depth.txt"
    corpus = Corpus(importStrFromFile(corpus_path))
    print(corpus)
    reverse_corpus = list(reversed(corpus))
    print(reverse_corpus)
    forward_markov_dict = MarkovDict(source=corpus, depth=getDepth())
    reverse_markov_dict = MarkovDict(source=reverse_corpus, depth=getDepth())
    pprint(forward_markov_dict.dict)
    pprint(reverse_markov_dict.dict)
    bot = MarkovBot(forward_markov_dict, reverse_markov_dict)
    # pprint(bot.forward_dict.dict)
    # pprint(bot.reverse_dict.dict)
    print(bot.response(topic="markov"))
Ejemplo n.º 2
0
def main():
    print("Creating new markov dict...")
    forward_markov_dict = MarkovDict(source=None, depth=getDepth())
    reverse_markov_dict = MarkovDict(source=None, depth=getDepth())
    print("Starting for loop to add corpora...")
    for corpus_path in corporaPaths():
        corpus = Corpus(importStrFromFile(corpus_path))
        print("Adding corpus with path '" + corpus_path + "'...")
        forward_markov_dict.add(corpus)
        reverse_markov_dict.add(list(reversed(corpus)))
    print("Initializing MarkovBot...")
    bot = MarkovBot(forward_markov_dict, reverse_markov_dict)
    print("\nWelcome to MarkovBot! Type a message. Type 'exit()' to quit.")
    message = prompt()
    while message != "exit()":
        print(bot.response(topic=message.split()[0]))
        message = prompt()