Choice interface with HTML

Hi, I’m running the choice interface and try to get the data rendered as HTML, if I contruct this minimal example:

@prodigy.recipe('choice')
def choice():
    stream = [{
        'label': 'SOME_LABEL',
        'text': 'hello {}'.format(i),
        'html': "<b>Bold {}</b>".format(i),
        'options': [{"id": 1, "text": "Apple"}, {"id": 2, "text": "Google"}, {"id": 3, "text": "McDonalds"}]
    } for i in range(10)]

    return {
        'view_id': 'choice',
        'dataset': False,
        'stream': stream
    }

it still renders the text field. Any hints how to render a HTML template together with choice?

Interesting! What happens when you remove the 'label' key from your stream?

I need to double-check to verify this, but here’s my suspicion: the logic to determine which interface to render checks for the label first and if found, uses the classification interface. The classification interface can render text, images and spans – but not HTML, so it falls back to the text. If there’s no label, Prodigy will check for 'html' next and should then use the HTML interface within the choice task.

Allowing the classification UI to render HTML might be a good idea, though – no idea why it currently doesn’t. I guess it just never came up until now.

Okay, cool. Yeah, it works without a label. I was trying to use a TextClassifier recipe to work with HTML and choice (to sub-categorize an existent classification). Probably I need to remove the label from the stream and add it on update again.

The remove/add label workaround seem to work :grinning:. Another thing I came across is that I can’t use key shortcuts [1]-[9], the frontend displays these messages in the developer console:

bundle.js:1 Uncaught TypeError: n.props.updateChoice is not a function
    at Object.n.handleShortcuts [as handler] (bundle.js:1)
    at r._handleShortcuts (bundle.js:1)
    at e.exports [as fireCallback] (bundle.js:1)
    at e.exports [as handleKey] (bundle.js:1)
    at e.exports.r._combokeys.handleKey (bundle.js:1)
    at e.exports (bundle.js:1)

Is this a bug or a configuration problem on my side?

Ah, damn – I just checked and looks like this is a bug. Thanks for the report. Already fixed it and the fix will be included in the next release (we’re planning on pushing a smaller point release today that fixes a bunch of small things).

1 Like

Fixed in v1.4.2! The classification interface now also allows HTML, so your code should work as expected.

(Btw, off-topic, but if you want to test the new experimental UI translation feature I’m working on, you can set "ui_lang": "de" in your prodigy.json :wink:)

1 Like

I’m still getting TypeError: n.props.updateChoice is not a function in v1.4.2 when I’m trying to use keyboard shortcuts in the choice interface. I get the same error using the online demo, though Named Entities (manual) works fine. Is the bug fix slated for v1.5.0?

@steve Yes, that’s fixed! Sorry about that. Just testing the wheels for v1.5.0 btw :tada: