Markov: drop the max id stuff, get a bunch of chains and pick one randomly. cooler this way.
This commit is contained in:
parent
e3ef3f48dc
commit
8c1ffc54ba
@ -521,10 +521,8 @@ class Markov(Module):
|
||||
values = []
|
||||
try:
|
||||
db = self.get_db()
|
||||
max_id = self._get_max_chain_id()
|
||||
rand_id = random.randint(1,max_id)
|
||||
query = 'SELECT k2 FROM markov_chain WHERE v = ? AND (context = ? OR context IS NULL) AND id >= {0:d} UNION SELECT k2 FROM markov_chain WHERE v = ? AND (context = ? OR context IS NULL) AND id < {1:d} LIMIT 1'.format(rand_id, rand_id)
|
||||
cursor = db.execute(query, (v,context,v,context))
|
||||
query = 'SELECT k2 FROM markov_chain WHERE v = ? AND (context = ? OR context IS NULL)'
|
||||
cursor = db.execute(query, (v,context))
|
||||
results = cursor.fetchall()
|
||||
|
||||
for result in results:
|
||||
|
Loading…
Reference in New Issue
Block a user