Sorry, I was getting a big confused by all of that nested logic and the the pattern matcher that yields examples etc. And yes, if you want to create static annotation examples (one for each span) and render them exactly as they come in to accept/reject (e.g. with the mark
recipe), you’d really only need something like this?
examples = []
for text in LOTS_OF_TEXTS:
for label, regex_patterns.items():
for match in re.finditer(expression, text):
start, end = match.span()
span = {"start": start, "end": end, "label": label}
task = {"text": text, "spans": [span]}
examples.append(task)