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 = []
|
values = []
|
||||||
try:
|
try:
|
||||||
db = self.get_db()
|
db = self.get_db()
|
||||||
max_id = self._get_max_chain_id()
|
query = 'SELECT k2 FROM markov_chain WHERE v = ? AND (context = ? OR context IS NULL)'
|
||||||
rand_id = random.randint(1,max_id)
|
cursor = db.execute(query, (v,context))
|
||||||
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))
|
|
||||||
results = cursor.fetchall()
|
results = cursor.fetchall()
|
||||||
|
|
||||||
for result in results:
|
for result in results:
|
||||||
|
Loading…
Reference in New Issue
Block a user