Compare commits

...

3 commits

Author SHA1 Message Date
2a21330e8b update default enmul 2022-03-10 12:04:10 -07:00
4d20f602a7 tokenize punctuation before recording words 2022-03-10 12:03:39 -07:00
dccdda1f5f improve ending balences 2022-03-10 09:41:56 -07:00

View file

@ -19,7 +19,7 @@ async def rec(self, m):
beg = shared.db["beg"] beg = shared.db["beg"]
end = shared.db["end"] end = shared.db["end"]
words = m.split() words = re.sub(r"([\.,\?!])", r" \1", m).split()
if words[0] == "admin" or len(words) < 2: if words[0] == "admin" or len(words) < 2:
return return
@ -78,7 +78,7 @@ async def genOut(self, noun):
out = [noun] out = [noun]
while ( while (
beg.find_one(word=out[0]) is None beg.find_one(word=out[0]) is None
or beg.count(word=out[0]) - 1 > iter * shared.enmul or beg.count(word=out[0]) - 1 < shared.enmul / (1 + iter / shared.maxiter)
) and iter < shared.maxiter: ) and iter < shared.maxiter:
try: try:
out = [ out = [
@ -95,13 +95,13 @@ async def genOut(self, noun):
try: try:
out = [random.choice(list(prew.find(pro=out[0])))["pre"]] + out out = [random.choice(list(prew.find(pro=out[0])))["pre"]] + out
except IndexError: except IndexError:
iter += 69 iter += 69420
iter += 1 iter += 1
coun += 1 coun += 1
iter = 0 iter = 0
while ( while (
end.find_one(word=out[-1]) is None end.find_one(word=out[-1]) is None
or end.count(word=out[-1]) - 1 > iter * shared.enmul or end.count(word=out[-1]) - 1 < shared.enmul / (1 + iter / shared.maxiter)
) and iter < shared.maxiter: ) and iter < shared.maxiter:
try: try:
out.append( out.append(
@ -118,14 +118,14 @@ async def genOut(self, noun):
try: try:
out.append(random.choice(list(prew.find(pre=out[-1])))["pro"]) out.append(random.choice(list(prew.find(pre=out[-1])))["pro"])
except IndexError: except IndexError:
iter += 69 iter += 69420
iter += 1 iter += 1
coun += 1 coun += 1
if coun <= 4: if coun <= 4:
shared.enmul -= 0.1 shared.enmul += 1
elif coun >= shared.maxiter: elif coun >= shared.maxiter:
shared.enmul += 0.1 shared.enmul -= 1
return out return out
@ -171,10 +171,10 @@ async def init(self):
# delay between grabbing random messages and passively # delay between grabbing random messages and passively
# learning. # learning.
shared.learndelay = 1 shared.learndelay = 1
# sentance ending weight, lower means longer sentances, # sentance ending weight, higher means longer sentances,
# higher means shorter sentances. this will need to slowly # higher means shorter sentances. this will need to slowly
# get larger as the database grows # get larger as the database grows
shared.enmul = 2 shared.enmul = 200
shared.maxiter = 14 shared.maxiter = 14
shared.rawm["nlp"] = filter shared.rawm["nlp"] = filter