Liyan06 commited on
Commit
93e9112
1 Parent(s): 29406c4

span highlight for web search

Browse files
Files changed (1) hide show
  1. handler.py +11 -2
handler.py CHANGED
@@ -54,13 +54,22 @@ class EndpointHandler():
54
  else:
55
  assert len(data['inputs']['claims']) == 1, "Only one claim is allowed for web retrieval for the current version."
56
 
57
-
58
  ranked_docs, scores, ranked_urls = self.search_relevant_docs(claim)
59
 
 
 
 
 
 
 
 
 
 
60
  outputs = {
61
  'ranked_docs': ranked_docs,
62
  'scores': scores,
63
- 'ranked_urls': ranked_urls
 
64
  }
65
 
66
  return outputs
 
54
  else:
55
  assert len(data['inputs']['claims']) == 1, "Only one claim is allowed for web retrieval for the current version."
56
 
 
57
  ranked_docs, scores, ranked_urls = self.search_relevant_docs(claim)
58
 
59
+ span_to_highlight = []
60
+ for doc_chunk, score in zip(ranked_docs, scores):
61
+ # If the chunk can support the claim, find the sentence with the highest rouge score
62
+ if score > 0.5:
63
+ highest_score_sent, _ = self.chunk_and_highest_rouge_score(doc_chunk, claim)
64
+ span_to_highlight.append(highest_score_sent)
65
+ else:
66
+ span_to_highlight.append("")
67
+
68
  outputs = {
69
  'ranked_docs': ranked_docs,
70
  'scores': scores,
71
+ 'ranked_urls': ranked_urls,
72
+ 'span_to_highlight': span_to_highlight
73
  }
74
 
75
  return outputs