How to add "text_input" blocks for ner.manual

I want to create a custom recipe for pasting text into the annotation interface with my custom entities.

you talk about it on this page but I can not do it.

I guess it takes add a "text_input" in a recipe.py file and call it like this:

python -m prodigy ner.manual mydataset blank:fr -F recipe.py --label INDICE,INGRED

This recipe.py is incomplete

import prodigy
@prodigy.recipe("text-input")

def ner_text_input(dataset)
    blocks = [
    {"view_id": "ner_manual"},
    {"view_id": "text_input", "field_rows": 3}
    ]
    return {
        'config': {
            "labels": ["PRODUCT"],
            "blocks": [
                {"view_id": "ner_manual"},
                {"view_id": "text_input", "field_rows":3},
                {"view_id": "html"},
            ]
            },
        },
    }

Could you enlighten me

Hi! If you want to use a custom recipe, it should have all settings required by a custom recipe: the interface to use, the stream of examples, the dataset to save annotations to and any of the preprocessing you need. See the docs on custom recipes here: https://prodi.gy/docs/custom-recipes

If you want to write a custom version of the ner.manual recipe, here's an example to get you started:

We manage to paste a text into the interface and store it in the database.

But we are unable to display the annotation interface

import prodigy
import json

@prodigy.recipe("ner-manual")
def cat_facts_ner(dataset, lang="fr"):
    blocks = [
        #{"view_id":"html"},
        {"view_id": "ner_manual"},
        {"view_id": "text_input", "field_rows": 3, "field_label": "Ecrivez ce que vous voulez"}
    ]

    def get_stream():
        with open('./test3.jsonl') as text_file:
            text_str = text_file.read()
            text_json = json.loads(text_str)
        yield {"text": text_json['text']}

    stream = get_stream()

    with open('./input_text.html') as template_file:
        html_template = template_file.read()

    with open('./button_fct.js') as script_file:
        html_script = script_file.read()

    return {
        "view_id":"html",         #"view_id": "ner_manual", ?         #"view_id": "blocks", ?
        "dataset": dataset,
        "stream": stream,
        "config": {            
            "labels": ["ASSUREUR","DATE"],
            "html_template": html_template,
            "javascript": html_script          
        }
    }

Is it possible to call ner_manual with the text from the stream to annotate manually and then to display the html input (input text + button) in the same page?

Our objective is to change the text to annotate by writting a new one in the input text and clicking the 'change text' button in order to be able to annotate this new text ("test 14 35")

<strong>
    <p id="displaytext">
        {{text}}
    </p>
    <input type="text" id="name" name="name" required minlength="4" maxlength="40" size="40">
    <br />
    <button class="custom-button" onClick="addText()">
        Change text
    </button>
</strong>

The jsonl

{"text":" "}

The js file

function addText(){
    window.prodigy.content.text = document.getElementById('name').value
    document.getElementById("displaytext").textContent = window.prodigy.content.text
} 

Finally the command terminal

python -m prodigy ner-manual dataset_42 -F recipe.py

Yes, you can do that with two blocks: a ner_manual block and a html block, and then use the interface "blocks" with a list of "blocks" defined in the config returned by the recipe. Just like in this example, but with different blocks: https://prodi.gy/docs/custom-interfaces#blocks

In your script, you're setting "view_id": "html", so only the HTML template is shown.