fix(brand-questions): accept generic search terms in lexicon validation
Deployment Config CI / Deployment Config (push) Successful in 27s
Frontend CI / Frontend (push) Successful in 2m53s
Backend CI / Backend (push) Successful in 16m53s
Desktop Client Build / Resolve Build Metadata (push) Waiting to run
Desktop Client Build / Build Desktop Client (push) Blocked by required conditions
Desktop Client Build / Publish Client Artifacts to NAS (push) Has been cancelled
Deployment Config CI / Deployment Config (push) Successful in 27s
Frontend CI / Frontend (push) Successful in 2m53s
Backend CI / Backend (push) Successful in 16m53s
Desktop Client Build / Resolve Build Metadata (push) Waiting to run
Desktop Client Build / Build Desktop Client (push) Blocked by required conditions
Desktop Client Build / Publish Client Artifacts to NAS (push) Has been cancelled
Search terms like "全屋定制" or "GEO排名优化" were rejected as invalid because both the Vue candidate validator and the Go question_metadata classifier required interrogative cues (什么/如何/为什么/...). Lexicon entries are search terms, not questions, so require only letters or digits plus the existing 4-char minimum. Rename helpers to searchTermLooksValid/questionLooksValid to reflect the looser semantics, and relabel the navigation entry from "公司和词库" to "品牌和词库" to match the actual domain.
This commit is contained in:
@@ -123,17 +123,14 @@ func questionLooksValid(text string) bool {
|
||||
if utf8.RuneCountInString(trimmed) < 4 {
|
||||
return false
|
||||
}
|
||||
hasLetterOrNumber := false
|
||||
hasSearchTermChar := false
|
||||
for _, r := range trimmed {
|
||||
if unicode.IsLetter(r) || unicode.IsNumber(r) {
|
||||
hasLetterOrNumber = true
|
||||
hasSearchTermChar = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !hasLetterOrNumber {
|
||||
return false
|
||||
}
|
||||
return containsAny(strings.ToLower(trimmed), []string{"?", "?", "什么", "如何", "怎么", "哪", "为什么", "是否", "能不能", "适合", "区别", "对比", "推荐"})
|
||||
return hasSearchTermChar
|
||||
}
|
||||
|
||||
func containsAny(value string, needles []string) bool {
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package app
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestQuestionLooksValidAcceptsGenericSearchTerms(t *testing.T) {
|
||||
tests := []string{
|
||||
"全屋定制",
|
||||
"GEO排名优化",
|
||||
"AI搜索排名",
|
||||
}
|
||||
|
||||
for _, text := range tests {
|
||||
if !questionLooksValid(text) {
|
||||
t.Fatalf("questionLooksValid(%q) = false, want true", text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildCandidateKeepsGenericSearchTermSavable(t *testing.T) {
|
||||
candidate := buildCandidate(
|
||||
"全屋定制",
|
||||
QuestionSourceManual,
|
||||
false,
|
||||
map[string]struct{}{},
|
||||
&questionBrandContext{BrandName: "安徽海翔家居用品销售有限公司"},
|
||||
)
|
||||
|
||||
if candidate.TooShort {
|
||||
t.Fatal("expected generic search term not to be marked too short")
|
||||
}
|
||||
if candidate.SuggestSkip {
|
||||
t.Fatal("expected generic search term not to be suggested for skip")
|
||||
}
|
||||
}
|
||||
|
||||
func TestQuestionLooksValidRejectsEmptyOrTooShortTerms(t *testing.T) {
|
||||
tests := []string{
|
||||
"",
|
||||
"!?。",
|
||||
"AI",
|
||||
}
|
||||
|
||||
for _, text := range tests {
|
||||
if questionLooksValid(text) {
|
||||
t.Fatalf("questionLooksValid(%q) = true, want false", text)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user