Skip to content
Snippets Groups Projects

Add few more helpers for developers + Report entity creation

Merged Eva Bardou requested to merge add-more-helpers into master
All threads resolved!
2 files
+ 52
38
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 9
13
@@ -230,11 +230,8 @@ class ElementsWorker(BaseWorker):
element, Element
), "element shouldn't be null and should be of type Element"
assert type and isinstance(
type, str
), "type shouldn't be null and should be of type str"
assert (
type in TranscriptionType._value2member_map_
), "type should be an allowed transcription type"
type, TranscriptionType
), "type shouldn't be null and should be of type TranscriptionType"
assert text and isinstance(
text, str
), "text shouldn't be null and should be of type str"
@@ -247,14 +244,16 @@ class ElementsWorker(BaseWorker):
id=element.id,
body={
"text": text,
"type": type,
"type": type.value,
"worker_version": self.worker_version_id,
"score": score,
},
)
self.report.add_transcription(element.id, type)
def create_classification(self, element, ml_class, confidence, high_confidence):
def create_classification(
self, element, ml_class, confidence, high_confidence=False
):
"""
Create a classification on the given element through API
"""
@@ -291,11 +290,8 @@ class ElementsWorker(BaseWorker):
name, str
), "name shouldn't be null and should be of type str"
assert type and isinstance(
type, str
), "type shouldn't be null and should be of type str"
assert (
type in EntityType._value2member_map_
), "type should be an allowed entity type"
type, EntityType
), "type shouldn't be null and should be of type EntityType"
assert corpus and isinstance(
corpus, str
), "corpus shouldn't be null and should be of type str"
@@ -308,7 +304,7 @@ class ElementsWorker(BaseWorker):
"CreateEntity",
body={
"name": name,
"type": type,
"type": type.value,
"metas": metas,
"validated": validated,
"corpus": corpus,
Loading