Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • workers/base-worker
1 result
Show changes
Commits on Source (2)
0.2.3-rc4 0.2.3-rc5
...@@ -18,7 +18,11 @@ class TextOrientation(Enum): ...@@ -18,7 +18,11 @@ class TextOrientation(Enum):
class TranscriptionMixin(object): class TranscriptionMixin(object):
def create_transcription( 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. Create a transcription on the given element through the API.
...@@ -33,8 +37,8 @@ class TranscriptionMixin(object): ...@@ -33,8 +37,8 @@ class TranscriptionMixin(object):
orientation, TextOrientation orientation, TextOrientation
), "orientation shouldn't be null and should be of type TextOrientation" ), "orientation shouldn't be null and should be of type TextOrientation"
assert ( assert (
isinstance(score, float) and 0 <= score <= 1 isinstance(confidence, float) and 0 <= confidence <= 1
), "score shouldn't be null and should be a float in [0..1] range" ), "confidence shouldn't be null and should be a float in [0..1] range"
if self.is_read_only: if self.is_read_only:
logger.warning( logger.warning(
...@@ -48,7 +52,7 @@ class TranscriptionMixin(object): ...@@ -48,7 +52,7 @@ class TranscriptionMixin(object):
body={ body={
"text": text, "text": text,
"worker_version": self.worker_version_id, "worker_version": self.worker_version_id,
"score": score, "confidence": confidence,
"orientation": orientation.value, "orientation": orientation.value,
}, },
) )
...@@ -99,10 +103,12 @@ class TranscriptionMixin(object): ...@@ -99,10 +103,12 @@ class TranscriptionMixin(object):
text, str text, str
), f"Transcription at index {index} in transcriptions: text shouldn't be null and should be of type 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 ( assert (
score is not None and isinstance(score, float) and 0 <= score <= 1 confidence is not None
), f"Transcription at index {index} in transcriptions: score shouldn't be null and should be a float in [0..1] range" 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 = transcription.get(
"orientation", TextOrientation.HorizontalLeftToRight "orientation", TextOrientation.HorizontalLeftToRight
...@@ -169,10 +175,12 @@ class TranscriptionMixin(object): ...@@ -169,10 +175,12 @@ class TranscriptionMixin(object):
text, str text, str
), f"Transcription at index {index} in transcriptions: text shouldn't be null and should be of type 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 ( assert (
score is not None and isinstance(score, float) and 0 <= score <= 1 confidence is not None
), f"Transcription at index {index} in transcriptions: score shouldn't be null and should be a float in [0..1] range" 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 = transcription.get(
"orientation", TextOrientation.HorizontalLeftToRight "orientation", TextOrientation.HorizontalLeftToRight
...@@ -255,7 +263,7 @@ class TranscriptionMixin(object): ...@@ -255,7 +263,7 @@ class TranscriptionMixin(object):
"id": annotation["id"], "id": annotation["id"],
"element_id": annotation["element_id"], "element_id": annotation["element_id"],
"text": transcription["text"], "text": transcription["text"],
"confidence": transcription["score"], "confidence": transcription["confidence"],
"orientation": transcription.get( "orientation": transcription.get(
"orientation", TextOrientation.HorizontalLeftToRight "orientation", TextOrientation.HorizontalLeftToRight
).value, ).value,
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
"id": "008691ae-8133-48c4-88d5-d4cc9f65c06c", "id": "008691ae-8133-48c4-88d5-d4cc9f65c06c",
"type": "line", "type": "line",
"text": "J . Caron &", "text": "J . Caron &",
"score": 0.4781, "confidence": 0.4781,
"zone": null, "zone": null,
"source": null, "source": null,
"worker_version_id": "3ca4a8e3-91d1-4b78-8d83-d8bbbf487996", "worker_version_id": "3ca4a8e3-91d1-4b78-8d83-d8bbbf487996",
......