1

Use cached part-of-speech values

This commit is contained in:
stephenmk 2023-02-02 15:50:57 -06:00
parent 7bff70b71c
commit 5755b79341
No known key found for this signature in database
GPG Key ID: B6DA730DB06235F1
2 changed files with 16 additions and 12 deletions

View File

@ -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)

View File

@ -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 {