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
|
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)
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user