From b6e64ca42d9b1be1ac34ecc4b4d4e704b418c234 Mon Sep 17 00:00:00 2001 From: Malte Pietsch Date: Tue, 12 Jan 2021 10:02:40 +0100 Subject: [PATCH] Add ID to label schema (#727) --- haystack/schema.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/haystack/schema.py b/haystack/schema.py index 93e8e3a27..8733f49a8 100644 --- a/haystack/schema.py +++ b/haystack/schema.py @@ -83,6 +83,7 @@ class Label: is_correct_answer: bool, is_correct_document: bool, origin: str, + id: Optional[str] = None, document_id: Optional[str] = None, offset_start_in_doc: Optional[int] = None, no_answer: Optional[bool] = None, @@ -99,11 +100,19 @@ class Label: incorrect answer but correct document & incorrect document. This flag denotes if the returned document was correct. :param origin: the source for the labels. It can be used to later for filtering. + :param id: Unique ID used within the DocumentStore. If not supplied, a uuid will be generated automatically. :param document_id: the document_store's ID for the returned answer document. :param offset_start_in_doc: the answer start offset in the document. :param no_answer: whether the question in unanswerable. :param model_id: model_id used for prediction (in-case of user feedback). """ + + # Create a unique ID (either new one, or one from user input) + if id: + self.id = str(id) + else: + self.id = str(uuid4()) + self.question = question self.answer = answer self.is_correct_answer = is_correct_answer