예제 #1
0
def add_relation_button():
    data = request.json
    db = Database()
    relation_button = RelationButton()

    rels = relation_button.get_relation_buttons(db)
    if rels:
        if data['className'] not in rels:
            relation_button.add_button(db, data['className'])
            return {'buttons': relation_button.get_html_format(db)}
    else:
        relation_button.add_button(db, data['className'])
        return {'buttons': relation_button.get_html_format(db)}
예제 #2
0
def index():
    fproc = FileProcessor()
    db = Database()

    button = None
    mode = "Class"

    # MIGHT NOT NEED

    sessionid = str(uuid.uuid1())
    if request.get_cookie(COOKIE_NAME) is None:
        response.set_cookie(COOKIE_NAME, sessionid)

    if fproc.is_relation(db):
        button = RelationButton()
        mode = "Relation"
    else:
        button = ClassButton()

    class_button = ClassButton()
    info = {
        'filename': fproc.get_filename(db),
        'content': fproc.token_to_span_colour(db, class_button),
        'result': fproc.output_annotated_str(db),
        'buttons': button.get_html_format(db),
        'mode': mode
    }

    return template('views/index', info)
예제 #3
0
def switch_to_relation():
    db = Database()
    relation_button = RelationButton()
    fproc = FileProcessor()

    buttons = relation_button.get_html_format(db)
    fproc.set_relation_mode(db, "true")
    return {'buttons': buttons}
예제 #4
0
def delete_button():
    db = Database()
    fproc = FileProcessor()
    class_button = ClassButton()
    data = request.json
    class_name = data['name']

    if fproc.is_relation(db):
        relation_button = RelationButton()
        relation_button.delete_button(db, class_name)
        return {
            'content': fproc.token_to_span_colour(db, class_button),
            'buttons': relation_button.get_html_format(db)
        }
    else:
        class_button.delete_button(db, class_name)
        fproc.delete_annotation(db, class_name)
        return {
            'content': fproc.token_to_span_colour(db, class_button),
            'buttons': class_button.get_html_format(db)
        }