fix: narrow company registration intent

This commit is contained in:
2026-08-20 15:10:32 +03:00
parent e3f08426d5
commit 2faac7b74e
2 changed files with 7 additions and 4 deletions

View File

@@ -13,11 +13,11 @@ from search.minjust_opensearch import APP_VERSION, request_json
def company_registration_clauses(language: str, query: str) -> list[dict]:
tokens = set(re.findall(r"\w+", query.casefold()))
intent = {
"ru": ("осоо", ("как", "порядок", "процедура"), ("откр", "созд", "зарегистр"), "Действует"),
"ky": ("жчк", ("кантип", "тартиби"), ("ач", "түз", "кат"), "Күчүндө"),
"ru": ("осоо", ("как", "порядок", "процедура"), ("откр", "созд", "зарегистр"), ("счет", "счёт", "филиал"), "Действует"),
"ky": ("жчк", ("кантип", "тартиби"), ("ач", "түз", "кат"), ("эсеп", "эсеб", "филиал"), "Күчүндө"),
}[language]
entity, procedure_terms, action_prefixes, status = intent
if entity not in tokens or not tokens.intersection(procedure_terms) or not any(
entity, procedure_terms, action_prefixes, excluded_terms, status = intent
if entity not in tokens or any(token.startswith(term) for token in tokens for term in excluded_terms) or not tokens.intersection(procedure_terms) or not any(
token.startswith(prefix) for token in tokens for prefix in action_prefixes
):
return []

View File

@@ -59,7 +59,10 @@ class SearchRelevanceTest(unittest.TestCase):
for language, query in (
("ru", "ОсОО зарегистрирован?"),
("ru", "кто зарегистрировал ОсОО"),
("ru", "как открыть счет ОсОО"),
("ru", "как открыть филиал ОсОО"),
("ky", "ЖЧК ачык маалымат"),
("ky", "ЖЧК кантип банк эсебин ачуу"),
):
body = json.loads(build_search_body(language, query, 10))
self.assertNotIn("should", body["query"]["bool"])