Skip to content
Open
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
10 changes: 6 additions & 4 deletions pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,14 @@ def _prepare_inputs_for_qg_from_answers_hl(self, sents, answers):
for i, answer in enumerate(answers):
if len(answer) == 0: continue
for answer_text in answer:
sent = sents[i]
sent = sents[i].lower()
sents_copy = sents[:]

answer_text = answer_text.strip()

ans_start_idx = sent.index(answer_text)
answer_text = answer_text.strip().lower()
try:
ans_start_idx = sent.index(answer_text)
except (ValueError,AssertionError):
continue

sent = f"{sent[:ans_start_idx]} <hl> {answer_text} <hl> {sent[ans_start_idx + len(answer_text): ]}"
sents_copy[i] = sent
Expand Down