Hi, As you can see in the picture, although I tried to get "ID" from my CSV file, it doesnot show up here. Can you let me know what's happening here? Below is my code for recipe:
# -*- coding: utf-8 -*-
import csv
import prodigy
@prodigy.recipe('feedback_recipe',
dataset=prodigy.recipe_args['dataset'],
file_path=("C:/Users/.......feedback_prodigy_test.csv", "positional", None, str))
def feedback_recipe(dataset, file_path):
"""Annotate the feedbacks using different labels."""
def custom_csv_loader(file_path):
with open(file_path, encoding="utf-8") as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
text = row.get('Feedback_Explanation')
id = row.get('ResponseId')
yield {'text': text, 'meta': {'id':id}} # load in the CSV file
stream = custom_csv_loader("C:/Users/......feedback_prodigy_test.csv")
stream = add_options(stream) # add options to each task
return {
'dataset': dataset, # save annotations in this dataset
'view_id': 'choice', # use the choice interface
'config': {'choice_style': 'multiple'},
'stream':stream,
}
def on_exit(controller):
# Get all annotations in the dataset, filter out the accepted tasks,
# count them by the selected options and print the counts.
examples = controller.db.get_dataset(controller.dataset)
examples = [eg for eg in examples if eg["answer"] == "accept"]
for option in ("IVR Issues", "Customer Complaints", "Questions", "Button Issue", "UI & UX Issue", "Usage Display", "View Bill Issue", "Pay Bill Issue", "High Bill", "Payment Arrangement", "Autopay",
"Budget Billing", "Equal Payment Plan", "Suggestions", "Others"):
count = len([eg for eg in examples if option in eg["accept"]])
print(f"Annotated {count} {option} examples")
def add_options(stream):
# Helper function to add options to every task in a stream
options = [
{"id": "IVR Issues", "text": "IVR Issues"},
{"id": "Online Order Issue", "text": "Online Order Issue"},
{"id": "Service Information", "text": "Service Information"},
{"id": "Account Changes", "text": "Account Changes"},
{"id": "Paperless Billing", "text": "Paperless Billing"},
{"id": "Others", "text": "Others"},
]
for task in stream:
task["options"] = options
yield task