use multiple words in sentance generation when cheapie
This commit is contained in:
parent
b5afc6135a
commit
ae7b469676
1 changed files with 20 additions and 10 deletions
|
@ -2,24 +2,34 @@ from bot import *
|
||||||
|
|
||||||
import dataset, random, time, re
|
import dataset, random, time, re
|
||||||
|
|
||||||
|
def get(l,i):
|
||||||
|
try:
|
||||||
|
if i <= len(l) and i >= 0:
|
||||||
|
return l[i]
|
||||||
|
else:
|
||||||
|
return ''
|
||||||
|
except IndexError:
|
||||||
|
return ''
|
||||||
|
|
||||||
async def rec(self, m):
|
async def rec(self, m):
|
||||||
prew = shared.db['prew']
|
prew = shared.db['prew']
|
||||||
noch = shared.db['noun']
|
noch = shared.db['noun']
|
||||||
beg = shared.db['beg']
|
beg = shared.db['beg']
|
||||||
end = shared.db['end']
|
end = shared.db['end']
|
||||||
pre = ''
|
|
||||||
words = m.split(' ')
|
words = m.split(' ')
|
||||||
if words[0] == 'admin':
|
|
||||||
|
if words[0] == 'admin' or len(words) < 2:
|
||||||
return
|
return
|
||||||
for w in words:
|
|
||||||
if pre == '':
|
beg.insert(dict(word=words[0]))
|
||||||
beg.insert(dict(word=w))
|
end.insert(dict(word=words[-1]))
|
||||||
else:
|
|
||||||
prew.insert_ignore(dict(pre=pre, pro=w),['id'])
|
for w in range(len(words)):
|
||||||
pre = w
|
if w > 0:
|
||||||
|
prew.insert_ignore(dict(pre3=get(words,w-3), pre2=get(words,w-2), pre=get(words,w-1), pro=get(words,w), pro2=get(words,w+1), pro3=get(words,w+2)),['id'])
|
||||||
noch.insert(dict(word=w))
|
noch.insert(dict(word=w))
|
||||||
end.insert(dict(word=pre))
|
|
||||||
|
|
||||||
async def getNoun(self, words, c):
|
async def getNoun(self, words, c):
|
||||||
if c in shared.cstate:
|
if c in shared.cstate:
|
||||||
oldnoun = shared.cstate[c]
|
oldnoun = shared.cstate[c]
|
||||||
|
|
Loading…
Reference in a new issue