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