Hi!
What I would like to do is to show the score of predictions, together with the highlighted labels inside the ner_manual view (using ner.make-gold recipe).
So, I am trying to modify the ner.make-gold recipe code, and create my own recipe which does the following:
1 - calculates the score of each span should not be an issue, I was thinking to use the logic in this post: Accessing probabilities in NER
2 - Then, I would like to add the “score” field to each span dict inside the make_tasks function as following:
def make_tasks(nlp, stream):
"""Add a 'spans' key to each example, with predicted entities."""
texts = ((eg["text"], eg) for eg in stream)
for doc, eg in nlp.pipe(texts, as_tuples=True):
task = copy.deepcopy(eg)
spans = []
for ent in doc.ents:
if labels and ent.label_ not in labels:
continue
spans.append(
{
"token_start": ent.start,
"token_end": ent.end - 1,
"start": ent.start_char,
"end": ent.end_char,
"text": ent.text,
"label": ent.label_,
"source": spacy_model,
"input_hash": eg[INPUT_HASH_ATTR],
"score": MY_SCORE,
}
)
task["spans"] = spans
task = set_hashes(task)
yield task
Now, the most unclear step is: how do I modify the current ner_manual view to show the scores?
1 - do you have an already existing way to do this which I am missing?
2 - if not, could you suggest a way to change the ner_manual view? Unfortunately i cannot access the code of the template…
3 - If option 1 and option 2 are not feasible, what else can i do?
Actually by extending a little the scope of the question, it would be nice to have a way to personalize and slightly change the already existing Prodigy views. But at the moment I cannot find a way to achieve this.
Thanks,
Kasra