| 34 | return [self.items[i] for i in top_indices] |
| 35 | |
| 36 | def extract_query(text: str) -> Tuple[str, str]: |
| 37 | query_index = text.rfind("Query:") |
| 38 | |
| 39 | if query_index != -1: |
| 40 | context = text[:query_index].strip() |
| 41 | query = text[query_index + 6:].strip() |
| 42 | else: |
| 43 | sentences = re.split(r'(?<=[.!?])\s+', text.strip()) |
| 44 | if len(sentences) > 1: |
| 45 | context = ' '.join(sentences[:-1]) |
| 46 | query = sentences[-1] |
| 47 | else: |
| 48 | context = text |
| 49 | query = "What is the main point of this text?" |
| 50 | return query, context |
| 51 | |
| 52 | def classify_margin(margin): |
| 53 | return margin.startswith("YES#") |