morpheme.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:Sentences-analysis 作者: sungminoh 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号