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
|
TermTags []string
|
||||||
Index int
|
Index int
|
||||||
IsPriority bool
|
IsPriority bool
|
||||||
|
IsFrequent bool
|
||||||
IsIrregular bool
|
IsIrregular bool
|
||||||
IsOutdated bool
|
IsOutdated bool
|
||||||
IsRareKanji bool
|
IsRareKanji bool
|
||||||
@ -69,6 +70,9 @@ func (h *headword) Score() int {
|
|||||||
if h.IsPriority {
|
if h.IsPriority {
|
||||||
score += 1
|
score += 1
|
||||||
}
|
}
|
||||||
|
if h.IsFrequent {
|
||||||
|
score += 1
|
||||||
|
}
|
||||||
if h.IsIrregular {
|
if h.IsIrregular {
|
||||||
score -= 5
|
score -= 5
|
||||||
}
|
}
|
||||||
@ -109,6 +113,9 @@ func (h *headword) SetFlags(infoTags, freqTags []string) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if len(freqTags) > 1 {
|
||||||
|
h.IsFrequent = true
|
||||||
|
}
|
||||||
for _, infoTag := range infoTags {
|
for _, infoTag := range infoTags {
|
||||||
switch infoTag {
|
switch infoTag {
|
||||||
case "iK", "ik", "io":
|
case "iK", "ik", "io":
|
||||||
|
Loading…
Reference in New Issue
Block a user