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:
parent
8451803bfd
commit
d8a3b420ee
10
jmdict.go
10
jmdict.go
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user