Use cached part-of-speech values
This commit is contained in:
parent
7bff70b71c
commit
5755b79341
12
jmdict.go
12
jmdict.go
@ -94,16 +94,17 @@ func jmdictFormsTerm(headword headword, entry jmdict.JmdictEntry, meta jmdictMet
|
||||
}
|
||||
}
|
||||
|
||||
term := baseFormsTerm(entry)
|
||||
term := baseFormsTerm(entry, meta)
|
||||
term.Expression = headword.Expression
|
||||
term.Reading = headword.Reading
|
||||
|
||||
term.addTermTags(headword.TermTags...)
|
||||
|
||||
term.addDefinitionTags("forms")
|
||||
|
||||
senseNumber := meta.seqToSenseCount[entry.Sequence] + 1
|
||||
entryDepth := meta.entryDepth[entry.Sequence]
|
||||
term.Score = calculateTermScore(senseNumber, entryDepth, headword)
|
||||
|
||||
return term, true
|
||||
}
|
||||
|
||||
@ -119,10 +120,11 @@ func jmdictSearchTerm(headword headword, entry jmdict.JmdictEntry, meta jmdictMe
|
||||
Expression: headword.Expression,
|
||||
Sequence: -entry.Sequence,
|
||||
}
|
||||
for _, sense := range entry.Sense {
|
||||
rules := grammarRules(sense.PartsOfSpeech)
|
||||
|
||||
partsOfSpeech := meta.seqToPartsOfSpeech[entry.Sequence]
|
||||
rules := grammarRules(partsOfSpeech)
|
||||
term.addRules(rules...)
|
||||
}
|
||||
|
||||
term.addTermTags(headword.TermTags...)
|
||||
term.Score = calculateTermScore(1, 0, headword)
|
||||
|
||||
|
@ -172,18 +172,20 @@ func formsGlossary(headwords []headword) []any {
|
||||
return glossary
|
||||
}
|
||||
|
||||
func baseFormsTerm(entry jmdict.JmdictEntry) dbTerm {
|
||||
func baseFormsTerm(entry jmdict.JmdictEntry, meta jmdictMetadata) dbTerm {
|
||||
term := dbTerm{Sequence: entry.Sequence}
|
||||
headwords := extractHeadwords(entry)
|
||||
|
||||
if needsFormTable(headwords) {
|
||||
term.Glossary = formsTableGlossary(headwords)
|
||||
} else {
|
||||
term.Glossary = formsGlossary(headwords)
|
||||
}
|
||||
for _, sense := range entry.Sense {
|
||||
rules := grammarRules(sense.PartsOfSpeech)
|
||||
|
||||
partsOfSpeech := meta.seqToPartsOfSpeech[entry.Sequence]
|
||||
rules := grammarRules(partsOfSpeech)
|
||||
term.addRules(rules...)
|
||||
}
|
||||
|
||||
return term
|
||||
}
|
||||
|
||||
@ -203,7 +205,7 @@ func formsExportDb(inputPath, outputPath, languageName, title string, stride int
|
||||
|
||||
terms := dbTermList{}
|
||||
for _, entry := range dictionary.Entries {
|
||||
baseTerm := baseFormsTerm(entry)
|
||||
baseTerm := baseFormsTerm(entry, meta)
|
||||
headwords := extractHeadwords(entry)
|
||||
for _, h := range headwords {
|
||||
if h.IsSearchOnly {
|
||||
|
Loading…
Reference in New Issue
Block a user