From c85e5a321dd306ca24b6225475e6de908a0b2881 Mon Sep 17 00:00:00 2001
From: Bastien Abadie <bastien@nextcairn.com>
Date: Mon, 21 Sep 2020 11:55:37 +0200
Subject: [PATCH] Check score & confidence type

---
 arkindex_worker/worker.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arkindex_worker/worker.py b/arkindex_worker/worker.py
index 2882358c..73da0d86 100644
--- a/arkindex_worker/worker.py
+++ b/arkindex_worker/worker.py
@@ -299,7 +299,7 @@ class ElementsWorker(BaseWorker):
             text, str
         ), "text shouldn't be null and should be of type str"
         assert (
-            score and isinstance(score, float) and 0 <= score <= 1
+            isinstance(score, float) and 0 <= score <= 1
         ), "score shouldn't be null and should be a float in [0..1] range"
         if self.is_read_only:
             logger.warning(
@@ -374,7 +374,7 @@ class ElementsWorker(BaseWorker):
         ), "corpus shouldn't be null and should be of type str"
         if metas:
             assert isinstance(metas, dict), "metas should be of type dict"
-        if validated:
+        if validated is not None:
             assert isinstance(validated, bool), "validated should be of type bool"
         if self.is_read_only:
             logger.warning("Cannot create entity as this worker is in read-only mode")
@@ -422,7 +422,7 @@ class ElementsWorker(BaseWorker):
 
             score = transcription.get("score")
             assert (
-                score and isinstance(score, float) and 0 <= score <= 1
+                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"
 
             polygon = transcription.get("polygon")
-- 
GitLab