Skip to content

Interfaces

Robert Greinacher edited this page Sep 23, 2016 · 15 revisions

Dalphi uses annotation document / problem specific annotation interfaces to display annotation documents in the most efficient way. That said, you have to develop your own annotation interfaces for your use case using HTML, CoffeeScript and SCSS. To give you a good point to start here is a simple example of a text nominal interface. It can be used to answer a question like "Is something the case?" -> "yes" / "no".

A more advanced interface for NER applications can be found in this repo.

Example of a text_nominal interface

HTML:

<div class="description-container">
    <h1>Paragraph Classification</h1>
    <p>
        Choose whether the text below contains a real person name or not.
    </p>
    {{#options}}
        <button class="btn btn-secondary annotation-button" onclick="window.text_nominal.annotateWith('{{.}}')">
            {{.}}
        </button>
    {{/options}}
    <button class="btn btn-secondary annotation-button" onclick="window.text_nominal.skip()">
        Skip this document
    </button>
</div>
<div class="row paragraph-container">
    <div class="col-xs-12 col-sm-8 offset-sm-2">
        <p>
            {{{content}}}
        </p>
    </div>
</div>

SCSS

.description-container {
    margin: 0 auto;
    text-align: center;
    width: 60%;
}

.paragraph-container {
    margin-top: 2.3rem;

    strong {
        color: #A70000;
        font-size: 1.2rem;
    }
}

CoffeeScript

class text_nominal extends AnnotationIteration
    # uncomment to overwrite interface registration at AnnotationLifecylce
    constructor: ->
        $(document).keypress (e) ->
            $buttons = $('.annotation-interface:not(.template) .annotation-button')
            if e.which == 106
                console.log 'pressed J; emulate left button click'
                $buttons[0].click()
            else if e.which == 107
                console.log 'pressed K; emulate right button click'
                $buttons[1].click()
        super

    annotateWith: (label) ->
        @currentData.label = label
        this.saveChanges(@currentData)

window.text_nominal = new text_nominal()
Clone this wiki locally