diff --git a/cmd/core-runtime/main.go b/cmd/core-runtime/main.go index 8660763..10279dc 100644 --- a/cmd/core-runtime/main.go +++ b/cmd/core-runtime/main.go @@ -1780,6 +1780,9 @@ func renderResearchReply(query string, result epistemics.ResearchResult, researc } } if len(lines) == 0 { + if identifiers := requestedResearchIdentifiers(query); len(identifiers) > 0 { + return "Не нашёл проверяемых данных о «" + strings.Join(identifiers, "», «") + "». Возможно, название написано иначе; пришлите ссылку или уточните написание, и я проверю.", false + } return "Проверяемых данных пока не найдено. Могу повторить поиск или уточнить, что именно проверить.", false } if isInternetStatusQuery(query) { @@ -1849,7 +1852,7 @@ func researchFindingMatchesIntent(query string, finding epistemics.ResearchFindi // Identifiers are detected by their syntax, not by a catalogue of providers or // entities, so the rule stays valid as user vocabulary changes. func findingContainsRequestedIdentifier(query string, finding epistemics.ResearchFinding) bool { - identifiers := regexp.MustCompile(`(?i)[a-z0-9][a-z0-9._-]{3,}`).FindAllString(query, -1) + identifiers := requestedResearchIdentifiers(query) if len(identifiers) == 0 { return true } @@ -1862,6 +1865,10 @@ func findingContainsRequestedIdentifier(query string, finding epistemics.Researc return true } +func requestedResearchIdentifiers(query string) []string { + return regexp.MustCompile(`(?i)[a-z0-9][a-z0-9._-]{3,}`).FindAllString(query, -1) +} + // nearestFlightRouteTerms retains only the two endpoint-shaped terms from a // structured flight search. It has no city or provider vocabulary: endpoint // relevance is determined from the request itself. diff --git a/cmd/core-runtime/main_test.go b/cmd/core-runtime/main_test.go index b7da5a8..2dccb13 100644 --- a/cmd/core-runtime/main_test.go +++ b/cmd/core-runtime/main_test.go @@ -65,7 +65,7 @@ func TestResearchReplyRejectsGenericLandingPageForConcreteIdentifier(t *testing. Excerpt: epistemics.SourceExcerpt{Text: "Широкий ассортимент товаров и услуг."}, }}} reply, backed := renderResearchReply("на WB бренд marka-wear", result, nil) - if backed || !strings.Contains(reply, "Проверяемых данных") { + if backed || !strings.Contains(reply, "marka-wear") || !strings.Contains(reply, "уточните написание") { t.Fatalf("generic page was presented as a brand result: %q", reply) } }