fixed short output

This commit is contained in:
lickthecheese 2020-04-23 13:50:05 -04:00
parent 3b8044dbac
commit a16fade5af
2 changed files with 5 additions and 2 deletions

View file

@ -31,13 +31,14 @@ async def genOut(self, noun):
prew = self.db['prew'] prew = self.db['prew']
beg = [ i['word'] for i in self.db['beg'].find() ] beg = [ i['word'] for i in self.db['beg'].find() ]
end = [ i['word'] for i in self.db['end'].find() ] end = [ i['word'] for i in self.db['end'].find() ]
nouns = [i['word'] for i in self.db['noun'].find()]
iter=0 iter=0
out = [noun] out = [noun]
while out[0] not in beg and iter < 7: while (out[0] not in beg or nouns.count(out[0])-1 > iter * self.enmul) and iter < 7:
out = [ random.choice(list(prew.find(pro=out[0])))['pre'] ] + out out = [ random.choice(list(prew.find(pro=out[0])))['pre'] ] + out
iter += 1 iter += 1
iter = 0 iter = 0
while out[-1] not in end and iter < 7: while (out[-1] not in end or nouns.count(out[-1])-1 > iter * self.enmul) and iter < 7:
out.append(random.choice(list(prew.find(pre=out[-1])))['pro']) out.append(random.choice(list(prew.find(pre=out[-1])))['pro'])
iter += 1 iter += 1
return out return out
@ -55,5 +56,7 @@ async def filter(self, c, n, m):
async def init(self): async def init(self):
self.db = dataset.connect('sqlite:///database.db') self.db = dataset.connect('sqlite:///database.db')
self.enmul = 1
self.raw['nlp'] = filter self.raw['nlp'] = filter