Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix loading and saving of EvaluationReszult #1831

Merged
merged 2 commits into from
Dec 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions haystack/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,13 +482,20 @@ def __init__(self,
# which equals the no_answers representation of reader nodes.
if self.no_answer:
self.answers = [""]
self.gold_offsets_in_documents = []
self.gold_offsets_in_contexts = []
self.gold_offsets_in_documents: List[dict] = []
self.gold_offsets_in_contexts: List[dict] = []
else:
answered = [l.answer for l in self.labels if not l.no_answer and l.answer is not None]
self.answers = [answer.answer for answer in answered]
self.gold_offsets_in_documents = [answer.offsets_in_document for answer in answered]
self.gold_offsets_in_contexts = [answer.offsets_in_context for answer in answered]
self.gold_offsets_in_documents = []
self.gold_offsets_in_contexts = []
for answer in answered:
if answer.offsets_in_document is not None:
for span in answer.offsets_in_document:
self.gold_offsets_in_documents.append({'start': span.start, 'end': span.end})
if answer.offsets_in_context is not None:
for span in answer.offsets_in_context:
self.gold_offsets_in_contexts.append({'start': span.start, 'end': span.end})

# There are two options here to represent document_ids:
# taking the id from the document of each label or taking the document_id of each label's answer.
Expand Down