Hi,
I have set up a curation recipe for our Prodigy project but I still need to workout how to send the rejected annotations for re-annotation BY THE SAME PERSON.
The current project set up is:
- 6 annotators
- 2 curators
- 1 data set
- session_id_ is an annotator id
I thought perhaps instead of all annotators working off the 1 master data set, they each have their own data set that contains the rejected annotations for them to re-do and only if there are none left, Prodigy fires off the next text from the master data set.
My current curation recipe is as follows (thanks for this @ines ):
@prodigy.recipe('review_annotations',
dataset=("Dataset name"),
n_examples=("Number of examples to randomly review, -1 for all", "option", "n", int),
manual=("Allow manual corrections", "option", "m", bool)
)
def review_annotations(dataset, n_examples=-1, manual=False):
examples=[]
db = connect()
for dataset_id in db.sessions: #only interested in certain user sessions
find_user_annot=re.search('(-[a-zA-Z]+)$|(-[a-zA-Z]+\d+)$',dataset_id)
if find_user_annot:
annotations = db.get_dataset(dataset_id)
for text in annotations:
examples.append(text)
if n_examples > 0:
random.shuffle(examples)
examples = examples[:n_examples]
# collect scores here
scores = {'right': 0, 'wrong': 0}
def update(examples):
# get all accepted / rejected examples and update scores
rejected = [eg for eg in examples if eg['answer'] == 'reject']
accepted = [eg for eg in examples if eg['answer'] == 'accept']
scores['wrong'] = scores['wrong'] + len(rejected)
scores['right'] = scores['right'] + len(accepted)
def on_exit(ctrl):
# called when you exit the server, compile results
total_right = scores['right']
total_wrong = scores['wrong']
total = len(examples)
print('Reviewed dataset', dataset)
print('Correct:', total_right)
print('Wrong:', total_wrong)
return {
'dataset': 'curated',
'stream': examples,
'view_id': 'ner_manual' if manual else 'ner',
'update': update,
'on_exit': on_exit
}
Has anyone got this set up or similar and would be willing to share the coding or discuss, please?
Anna