From 086701a1dc827c29e5427f678c2d8b7abae20762 Mon Sep 17 00:00:00 2001 From: meganung Date: Wed, 4 Aug 2021 22:25:00 -0700 Subject: [PATCH 1/4] annotation buckets customization from task data --- .../webapp/src/components/task_components.jsx | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/parlai/crowdsourcing/tasks/turn_annotations_static/webapp/src/components/task_components.jsx b/parlai/crowdsourcing/tasks/turn_annotations_static/webapp/src/components/task_components.jsx index da1c2832547..61a233f810d 100644 --- a/parlai/crowdsourcing/tasks/turn_annotations_static/webapp/src/components/task_components.jsx +++ b/parlai/crowdsourcing/tasks/turn_annotations_static/webapp/src/components/task_components.jsx @@ -85,6 +85,24 @@ var handleUserInputUpdate = function (subtaskData) { } } +var getAnnotationBuckets = function (taskData, annotationBuckets) { + // return list of all the bucket ids + var buckets = [] + if (annotationBuckets !== null && 'config' in annotationBuckets){ + buckets = Object.keys(annotationBuckets.config); + } + taskData.forEach(elem => { + if ('annotation_buckets' in elem) { + (Object.keys(elem.annotation_buckets.config)).forEach(bucketKey => { + if (!buckets.includes(bucketKey)) { + buckets.push(bucketKey) + } + }) + } + }) + return buckets +} + var handleSubtaskSubmit = function (subtaskIndex, setIndex, numSubtasks, initialTaskData, annotationBuckets, mephistoSubmit) { // initialTaskData is the initial task data for this index console.log('In handleSubtaskSubmit for subtask: ' + subtaskIndex); @@ -103,8 +121,8 @@ var handleSubtaskSubmit = function (subtaskIndex, setIndex, numSubtasks, initial 'agent_idx': initialTaskData[i].agent_idx, 'other_metadata': initialTaskData[i].other_metadata }; - if (annotationBuckets !== null) { - var buckets = Object.keys(annotationBuckets.config); + var buckets = getAnnotationBuckets(initialTaskData, annotationBuckets) + if (buckets !== null && buckets.length > 0) { for (var j = 0; j < buckets.length; j++) { answersForTurn[buckets[j]] = null; var checkbox = document.getElementById(buckets[j] + '_' + i); @@ -267,7 +285,7 @@ function ContentPane({ subtaskData, taskConfig, subtaskIndex, numSubtasks }) { agentIdx={m.agent_idx} turnIdx={idx} annotationQuestion={annotationQuestion} - annotationBuckets={annotationBuckets} + annotationBuckets={ ('annotation_buckets' in m) ? m.annotation_buckets : annotationBuckets} doAnnotateMessage={m.do_annotate} askReason={askReason} responseField={responseField} From 88f3b200f85cbe8162cee9a4e4b7b30fb6175cd2 Mon Sep 17 00:00:00 2001 From: meganung Date: Wed, 4 Aug 2021 22:38:11 -0700 Subject: [PATCH 2/4] customize annotation question per utterance --- .../webapp/src/components/task_components.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parlai/crowdsourcing/tasks/turn_annotations_static/webapp/src/components/task_components.jsx b/parlai/crowdsourcing/tasks/turn_annotations_static/webapp/src/components/task_components.jsx index 61a233f810d..f690bc9327f 100644 --- a/parlai/crowdsourcing/tasks/turn_annotations_static/webapp/src/components/task_components.jsx +++ b/parlai/crowdsourcing/tasks/turn_annotations_static/webapp/src/components/task_components.jsx @@ -284,7 +284,7 @@ function ContentPane({ subtaskData, taskConfig, subtaskIndex, numSubtasks }) { text={m.text} agentIdx={m.agent_idx} turnIdx={idx} - annotationQuestion={annotationQuestion} + annotationQuestion={ ('annotation_question' in m) ? m.annotation_question : annotationQuestion} annotationBuckets={ ('annotation_buckets' in m) ? m.annotation_buckets : annotationBuckets} doAnnotateMessage={m.do_annotate} askReason={askReason} From fba9e9fc104b14b8a8f58b402b837207cdd78121 Mon Sep 17 00:00:00 2001 From: meganung Date: Wed, 4 Aug 2021 22:40:53 -0700 Subject: [PATCH 3/4] customize speaker label --- .../webapp/src/components/task_components.jsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/parlai/crowdsourcing/tasks/turn_annotations_static/webapp/src/components/task_components.jsx b/parlai/crowdsourcing/tasks/turn_annotations_static/webapp/src/components/task_components.jsx index f690bc9327f..37a5a50c935 100644 --- a/parlai/crowdsourcing/tasks/turn_annotations_static/webapp/src/components/task_components.jsx +++ b/parlai/crowdsourcing/tasks/turn_annotations_static/webapp/src/components/task_components.jsx @@ -216,9 +216,18 @@ function SubtaskSubmitButton({ subtaskIndex, numSubtasks, onSubtaskSubmit }) { ) } -function ChatMessage({ text, agentIdx, annotationQuestion, annotationBuckets, turnIdx, doAnnotateMessage, askReason, responseField, onUserInputUpdate }) { +function ChatMessage({ text, agentIdx, annotationQuestion, annotationBuckets, turnIdx, doAnnotateMessage, askReason, responseField, speakerLabel, onUserInputUpdate }) { var extraElements = ''; var responseInputElement = ''; + if (speakerLabel == null) { + speakerLabel = agentIdx % 2 == 0 ? 'YOU' : 'THEM' + } + var speakerElements = ( +
+ {speakerLabel}: {text} +
+ ) + if (doAnnotateMessage) { if (annotationBuckets !== null) { extraElements = (

@@ -251,7 +260,8 @@ function ChatMessage({ text, agentIdx, annotationQuestion, annotationBuckets, tu return (
- {turnIdx % 2 == 0 ? 'YOU' : 'THEM'}: {text} + + {speakerElements} {extraElements} @@ -289,6 +299,7 @@ function ContentPane({ subtaskData, taskConfig, subtaskIndex, numSubtasks }) { doAnnotateMessage={m.do_annotate} askReason={askReason} responseField={responseField} + speakerLabel={('speaker_label' in m) ? m.speaker_label : null} onUserInputUpdate={() => handleUserInputUpdate(subtaskData)} />
From 03941ee980139de01a252a2b9e50684bd6cc5435 Mon Sep 17 00:00:00 2001 From: meganung Date: Sun, 15 Aug 2021 23:35:56 -0700 Subject: [PATCH 4/4] use turnIdx for determining speaker label --- .../webapp/src/components/task_components.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parlai/crowdsourcing/tasks/turn_annotations_static/webapp/src/components/task_components.jsx b/parlai/crowdsourcing/tasks/turn_annotations_static/webapp/src/components/task_components.jsx index 37a5a50c935..378501b7f09 100644 --- a/parlai/crowdsourcing/tasks/turn_annotations_static/webapp/src/components/task_components.jsx +++ b/parlai/crowdsourcing/tasks/turn_annotations_static/webapp/src/components/task_components.jsx @@ -220,7 +220,7 @@ function ChatMessage({ text, agentIdx, annotationQuestion, annotationBuckets, tu var extraElements = ''; var responseInputElement = ''; if (speakerLabel == null) { - speakerLabel = agentIdx % 2 == 0 ? 'YOU' : 'THEM' + speakerLabel = turnIdx % 2 == 0 ? 'YOU' : 'THEM' } var speakerElements = (