コード例 #1
0
ファイル: annotation.py プロジェクト: ldmt-muri/morpholm
def sentence():
    username = request.authorization.username.lower()
    sentence_id = int(request.args.get('id'))
    sentence = config.sentences[sentence_id]
    analyzed_sentence = config.analyze_sentence(sentence)
    g.cursor.execute('select word_id, analysis from annotations '
            'where sentence_id = ? and username = ?', (sentence_id, username))
    annotations = dict(g.cursor.fetchall())
    annotations = [parse_analysis(annotations.get(word_id, None))
        for word_id in range(len(sentence.split()))]
    words = [(config.model.vocabulary[word], get_patterns(word), 
                annotation, is_other(annotation, word))
             for annotation, word in izip(annotations, analyzed_sentence)]
    return render_template('annotation.html', sentence_id=sentence_id,
            words=words, palette=config.morpheme_colors, 
            prev=(None if sentence_id == 0 else sentence_id-1),
            nxt=(None if sentence_id == len(config.sentences) else sentence_id+1))
コード例 #2
0
ファイル: app.py プロジェクト: ldmt-muri/morpholm
def sentence():
    s = request.args.get('q')
    words = [(config.model.vocabulary[word], word_score(word), 
        is_known_word(word), get_patterns(word))
             for word in config.analyze_sentence(s)]
    return render_template('sentence.html', words=words, palette=config.morpheme_colors)