(query: str, text: str)
| 334 | |
| 335 | |
| 336 | def lexical_overlap_score(query: str, text: str) -> float: |
| 337 | q_terms = [t for t in re.findall(r"[a-zA-Z0-9_]+", query.lower()) if len(t) > 2] |
| 338 | if not q_terms: |
| 339 | return 0.0 |
| 340 | t = text.lower() |
| 341 | hits = sum(1 for term in q_terms if term in t) |
| 342 | return hits / len(q_terms) |
| 343 | |
| 344 | |
| 345 | def load_sentence_transformer(model_name: str, allow_online_model_fetch: bool) -> SentenceTransformer: |
no outgoing calls
no test coverage detected