Skip to content
Snippets Groups Projects
Commit d52df58b authored by Manon Blanco's avatar Manon Blanco Committed by Yoann Schneider
Browse files

Use a random transcription of an element when more than one found

parent 67f28861
No related branches found
No related tags found
1 merge request!180Use a random transcription of an element when more than one found
......@@ -49,15 +49,6 @@ class NoTranscriptionError(ElementProcessingError):
return f"No transcriptions found on element ({self.element_id}) with this config. Skipping."
class MultipleTranscriptionsError(ElementProcessingError):
"""
Raised when there are more than one transcription on an element
"""
def __str__(self) -> str:
return f"More than one transcription found on element ({self.element_id}) with this config."
class UnknownLabelError(ProcessingError):
"""
Raised when the specified label is not known
......
......@@ -18,7 +18,6 @@ from dan.datasets.extract.db import (
get_transcriptions,
)
from dan.datasets.extract.exceptions import (
MultipleTranscriptionsError,
NoTranscriptionError,
ProcessingError,
UnknownLabelError,
......@@ -129,12 +128,10 @@ class ArkindexExtractor:
transcriptions = get_transcriptions(
element.id, self.transcription_worker_version
)
if len(transcriptions) > 1:
raise MultipleTranscriptionsError(element.id)
elif len(transcriptions) == 0:
if len(transcriptions) == 0:
raise NoTranscriptionError(element.id)
transcription = transcriptions.pop()
transcription = random.choice(transcriptions)
if self.load_entities:
entities = get_transcription_entities(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment