Don't query Nothing.

This commit is contained in:
Matúš Tejiščák 2024-02-13 16:24:38 +01:00
parent 0e60a754f6
commit 0e189ecbac
1 changed files with 13 additions and 12 deletions

View File

@ -33,7 +33,7 @@ while Q:
((x, x_rank), (y, y_rank)), = random.sample(
population=list(Q),
k=1,
counts=[max(xr, yr) for (_, xr), (_, yr) in Q],
counts=[max(len(x), len(y))*max(xr, yr) for (x, xr), (y, yr) in Q],
)
Q.remove(((x, x_rank), (y, y_rank)))
@ -67,16 +67,17 @@ while Q:
)
db.commit()
r = db.execute('''
select q.word, q.rank, z.rank
from words q, words z
where not exists (
select *
from combos c
where c.x = q.word and c.y = ?
) and z.word = ?
''', (z, z))
for q, q_rank, z_rank in r.fetchall():
Q.add(((z, z_rank), (q, q_rank)))
if z != 'Nothing':
r = db.execute('''
select q.word, q.rank, z.rank
from words q, words z
where not exists (
select *
from combos c
where c.x = q.word and c.y = ?
) and z.word = ? and q.word != 'Nothing'
''', (z, z))
for q, q_rank, z_rank in r.fetchall():
Q.add(((z, z_rank), (q, q_rank)))
time.sleep(5)