diff --git a/modules/__pycache__/nlp.cpython-36.pyc b/modules/__pycache__/nlp.cpython-36.pyc index 9f5aa96..b187dfb 100644 Binary files a/modules/__pycache__/nlp.cpython-36.pyc and b/modules/__pycache__/nlp.cpython-36.pyc differ diff --git a/modules/nlp.py b/modules/nlp.py index a749603..22c8f25 100644 --- a/modules/nlp.py +++ b/modules/nlp.py @@ -31,13 +31,14 @@ async def genOut(self, noun): prew = self.db['prew'] beg = [ i['word'] for i in self.db['beg'].find() ] end = [ i['word'] for i in self.db['end'].find() ] + nouns = [i['word'] for i in self.db['noun'].find()] iter=0 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 iter += 1 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']) iter += 1 return out @@ -55,5 +56,7 @@ async def filter(self, c, n, m): async def init(self): self.db = dataset.connect('sqlite:///database.db') + + self.enmul = 1 self.raw['nlp'] = filter