I have encountered a similar error. I am on v1.13.3
:
TypeError: Cannot use 'in' operator to search for 'reject' in undefined
The dataset does not have any missing or null entries, and it is not pre-labeled. The annotators are experiencing this error periodically (every 100 or so) throughout the set, even though I have confirmed that annotations are being saved.
The dataset looks like this:
{"orig_utterance": "This is a Sentence", "utterance": "this is a sentence"}
This is the custom recipe I am using:
import json
from typing import Dict, Generator
import prodigy
from prodigy.components.loaders import JSONL
from annotator.recipes.utils import COVERAGE_GAPS
UNLIMITED_ROWS = [
{"view_id": "html", "html_template":
"<div style=\"padding: 0 10px; border: 1px solid #ddd; border-radius: 4px; text-align: center;\">" +
"<div style=\"max-height: 300px; font-size: 30px; overflow-y: scroll; margin-bottom: 10px;\">{{utterance}}" +
"</div>"
},
{"view_id": "choice"},
{"view_id": "html", "html_template": "<div style='float:left;'>" +
"<input name='fragment' id='fragment' type='checkbox' value='Fragment' style='margin-right:10px;' data-id='{{chat_id}}' onchange='updateFragment()'" +
"<label onclick='update()'>Fragment</label>"
},
{"view_id": "html", "html_template": "<div style='float:left;'>" +
"<input name='stt' id='stt' type='checkbox' value='STT' style='margin-right:10px;' data-id='{{chat_id}}' onchange='updateSTT()'" +
"<label onclick='update()'>STT</label>"
},
{"view_id": "html", "html_template": "<div style='float:left;'>" +
"<input name='gibberish' id='gibberish' type='checkbox' value='Gibberish' style='margin-right:10px;' data-id='{{chat_id}}' onchange='updateGibberish()'" +
"<label onclick='update()'>Gibberish</label>"
},
{"view_id": "html", "html_template": "<div style='float:left;'>" +
"<input name='other' id='other' type='checkbox' value='Other' style='margin-right:10px;' data-id='{{chat_id}}' onchange='updateOther()'" +
"<label onclick='update()'>Other</label>"
},
{"view_id": "text_input", "field_label": "Notes"}
]
def add_options(
stream, label_field="label", choices=COVERAGE_GAPS
) -> Generator[Dict, None, None]:
"""
Convert each line in the ``stream`` to a ``task`` with a text and an
options field
:param stream: the input stream
:param label_field: key; defaults to "label"
:param choices: the different choices
:yield: a task Dict with text and options
"""
for line in stream:
if label_field in line:
options = json.loads(line[label_field])
else:
options = []
for word in (options + choices):
if word not in options:
options.append(word)
task = {
"utterance": line["utterance"],
"fragment": False,
"stt": False,
"gibberish": False,
"other": False,
"options": [
{"id": o, "deployment": o, "prompt": o,
"text": o} for o in options
]
}
yield task
@prodigy.recipe(
"coverage-gaps",
dataset=("The dataset to save to", "positional", None, str),
file_path=("Path to texts", "positional", None, str)
)
def custom_labels(dataset, file_path):
"""
Annotate the text with labels from the list from the ``label_field`` in
the input file. Augmented with choices from ``choice_field``.
"""
blocks = UNLIMITED_ROWS
stream = JSONL(file_path)
stream = add_options(stream) # add options to each task
javascript = """
// Set fragment to false by default
prodigy.update({ fragment: false });
function updateFragment() {
prodigy.update({ fragment: document.getElementById('fragment').checked });
}
document.addEventListener('prodigyanswer', (event) => {
// Reset fragment to false
prodigy.update({ fragment: false });
document.getElementById('fragment').checked = false;
});
// Set stt to false by default
prodigy.update({ stt: false });
function updateSTT() {
prodigy.update({ stt: document.getElementById('stt').checked });
}
document.addEventListener('prodigyanswer', (event) => {
// Reset stt to false
prodigy.update({ stt: false });
document.getElementById('stt').checked = false;
});
// Set gibberish to false by default
prodigy.update({ gibberish: false });
function updateGibberish() {
prodigy.update({ gibberish: document.getElementById('gibberish').checked });
}
document.addEventListener('prodigyanswer', (event) => {
// Reset gibberish to false
prodigy.update({ gibberish: false });
document.getElementById('gibberish').checked = false;
});
// Set other to false by default
prodigy.update({ other: false });
function updateOther() {
prodigy.update({ other: document.getElementById('other').checked });
}
document.addEventListener('prodigyanswer', (event) => {
// Reset other to false
prodigy.update({ other: false });
document.getElementById('other').checked = false;
});
"""
return {
"dataset": dataset,
"view_id": "blocks",
"stream": list(stream),
"config": {
"blocks": blocks,
"javascript": javascript
}
}