Keep source names out of identifier clarification #393
@@ -1866,7 +1866,17 @@ func findingContainsRequestedIdentifier(query string, finding epistemics.Researc
|
||||
}
|
||||
|
||||
func requestedResearchIdentifiers(query string) []string {
|
||||
return regexp.MustCompile(`(?i)[a-z0-9][a-z0-9._-]{3,}`).FindAllString(query, -1)
|
||||
identifiers := regexp.MustCompile(`(?i)[a-z0-9][a-z0-9._-]{3,}`).FindAllString(query, -1)
|
||||
exact := make([]string, 0, len(identifiers))
|
||||
for _, identifier := range identifiers {
|
||||
if strings.ContainsAny(identifier, "._-") || strings.IndexFunc(identifier, func(r rune) bool { return r >= '0' && r <= '9' }) >= 0 {
|
||||
exact = append(exact, identifier)
|
||||
}
|
||||
}
|
||||
if len(exact) > 0 {
|
||||
return exact
|
||||
}
|
||||
return identifiers
|
||||
}
|
||||
|
||||
// nearestFlightRouteTerms retains only the two endpoint-shaped terms from a
|
||||
|
||||
@@ -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, "marka-wear") || !strings.Contains(reply, "уточните написание") {
|
||||
if backed || !strings.Contains(reply, "marka-wear") || strings.Contains(reply, "wildberries") || !strings.Contains(reply, "уточните написание") {
|
||||
t.Fatalf("generic page was presented as a brand result: %q", reply)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user