def sentences():
if request.method == 'GET':
topic = ast.literal_eval(request.args.get('topic'))
sources_ids = ast.literal_eval(request.args.get('sources'))
format_string = formatstring(sources_ids)
post_id = ast.literal_eval(request.args.get('post_id'))
app.logger.info('GET sentneces: topic(%s), sources_ids(%s), post_id(%s)'
% ('%s', format_string, '%s')
% tuple([topic]+sources_ids+[post_id]))
cur = g.db.cursor()
cur.execute(queries['get_sentences'], (post_id, ))
sentences = []
for row in cur.fetchall():
sentence_id = int(row[0])
full_text = row[1]
cur.execute(queries['get_result_by_sentence'], (post_id, sentence_id))
rules = [row[0] for row in cur.fetchall()]
sentences.append(dict(sentence_id=sentence_id, full_text=full_text, rules=rules))
return jsonify(sentences=sentences)
评论列表
文章目录