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:
parent
6726c5245b
commit
d606f729cf
@ -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":
|
||||
|
Loading…
Reference in New Issue
Block a user