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):
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",
......
......@@ -15,17 +15,17 @@ from . import BASE_API_CALLS
TRANSCRIPTIONS_SAMPLE = [
{
"polygon": [[100, 150], [700, 150], [700, 200], [100, 200]],
"score": 0.5,
"confidence": 0.5,
"text": "The",
},
{
"polygon": [[0, 0], [2000, 0], [2000, 3000], [0, 3000]],
"score": 0.75,
"confidence": 0.75,
"text": "first",
},
{
"polygon": [[1000, 300], [1200, 300], [1200, 500], [1000, 500]],
"score": 0.9,
"confidence": 0.9,
"text": "line",
},
]
......@@ -36,7 +36,7 @@ def test_create_transcription_wrong_element(mock_elements_worker):
mock_elements_worker.create_transcription(
element=None,
text="i am a line",
score=0.42,
confidence=0.42,
)
assert (
str(e.value)
......@@ -47,7 +47,7 @@ def test_create_transcription_wrong_element(mock_elements_worker):
mock_elements_worker.create_transcription(
element="not element type",
text="i am a line",
score=0.42,
confidence=0.42,
)
assert (
str(e.value)
......@@ -62,7 +62,7 @@ def test_create_transcription_wrong_text(mock_elements_worker):
mock_elements_worker.create_transcription(
element=elt,
text=None,
score=0.42,
confidence=0.42,
)
assert str(e.value) == "text shouldn't be null and should be of type str"
......@@ -70,52 +70,56 @@ def test_create_transcription_wrong_text(mock_elements_worker):
mock_elements_worker.create_transcription(
element=elt,
text=1234,
score=0.42,
confidence=0.42,
)
assert str(e.value) == "text shouldn't be null and should be of type str"
def test_create_transcription_wrong_score(mock_elements_worker):
def test_create_transcription_wrong_confidence(mock_elements_worker):
elt = Element({"id": "12341234-1234-1234-1234-123412341234"})
with pytest.raises(AssertionError) as e:
mock_elements_worker.create_transcription(
element=elt,
text="i am a line",
score=None,
confidence=None,
)
assert (
str(e.value) == "score shouldn't be null and should be a float in [0..1] range"
str(e.value)
== "confidence shouldn't be null and should be a float in [0..1] range"
)
with pytest.raises(AssertionError) as e:
mock_elements_worker.create_transcription(
element=elt,
text="i am a line",
score="wrong score",
confidence="wrong confidence",
)
assert (
str(e.value) == "score shouldn't be null and should be a float in [0..1] range"
str(e.value)
== "confidence shouldn't be null and should be a float in [0..1] range"
)
with pytest.raises(AssertionError) as e:
mock_elements_worker.create_transcription(
element=elt,
text="i am a line",
score=0,
confidence=0,
)
assert (
str(e.value) == "score shouldn't be null and should be a float in [0..1] range"
str(e.value)
== "confidence shouldn't be null and should be a float in [0..1] range"
)
with pytest.raises(AssertionError) as e:
mock_elements_worker.create_transcription(
element=elt,
text="i am a line",
score=2.00,
confidence=2.00,
)
assert (
str(e.value) == "score shouldn't be null and should be a float in [0..1] range"
str(e.value)
== "confidence shouldn't be null and should be a float in [0..1] range"
)
......@@ -135,12 +139,12 @@ def test_create_transcription_default_orientation(responses, mock_elements_worke
mock_elements_worker.create_transcription(
element=elt,
text="Animula vagula blandula",
score=0.42,
confidence=0.42,
)
assert json.loads(responses.calls[-1].request.body) == {
"text": "Animula vagula blandula",
"worker_version": "12341234-1234-1234-1234-123412341234",
"score": 0.42,
"confidence": 0.42,
"orientation": "horizontal-lr",
}
......@@ -162,12 +166,12 @@ def test_create_transcription_orientation(responses, mock_elements_worker):
element=elt,
text="Animula vagula blandula",
orientation=TextOrientation.VerticalLeftToRight,
score=0.42,
confidence=0.42,
)
assert json.loads(responses.calls[-1].request.body) == {
"text": "Animula vagula blandula",
"worker_version": "12341234-1234-1234-1234-123412341234",
"score": 0.42,
"confidence": 0.42,
"orientation": "vertical-lr",
}
......@@ -178,7 +182,7 @@ def test_create_transcription_wrong_orientation(mock_elements_worker):
mock_elements_worker.create_transcription(
element=elt,
text="Animula vagula blandula",
score=0.26,
confidence=0.26,
orientation="eliptical",
)
assert (
......@@ -199,7 +203,7 @@ def test_create_transcription_api_error(responses, mock_elements_worker):
mock_elements_worker.create_transcription(
element=elt,
text="i am a line",
score=0.42,
confidence=0.42,
)
assert len(responses.calls) == len(BASE_API_CALLS) + 5
......@@ -224,7 +228,6 @@ def test_create_transcription(responses, mock_elements_worker):
json={
"id": "56785678-5678-5678-5678-567856785678",
"text": "i am a line",
"score": 0.42,
"confidence": 0.42,
"worker_version_id": "12341234-1234-1234-1234-123412341234",
},
......@@ -233,7 +236,7 @@ def test_create_transcription(responses, mock_elements_worker):
mock_elements_worker.create_transcription(
element=elt,
text="i am a line",
score=0.42,
confidence=0.42,
)
assert len(responses.calls) == len(BASE_API_CALLS) + 1
......@@ -246,7 +249,7 @@ def test_create_transcription(responses, mock_elements_worker):
assert json.loads(responses.calls[-1].request.body) == {
"text": "i am a line",
"worker_version": "12341234-1234-1234-1234-123412341234",
"score": 0.42,
"confidence": 0.42,
"orientation": "horizontal-lr",
}
......@@ -261,7 +264,6 @@ def test_create_transcription_with_cache(responses, mock_elements_worker_with_ca
json={
"id": "56785678-5678-5678-5678-567856785678",
"text": "i am a line",
"score": 0.42,
"confidence": 0.42,
"orientation": "horizontal-lr",
"worker_version_id": "12341234-1234-1234-1234-123412341234",
......@@ -271,7 +273,7 @@ def test_create_transcription_with_cache(responses, mock_elements_worker_with_ca
mock_elements_worker_with_cache.create_transcription(
element=elt,
text="i am a line",
score=0.42,
confidence=0.42,
)
assert len(responses.calls) == len(BASE_API_CALLS) + 1
......@@ -285,7 +287,7 @@ def test_create_transcription_with_cache(responses, mock_elements_worker_with_ca
"text": "i am a line",
"worker_version": "12341234-1234-1234-1234-123412341234",
"orientation": "horizontal-lr",
"score": 0.42,
"confidence": 0.42,
}
# Check that created transcription was properly stored in SQLite cache
......@@ -321,13 +323,13 @@ def test_create_transcription_orientation_with_cache(
element=elt,
text="Animula vagula blandula",
orientation=TextOrientation.VerticalLeftToRight,
score=0.42,
confidence=0.42,
)
assert json.loads(responses.calls[-1].request.body) == {
"text": "Animula vagula blandula",
"worker_version": "12341234-1234-1234-1234-123412341234",
"orientation": "vertical-lr",
"score": 0.42,
"confidence": 0.42,
}
# Check that the text orientation was properly stored in SQLite cache
assert list(map(model_to_dict, CachedTranscription.select())) == [
......@@ -371,11 +373,11 @@ def test_create_transcriptions_wrong_transcriptions(mock_elements_worker):
{
"element_id": "11111111-1111-1111-1111-111111111111",
"text": "The",
"score": 0.75,
"confidence": 0.75,
},
{
"text": "word",
"score": 0.5,
"confidence": 0.5,
},
],
)
......@@ -390,12 +392,12 @@ def test_create_transcriptions_wrong_transcriptions(mock_elements_worker):
{
"element_id": "11111111-1111-1111-1111-111111111111",
"text": "The",
"score": 0.75,
"confidence": 0.75,
},
{
"element_id": None,
"text": "word",
"score": 0.5,
"confidence": 0.5,
},
],
)
......@@ -410,12 +412,12 @@ def test_create_transcriptions_wrong_transcriptions(mock_elements_worker):
{
"element_id": "11111111-1111-1111-1111-111111111111",
"text": "The",
"score": 0.75,
"confidence": 0.75,
},
{
"element_id": 1234,
"text": "word",
"score": 0.5,
"confidence": 0.5,
},
],
)
......@@ -430,11 +432,11 @@ def test_create_transcriptions_wrong_transcriptions(mock_elements_worker):
{
"element_id": "11111111-1111-1111-1111-111111111111",
"text": "The",
"score": 0.75,
"confidence": 0.75,
},
{
"element_id": "11111111-1111-1111-1111-111111111111",
"score": 0.5,
"confidence": 0.5,
},
],
)
......@@ -449,12 +451,12 @@ def test_create_transcriptions_wrong_transcriptions(mock_elements_worker):
{
"element_id": "11111111-1111-1111-1111-111111111111",
"text": "The",
"score": 0.75,
"confidence": 0.75,
},
{
"element_id": "11111111-1111-1111-1111-111111111111",
"text": None,
"score": 0.5,
"confidence": 0.5,
},
],
)
......@@ -469,12 +471,12 @@ def test_create_transcriptions_wrong_transcriptions(mock_elements_worker):
{
"element_id": "11111111-1111-1111-1111-111111111111",
"text": "The",
"score": 0.75,
"confidence": 0.75,
},
{
"element_id": "11111111-1111-1111-1111-111111111111",
"text": 1234,
"score": 0.5,
"confidence": 0.5,
},
],
)
......@@ -489,7 +491,7 @@ def test_create_transcriptions_wrong_transcriptions(mock_elements_worker):
{
"element_id": "11111111-1111-1111-1111-111111111111",
"text": "The",
"score": 0.75,
"confidence": 0.75,
},
{
"element_id": "11111111-1111-1111-1111-111111111111",
......@@ -499,7 +501,7 @@ def test_create_transcriptions_wrong_transcriptions(mock_elements_worker):
)
assert (
str(e.value)
== "Transcription at index 1 in transcriptions: score shouldn't be null and should be a float in [0..1] range"
== "Transcription at index 1 in transcriptions: confidence shouldn't be null and should be a float in [0..1] range"
)
with pytest.raises(AssertionError) as e:
......@@ -508,18 +510,18 @@ def test_create_transcriptions_wrong_transcriptions(mock_elements_worker):
{
"element_id": "11111111-1111-1111-1111-111111111111",
"text": "The",
"score": 0.75,
"confidence": 0.75,
},
{
"element_id": "11111111-1111-1111-1111-111111111111",
"text": "word",
"score": None,
"confidence": None,
},
],
)
assert (
str(e.value)
== "Transcription at index 1 in transcriptions: score shouldn't be null and should be a float in [0..1] range"
== "Transcription at index 1 in transcriptions: confidence shouldn't be null and should be a float in [0..1] range"
)
with pytest.raises(AssertionError) as e:
......@@ -528,18 +530,18 @@ def test_create_transcriptions_wrong_transcriptions(mock_elements_worker):
{
"element_id": "11111111-1111-1111-1111-111111111111",
"text": "The",
"score": 0.75,
"confidence": 0.75,
},
{
"element_id": "11111111-1111-1111-1111-111111111111",
"text": "word",
"score": "a wrong score",
"confidence": "a wrong confidence",
},
],
)
assert (
str(e.value)
== "Transcription at index 1 in transcriptions: score shouldn't be null and should be a float in [0..1] range"
== "Transcription at index 1 in transcriptions: confidence shouldn't be null and should be a float in [0..1] range"
)
with pytest.raises(AssertionError) as e:
......@@ -548,18 +550,18 @@ def test_create_transcriptions_wrong_transcriptions(mock_elements_worker):
{
"element_id": "11111111-1111-1111-1111-111111111111",
"text": "The",
"score": 0.75,
"confidence": 0.75,
},
{
"element_id": "11111111-1111-1111-1111-111111111111",
"text": "word",
"score": 0,
"confidence": 0,
},
],
)
assert (
str(e.value)
== "Transcription at index 1 in transcriptions: score shouldn't be null and should be a float in [0..1] range"
== "Transcription at index 1 in transcriptions: confidence shouldn't be null and should be a float in [0..1] range"
)
with pytest.raises(AssertionError) as e:
......@@ -568,18 +570,18 @@ def test_create_transcriptions_wrong_transcriptions(mock_elements_worker):
{
"element_id": "11111111-1111-1111-1111-111111111111",
"text": "The",
"score": 0.75,
"confidence": 0.75,
},
{
"element_id": "11111111-1111-1111-1111-111111111111",
"text": "word",
"score": 2.00,
"confidence": 2.00,
},
],
)
assert (
str(e.value)
== "Transcription at index 1 in transcriptions: score shouldn't be null and should be a float in [0..1] range"
== "Transcription at index 1 in transcriptions: confidence shouldn't be null and should be a float in [0..1] range"
)
with pytest.raises(AssertionError) as e:
......@@ -588,12 +590,12 @@ def test_create_transcriptions_wrong_transcriptions(mock_elements_worker):
{
"element_id": "11111111-1111-1111-1111-111111111111",
"text": "The",
"score": 0.75,
"confidence": 0.75,
},
{
"element_id": "11111111-1111-1111-1111-111111111111",
"text": "word",
"score": 0.28,
"confidence": 0.28,
"orientation": "wobble",
},
],
......@@ -614,12 +616,12 @@ def test_create_transcriptions_api_error(responses, mock_elements_worker):
{
"element_id": "11111111-1111-1111-1111-111111111111",
"text": "The",
"score": 0.75,
"confidence": 0.75,
},
{
"element_id": "11111111-1111-1111-1111-111111111111",
"text": "word",
"score": 0.42,
"confidence": 0.42,
},
]
......@@ -645,12 +647,12 @@ def test_create_transcriptions(responses, mock_elements_worker_with_cache):
{
"element_id": "11111111-1111-1111-1111-111111111111",
"text": "The",
"score": 0.75,
"confidence": 0.75,
},
{
"element_id": "11111111-1111-1111-1111-111111111111",
"text": "word",
"score": 0.42,
"confidence": 0.42,
},
]
......@@ -696,13 +698,13 @@ def test_create_transcriptions(responses, mock_elements_worker_with_cache):
{
"element_id": "11111111-1111-1111-1111-111111111111",
"text": "The",
"score": 0.75,
"confidence": 0.75,
"orientation": TextOrientation.HorizontalLeftToRight.value,
},
{
"element_id": "11111111-1111-1111-1111-111111111111",
"text": "word",
"score": 0.42,
"confidence": 0.42,
"orientation": TextOrientation.HorizontalLeftToRight.value,
},
],
......@@ -735,13 +737,13 @@ def test_create_transcriptions_orientation(responses, mock_elements_worker_with_
{
"element_id": "11111111-1111-1111-1111-111111111111",
"text": "Animula vagula blandula",
"score": 0.12,
"confidence": 0.12,
"orientation": TextOrientation.HorizontalRightToLeft,
},
{
"element_id": "11111111-1111-1111-1111-111111111111",
"text": "Hospes comesque corporis",
"score": 0.21,
"confidence": 0.21,
"orientation": TextOrientation.VerticalLeftToRight,
},
]
......@@ -781,13 +783,13 @@ def test_create_transcriptions_orientation(responses, mock_elements_worker_with_
{
"element_id": "11111111-1111-1111-1111-111111111111",
"text": "Animula vagula blandula",
"score": 0.12,
"confidence": 0.12,
"orientation": TextOrientation.HorizontalRightToLeft.value,
},
{
"element_id": "11111111-1111-1111-1111-111111111111",
"text": "Hospes comesque corporis",
"score": 0.21,
"confidence": 0.21,
"orientation": TextOrientation.VerticalLeftToRight.value,
},
],
......@@ -908,12 +910,12 @@ def test_create_element_transcriptions_wrong_transcriptions(mock_elements_worker
transcriptions=[
{
"polygon": [[0, 0], [2000, 0], [2000, 3000], [0, 3000]],
"score": 0.75,
"confidence": 0.75,
"text": "The",
},
{
"polygon": [[100, 150], [700, 150], [700, 200], [100, 200]],
"score": 0.5,
"confidence": 0.5,
},
],
)
......@@ -929,12 +931,12 @@ def test_create_element_transcriptions_wrong_transcriptions(mock_elements_worker
transcriptions=[
{
"polygon": [[0, 0], [2000, 0], [2000, 3000], [0, 3000]],
"score": 0.75,
"confidence": 0.75,
"text": "The",
},
{
"polygon": [[100, 150], [700, 150], [700, 200], [100, 200]],
"score": 0.5,
"confidence": 0.5,
"text": None,
},
],
......@@ -951,12 +953,12 @@ def test_create_element_transcriptions_wrong_transcriptions(mock_elements_worker
transcriptions=[
{
"polygon": [[0, 0], [2000, 0], [2000, 3000], [0, 3000]],
"score": 0.75,
"confidence": 0.75,
"text": "The",
},
{
"polygon": [[100, 150], [700, 150], [700, 200], [100, 200]],
"score": 0.5,
"confidence": 0.5,
"text": 1234,
},
],
......@@ -973,7 +975,7 @@ def test_create_element_transcriptions_wrong_transcriptions(mock_elements_worker
transcriptions=[
{
"polygon": [[0, 0], [2000, 0], [2000, 3000], [0, 3000]],
"score": 0.75,
"confidence": 0.75,
"text": "The",
},
{
......@@ -984,7 +986,7 @@ def test_create_element_transcriptions_wrong_transcriptions(mock_elements_worker
)
assert (
str(e.value)
== "Transcription at index 1 in transcriptions: score shouldn't be null and should be a float in [0..1] range"
== "Transcription at index 1 in transcriptions: confidence shouldn't be null and should be a float in [0..1] range"
)
with pytest.raises(AssertionError) as e:
......@@ -994,19 +996,19 @@ def test_create_element_transcriptions_wrong_transcriptions(mock_elements_worker
transcriptions=[
{
"polygon": [[0, 0], [2000, 0], [2000, 3000], [0, 3000]],
"score": 0.75,
"confidence": 0.75,
"text": "The",
},
{
"polygon": [[100, 150], [700, 150], [700, 200], [100, 200]],
"score": None,
"confidence": None,
"text": "word",
},
],
)
assert (
str(e.value)
== "Transcription at index 1 in transcriptions: score shouldn't be null and should be a float in [0..1] range"
== "Transcription at index 1 in transcriptions: confidence shouldn't be null and should be a float in [0..1] range"
)
with pytest.raises(AssertionError) as e:
......@@ -1016,19 +1018,19 @@ def test_create_element_transcriptions_wrong_transcriptions(mock_elements_worker
transcriptions=[
{
"polygon": [[0, 0], [2000, 0], [2000, 3000], [0, 3000]],
"score": 0.75,
"confidence": 0.75,
"text": "The",
},
{
"polygon": [[100, 150], [700, 150], [700, 200], [100, 200]],
"score": "a wrong score",
"confidence": "a wrong confidence",
"text": "word",
},
],
)
assert (
str(e.value)
== "Transcription at index 1 in transcriptions: score shouldn't be null and should be a float in [0..1] range"
== "Transcription at index 1 in transcriptions: confidence shouldn't be null and should be a float in [0..1] range"
)
with pytest.raises(AssertionError) as e:
......@@ -1038,19 +1040,19 @@ def test_create_element_transcriptions_wrong_transcriptions(mock_elements_worker
transcriptions=[
{
"polygon": [[0, 0], [2000, 0], [2000, 3000], [0, 3000]],
"score": 0.75,
"confidence": 0.75,
"text": "The",
},
{
"polygon": [[100, 150], [700, 150], [700, 200], [100, 200]],
"score": 0,
"confidence": 0,
"text": "word",
},
],
)
assert (
str(e.value)
== "Transcription at index 1 in transcriptions: score shouldn't be null and should be a float in [0..1] range"
== "Transcription at index 1 in transcriptions: confidence shouldn't be null and should be a float in [0..1] range"
)
with pytest.raises(AssertionError) as e:
......@@ -1060,19 +1062,19 @@ def test_create_element_transcriptions_wrong_transcriptions(mock_elements_worker
transcriptions=[
{
"polygon": [[0, 0], [2000, 0], [2000, 3000], [0, 3000]],
"score": 0.75,
"confidence": 0.75,
"text": "The",
},
{
"polygon": [[100, 150], [700, 150], [700, 200], [100, 200]],
"score": 2.00,
"confidence": 2.00,
"text": "word",
},
],
)
assert (
str(e.value)
== "Transcription at index 1 in transcriptions: score shouldn't be null and should be a float in [0..1] range"
== "Transcription at index 1 in transcriptions: confidence shouldn't be null and should be a float in [0..1] range"
)
with pytest.raises(AssertionError) as e:
......@@ -1082,10 +1084,10 @@ def test_create_element_transcriptions_wrong_transcriptions(mock_elements_worker
transcriptions=[
{
"polygon": [[0, 0], [2000, 0], [2000, 3000], [0, 3000]],
"score": 0.75,
"confidence": 0.75,
"text": "The",
},
{"score": 0.5, "text": "word"},
{"confidence": 0.5, "text": "word"},
],
)
assert (
......@@ -1100,10 +1102,10 @@ def test_create_element_transcriptions_wrong_transcriptions(mock_elements_worker
transcriptions=[
{
"polygon": [[0, 0], [2000, 0], [2000, 3000], [0, 3000]],
"score": 0.75,
"confidence": 0.75,
"text": "The",
},
{"polygon": None, "score": 0.5, "text": "word"},
{"polygon": None, "confidence": 0.5, "text": "word"},
],
)
assert (
......@@ -1118,10 +1120,10 @@ def test_create_element_transcriptions_wrong_transcriptions(mock_elements_worker
transcriptions=[
{
"polygon": [[0, 0], [2000, 0], [2000, 3000], [0, 3000]],
"score": 0.75,
"confidence": 0.75,
"text": "The",
},
{"polygon": "not a polygon", "score": 0.5, "text": "word"},
{"polygon": "not a polygon", "confidence": 0.5, "text": "word"},
],
)
assert (
......@@ -1136,10 +1138,10 @@ def test_create_element_transcriptions_wrong_transcriptions(mock_elements_worker
transcriptions=[
{
"polygon": [[0, 0], [2000, 0], [2000, 3000], [0, 3000]],
"score": 0.75,
"confidence": 0.75,
"text": "The",
},
{"polygon": [[1, 1], [2, 2]], "score": 0.5, "text": "word"},
{"polygon": [[1, 1], [2, 2]], "confidence": 0.5, "text": "word"},
],
)
assert (
......@@ -1154,12 +1156,12 @@ def test_create_element_transcriptions_wrong_transcriptions(mock_elements_worker
transcriptions=[
{
"polygon": [[0, 0], [2000, 0], [2000, 3000], [0, 3000]],
"score": 0.75,
"confidence": 0.75,
"text": "The",
},
{
"polygon": [[1, 1, 1], [2, 2, 1], [2, 1, 1], [1, 2, 1]],
"score": 0.5,
"confidence": 0.5,
"text": "word",
},
],
......@@ -1176,10 +1178,10 @@ def test_create_element_transcriptions_wrong_transcriptions(mock_elements_worker
transcriptions=[
{
"polygon": [[0, 0], [2000, 0], [2000, 3000], [0, 3000]],
"score": 0.75,
"confidence": 0.75,
"text": "The",
},
{"polygon": [[1], [2], [2], [1]], "score": 0.5, "text": "word"},
{"polygon": [[1], [2], [2], [1]], "confidence": 0.5, "text": "word"},
],
)
assert (
......@@ -1194,12 +1196,12 @@ def test_create_element_transcriptions_wrong_transcriptions(mock_elements_worker
transcriptions=[
{
"polygon": [[0, 0], [2000, 0], [2000, 3000], [0, 3000]],
"score": 0.75,
"confidence": 0.75,
"text": "The",
},
{
"polygon": [["not a coord", 1], [2, 2], [2, 1], [1, 2]],
"score": 0.5,
"confidence": 0.5,
"text": "word",
},
],
......@@ -1216,12 +1218,12 @@ def test_create_element_transcriptions_wrong_transcriptions(mock_elements_worker
transcriptions=[
{
"polygon": [[0, 0], [2000, 0], [2000, 3000], [0, 3000]],
"score": 0.75,
"confidence": 0.75,
"text": "The",
},
{
"polygon": [[100, 150], [700, 150], [700, 200], [100, 200]],
"score": 0.35,
"confidence": 0.35,
"text": "word",
"orientation": "uptown",
},
......@@ -1305,19 +1307,19 @@ def test_create_element_transcriptions(responses, mock_elements_worker):
"transcriptions": [
{
"polygon": [[100, 150], [700, 150], [700, 200], [100, 200]],
"score": 0.5,
"confidence": 0.5,
"text": "The",
"orientation": TextOrientation.HorizontalLeftToRight.value,
},
{
"polygon": [[0, 0], [2000, 0], [2000, 3000], [0, 3000]],
"score": 0.75,
"confidence": 0.75,
"text": "first",
"orientation": TextOrientation.HorizontalLeftToRight.value,
},
{
"polygon": [[1000, 300], [1200, 300], [1200, 500], [1000, 500]],
"score": 0.9,
"confidence": 0.9,
"text": "line",
"orientation": TextOrientation.HorizontalLeftToRight.value,
},
......@@ -1390,19 +1392,19 @@ def test_create_element_transcriptions_with_cache(
"transcriptions": [
{
"polygon": [[100, 150], [700, 150], [700, 200], [100, 200]],
"score": 0.5,
"confidence": 0.5,
"text": "The",
"orientation": TextOrientation.HorizontalLeftToRight.value,
},
{
"polygon": [[0, 0], [2000, 0], [2000, 3000], [0, 3000]],
"score": 0.75,
"confidence": 0.75,
"text": "first",
"orientation": TextOrientation.HorizontalLeftToRight.value,
},
{
"polygon": [[1000, 300], [1200, 300], [1200, 500], [1000, 500]],
"score": 0.9,
"confidence": 0.9,
"text": "line",
"orientation": TextOrientation.HorizontalLeftToRight.value,
},
......@@ -1503,18 +1505,18 @@ def test_create_transcriptions_orientation_with_cache(
oriented_transcriptions = [
{
"polygon": [[100, 150], [700, 150], [700, 200], [100, 200]],
"score": 0.5,
"confidence": 0.5,
"text": "Animula vagula blandula",
},
{
"polygon": [[0, 0], [2000, 0], [2000, 3000], [0, 3000]],
"score": 0.75,
"confidence": 0.75,
"text": "Hospes comesque corporis",
"orientation": TextOrientation.VerticalLeftToRight,
},
{
"polygon": [[100, 150], [700, 150], [700, 200], [100, 200]],
"score": 0.9,
"confidence": 0.9,
"text": "Quae nunc abibis in loca",
"orientation": TextOrientation.HorizontalRightToLeft,
},
......@@ -1532,19 +1534,19 @@ def test_create_transcriptions_orientation_with_cache(
"transcriptions": [
{
"polygon": [[100, 150], [700, 150], [700, 200], [100, 200]],
"score": 0.5,
"confidence": 0.5,
"text": "Animula vagula blandula",
"orientation": TextOrientation.HorizontalLeftToRight.value,
},
{
"polygon": [[0, 0], [2000, 0], [2000, 3000], [0, 3000]],
"score": 0.75,
"confidence": 0.75,
"text": "Hospes comesque corporis",
"orientation": TextOrientation.VerticalLeftToRight.value,
},
{
"polygon": [[100, 150], [700, 150], [700, 200], [100, 200]],
"score": 0.9,
"confidence": 0.9,
"text": "Quae nunc abibis in loca",
"orientation": TextOrientation.HorizontalRightToLeft.value,
},
......