1

Use secondary frequency tags in term score calculation

If a term has a frequency tag, it should return higher in search
results than a match which does not have a tag.

For example, a search for 素性 should return すじょう rather than
そせい, because the former has a "news" frequency tag.
This commit is contained in:
stephenmk 2023-01-23 14:13:22 -06:00
parent 6726c5245b
commit d606f729cf
No known key found for this signature in database
GPG Key ID: B6DA730DB06235F1

View File

@ -16,6 +16,7 @@ type headword struct {
TermTags []string
Index int
IsPriority bool
IsFrequent bool
IsIrregular bool
IsOutdated bool
IsRareKanji bool
@ -69,6 +70,9 @@ func (h *headword) Score() int {
if h.IsPriority {
score += 1
}
if h.IsFrequent {
score += 1
}
if h.IsIrregular {
score -= 5
}
@ -109,6 +113,9 @@ func (h *headword) SetFlags(infoTags, freqTags []string) {
break
}
}
if len(freqTags) > 1 {
h.IsFrequent = true
}
for _, infoTag := range infoTags {
switch infoTag {
case "iK", "ik", "io":