Thanks, @ines!
I am currently trying to apply this method - I created a custom manual recipe from your sentiment example online. The labels display correctly, I select multiple and click accept, but the annotations aren't being saved at all afterwards. It shows 0 annotations when I finish the session. Here is my recipe:
import prodigy
from prodigy.components.loaders import JSONL
@prodigy.recipe('neg.cat.manual',
dataset=prodigy.recipe_args['dataset'],
file_path=("Path to texts", "positional", None, str))
def neg_cat(dataset, file_path):
"""Annotate the sentiment of texts using different mood options."""
stream = JSONL(file_path) # load in the JSONL file
stream = add_options(stream) # add options to each task
return {
'dataset': dataset, # save annotations in this dataset
'view_id': 'choice', # use the choice interface
'stream': stream,
'config': {
'choice_style': 'multiple',
"choice_auto_accept": False,
'answer': 'accept',
"show_flag": True,
"theme": "eighties"
}
}
def add_options(stream):
"""Helper function to add options to every task in a stream."""
# Colors for label subcategories
tone = "#FDC564"
general = "#FDC564"
food = "#EDFABC"
service = "#CEFCF0"
facilities = "#E3C9FC"
options = [
# REVIEW TONE
{'id': 'tone', 'text': 'PROFANITY/ THREATENING TONE', "style": { "background": tone }},
# GENERAL
{'id': 'general', 'text': 'GENERAL DISSAPOINTMENT', "style": { "background": general }},
# FOOD
{'id': 'illness', 'text': 'FOOD POISONING/ ROTTEN FOOD', "style": { "background": food }},
{'id': 'quality', 'text': 'POOR QUALITY/ TASTE/ PREPARATION', "style": { "background": food }},
{'id': 'value', 'text': 'SMALL PORTION/ EXPENSIVE', "style": { "background": food }},
{'id': 'foreign', 'text': 'FOREIGN BODY', "style": { "background": food }},
{'id': 'unavailable', 'text': 'NO STOCK/ VARIETY / SPECIAL UNAVAILABLE', "style": { "background": food }},
# STAFF/ SERVICE
{'id': 'staff_abuse', 'text': 'ABUSIVE STAFF/ RACISM/ DISCRIMINATION', "style": { "background": service }},
{'id': 'incorrect', 'text': 'INCORRECT ORDERS/ CHARGES', "style": { "background": service }},
{'id': 'unprofessional', 'text': 'UNFRIENDLY/ UNPROFESSIONAL/ INATTENTIVE/ NEED TRAINING', "style": { "background": service }},
{'id': 'wait', 'text': 'LONG WAIT/ BUSY/ DISORGANIZED/ FOOD COLD', "style": { "background": service }},
{'id': 'online', 'text': 'PROBLEMS ONLINE DELIVERY/ APP', "style": { "background": service }},
{'id': 'loyalty', 'text': 'ISSUES WITH VOUCHERS/ LOYALY CARDS', "style": { "background": service }},
# ATMOSPHERE/ FACILITIES
{'id': 'injury', 'text': 'ADULT INJURY/ AGGRESSION/ SECURITY', "style": { "background": facilities }},
{'id': 'childcare', 'text': 'CHILD BULLIED/ INJURY/ CARE', "style": { "background": facilities }},
{'id': 'hygiene', 'text': 'HYGIENE', "style": { "background": facilities }},
{'id': 'discomfort', 'text': 'NOISE/ DISRUPTION/ DISCOMFORT', "style": { "background": facilities }},
{'id': 'concern', 'text': 'CONCERN PREMISES/ FACILITIES/ SAFETY', "style": { "background": facilities }}
]
for task in stream:
task['options'] = options
yield task
Do I need to add something so that the selected labels are saved?