How to join Recipe ner.manual and choice

Hi,

I would like to know how to label a text as it is in ner.manual recipe but then also use choice recipe to tell if the text is difficult to label or not, so we can store data of a specific row for a future NER model and Text cat model as well.

We want to save us time to do it separately because is the same text that we would tag.
Let me know if it is option to join recipes.

Thanks in advance,

Gilberto

Hi,

I would like to know how to create an additional text box to add unusual comments about labeling on specific text using Prodigy.
We would like to label a text and if it is a special case we would like to add comment to the row and save it for later processing. We already tried html view and config with html but I did not work so well.

Any advices for this task or templates that we can follow.

Thanks in Advance,

Gilberto

Hi! I've merged your two topics, because the underlying questions are quite similar and it's easier to answer them together :slightly_smiling_face:

A similar question actually came up in this thread and here's my response:

I'd love to have that use case (combining different UIs and elements) supported better out-of-the-box. I actually wrote up a proposal for how this could work a while ago – I haven't had time to implement this yet, but it's still very much on my radar: javascript in views other then html - add position information to span elements - #4 by ines

In the meantime, you can use custom JavaScript to manipulate a given interface, add elements to it and make them interactive. Here's a super simple example that adds a text field and a submit button. When the submit button is clicked, the current task is updated and the text in the input is added as the "comment" field:

document.addEventListener('prodigymount', event => {
    const container = document.querySelector('.prodigy-content')
    // Create input and button and add them to annotation card
    const input = document.createElement('input')
    input.style = "border: 1px solid"
    const button = document.createElement('button')
    button.textContent = 'Submit'
    container.appendChild(input)
    container.appendChild(button)

    button.addEventListener('click', event => {
        // Update current task if button is clicked
        console.log(input.value)
        window.prodigy.update({ comment: input.value })
    })
})

Hi Ines,

When I use html view I can see the text box and the submit button, but when I use the ner_manual I can not see anymore the object. How can I do to add a custom element keeping the current element on the screen?

Code:

javascript = '''document.addEventListener('prodigymount', event => {
const container = document.querySelector('.prodigy-content-custom')
// Create input and button and add them to annotation card
const input = document.createElement('input')
input.style = "border: 1px solid"
const button = document.createElement('button')
button.textContent = 'Submit'
container.appendChild(input)
container.appendChild(button)

button.addEventListener('click', event => {
    // Update current task if button is clicked
    console.log(input.value)
    window.prodigy.update({ comment: input.value })
})
})'''

template_text = '''
<div class="prodigy-content-custom"></div>    
'''

return {
    'view_id': 'ner_manual',
    'dataset': dataset,
    'stream': stream,
    'exclude': exclude,
    'config': {'lang': nlp.lang, 'labels': labels, 'html_template': template_text, 'javascript':  javascript}
}

Best,

Gilberto

The HTML template is only used if you’re actually using the html interface (otherwise, it’s be kinda unclear where that content would go). If you’re using a different interface, you’ll have to place your elements in JavaScript. So instead of appending to your custom container .prodigy-content-custom, you could append to the existing .prodigy-content.