Exclude dates from concrete research identifiers
CI / test (push) Successful in 1m21s

This commit is contained in:
m
2026-08-26 04:20:15 +03:00
parent da5d06895b
commit f316f7ec3f
2 changed files with 20 additions and 3 deletions
+13 -3
View File
@@ -1883,9 +1883,14 @@ func findingContainsRequestedIdentifier(query string, finding epistemics.Researc
}
func requestedResearchIdentifiers(query string) []string {
identifiers := regexp.MustCompile(`(?i)[a-z0-9][a-z0-9._-]{3,}`).FindAllString(query, -1)
exact := make([]string, 0, len(identifiers))
for _, identifier := range identifiers {
rawIdentifiers := regexp.MustCompile(`(?i)[a-z0-9][a-z0-9._-]{3,}`).FindAllString(query, -1)
identifiers := make([]string, 0, len(rawIdentifiers))
exact := make([]string, 0, len(rawIdentifiers))
for _, identifier := range rawIdentifiers {
if researchDateIdentifier(identifier) {
continue
}
identifiers = append(identifiers, identifier)
if strings.ContainsAny(identifier, "._-") || strings.IndexFunc(identifier, func(r rune) bool { return r >= '0' && r <= '9' }) >= 0 {
exact = append(exact, identifier)
}
@@ -1896,6 +1901,11 @@ func requestedResearchIdentifiers(query string) []string {
return identifiers
}
func researchDateIdentifier(value string) bool {
return regexp.MustCompile(`^\d{1,2}[.-]\d{1,2}[.-]\d{2,4}$`).MatchString(value) ||
regexp.MustCompile(`^\d{4}[.-]\d{1,2}[.-]\d{1,2}$`).MatchString(value)
}
// 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.