Don't query Nothing.
This commit is contained in:
parent
0e60a754f6
commit
0e189ecbac
25
words.py
25
words.py
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue