Skip to content
Snippets Groups Projects
Commit 6bbf9c60 authored by ml bonhomme's avatar ml bonhomme :bee: Committed by Erwan Rouchet
Browse files

Replace all transcription scores with confidences

parent 9bc3eb43
No related branches found
No related tags found
1 merge request!152Replace all transcription scores with confidences
Pipeline #79057 passed
......@@ -18,7 +18,11 @@ class TextOrientation(Enum):
class TranscriptionMixin(object):
def create_transcription(
self, element, text, score, orientation=TextOrientation.HorizontalLeftToRight
self,
element,
text,
confidence,
orientation=TextOrientation.HorizontalLeftToRight,
):
"""
Create a transcription on the given element through the API.
......@@ -33,8 +37,8 @@ class TranscriptionMixin(object):
orientation, TextOrientation
), "orientation shouldn't be null and should be of type TextOrientation"
assert (
isinstance(score, float) and 0 <= score <= 1
), "score shouldn't be null and should be a float in [0..1] range"
isinstance(confidence, float) and 0 <= confidence <= 1
), "confidence shouldn't be null and should be a float in [0..1] range"
if self.is_read_only:
logger.warning(
......@@ -48,7 +52,7 @@ class TranscriptionMixin(object):
body={
"text": text,
"worker_version": self.worker_version_id,
"score": score,
"confidence": confidence,
"orientation": orientation.value,
},
)
......@@ -99,10 +103,12 @@ class TranscriptionMixin(object):
text, str
), f"Transcription at index {index} in transcriptions: text shouldn't be null and should be of type str"
score = transcription.get("score")
confidence = transcription.get("confidence")
assert (
score is not None and isinstance(score, float) and 0 <= score <= 1
), f"Transcription at index {index} in transcriptions: score shouldn't be null and should be a float in [0..1] range"
confidence is not None
and isinstance(confidence, float)
and 0 <= confidence <= 1
), f"Transcription at index {index} in transcriptions: confidence shouldn't be null and should be a float in [0..1] range"
orientation = transcription.get(
"orientation", TextOrientation.HorizontalLeftToRight
......@@ -169,10 +175,12 @@ class TranscriptionMixin(object):
text, str
), f"Transcription at index {index} in transcriptions: text shouldn't be null and should be of type str"
score = transcription.get("score")
confidence = transcription.get("confidence")
assert (
score is not None and isinstance(score, float) and 0 <= score <= 1
), f"Transcription at index {index} in transcriptions: score shouldn't be null and should be a float in [0..1] range"
confidence is not None
and isinstance(confidence, float)
and 0 <= confidence <= 1
), f"Transcription at index {index} in transcriptions: confidence shouldn't be null and should be a float in [0..1] range"
orientation = transcription.get(
"orientation", TextOrientation.HorizontalLeftToRight
......@@ -255,7 +263,7 @@ class TranscriptionMixin(object):
"id": annotation["id"],
"element_id": annotation["element_id"],
"text": transcription["text"],
"confidence": transcription["score"],
"confidence": transcription["confidence"],
"orientation": transcription.get(
"orientation", TextOrientation.HorizontalLeftToRight
).value,
......
......@@ -8,7 +8,7 @@
"id": "008691ae-8133-48c4-88d5-d4cc9f65c06c",
"type": "line",
"text": "J . Caron &",
"score": 0.4781,
"confidence": 0.4781,
"zone": null,
"source": null,
"worker_version_id": "3ca4a8e3-91d1-4b78-8d83-d8bbbf487996",
......
This diff is collapsed.
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