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

View File

@ -210,17 +210,21 @@ func formsExportDb(inputPath, outputPath, languageName, title string, stride int
return err
}
meta := newJmdictMetadata(dictionary, languageName)
terms := dbTermList{}
for _, entry := range dictionary.Entries {
baseTerm := baseFormsTerm(entry)
headwords := extractHeadwords(entry)
for _, h := range headwords {
term := baseTerm
var term dbTerm
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)
}
}