Commit 4d8cc12b authored by Emil Tylen's avatar Emil Tylen Committed by Emil Tylen

New post delim, better sentence search, cleanup
* Now always starts its sentences with the beginning of a real post.
* Will backtrack if a sentence cannot be completed under the word limit.

* posts are now delimited with % to allow for multi line posts.
* removed all duplicate posts.
parent 9c966e6b
......@@ -22,7 +22,23 @@ def generate_database(sentences, degrees=2):
cache[words[:-1]] = [words[-1]]
return cache
punctuation = "!?."
def generate_triples(sentence, degrees):
words = len(sentence)
for i in range(words):
yield tuple(sentence[i : i + degrees + 1])
def generate_database(sentences, degrees=2):
cache = {}
for sentence in sentences:
for words in generate_triples(sentence.split(), degrees):
if words[:-1] in cache:
cache[words[:-1]] = [words[-1]]
return cache
class Fam:
def __init__(self, bot, _):
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment