1

Exclude "search" and "forms" terms from non-English dictionaries

This allows a user to install the English version and another version
without cluttering their setup with duplicated information.

If a user doesn't want to use the English version, they can get the
"search" and "forms" terms by installing the separate jmdict_forms
file.
This commit is contained in:
stephenmk 2023-01-22 17:55:27 -06:00
parent 8451803bfd
commit d8a3b420ee
No known key found for this signature in database
GPG Key ID: B6DA730DB06235F1
2 changed files with 15 additions and 7 deletions

View File

@ -134,8 +134,12 @@ func extractTerms(headword headword, entry jmdict.JmdictEntry, meta jmdictMetada
return nil, false return nil, false
} }
if headword.IsSearchOnly { if headword.IsSearchOnly {
searchTerm := createSearchTerm(headword, entry, meta) if meta.language == "eng" {
return []dbTerm{searchTerm}, true searchTerm := createSearchTerm(headword, entry, meta)
return []dbTerm{searchTerm}, true
} else {
return nil, false
}
} }
terms := []dbTerm{} terms := []dbTerm{}
senseNumber := 1 senseNumber := 1
@ -156,7 +160,7 @@ func extractTerms(headword headword, entry jmdict.JmdictEntry, meta jmdictMetada
terms = append(terms, senseTerm) terms = append(terms, senseTerm)
} }
if meta.hasMultipleForms[entry.Sequence] { if meta.hasMultipleForms[entry.Sequence] && meta.language == "eng" {
formsTerm := createFormsTerm(headword, entry, meta) formsTerm := createFormsTerm(headword, entry, meta)
terms = append(terms, formsTerm) terms = append(terms, formsTerm)
} }

View File

@ -210,17 +210,21 @@ func formsExportDb(inputPath, outputPath, languageName, title string, stride int
return err return err
} }
meta := newJmdictMetadata(dictionary, languageName)
terms := dbTermList{} terms := dbTermList{}
for _, entry := range dictionary.Entries { for _, entry := range dictionary.Entries {
baseTerm := baseFormsTerm(entry) baseTerm := baseFormsTerm(entry)
headwords := extractHeadwords(entry) headwords := extractHeadwords(entry)
for _, h := range headwords { for _, h := range headwords {
term := baseTerm var term dbTerm
if h.IsSearchOnly { if h.IsSearchOnly {
term.Sequence = -term.Sequence term = createSearchTerm(h, entry, meta)
} else {
term = baseTerm
term.Expression = h.Expression
term.Reading = h.Reading
} }
term.Expression = h.Expression
term.Reading = h.Reading
terms = append(terms, term) terms = append(terms, term)
} }
} }