cleanup
This commit is contained in:
parent
2017635e01
commit
6cb74cc8c1
@ -262,10 +262,10 @@ func detectFormat(path string) (string, error) {
|
||||
switch filepath.Ext(path) {
|
||||
case ".sqlite":
|
||||
return "rikai", nil
|
||||
case ".kanji_freq":
|
||||
return "kanji_freq", nil
|
||||
case ".term_freq":
|
||||
return "term_freq", nil
|
||||
case ".kanjifreq":
|
||||
return "kanjifreq", nil
|
||||
case ".termfreq":
|
||||
return "termfreq", nil
|
||||
}
|
||||
|
||||
switch filepath.Base(path) {
|
||||
|
4
edict.go
4
edict.go
@ -228,8 +228,8 @@ func jmdictExportDb(inputPath, outputPath, language, title string, stride int, p
|
||||
}
|
||||
|
||||
recordData := map[string]dbRecordList{
|
||||
"terms": terms.crush(),
|
||||
"tags": jmdictBuildTagMeta(entities).crush(),
|
||||
"term": terms.crush(),
|
||||
"tag": jmdictBuildTagMeta(entities).crush(),
|
||||
}
|
||||
|
||||
return writeDb(
|
||||
|
@ -119,8 +119,8 @@ func jmnedictExportDb(inputPath, outputPath, language, title string, stride int,
|
||||
}
|
||||
|
||||
recordData := map[string]dbRecordList{
|
||||
"terms": terms.crush(),
|
||||
"tags": jmnedictBuildTagMeta(entities).crush(),
|
||||
"term": terms.crush(),
|
||||
"tag": jmnedictBuildTagMeta(entities).crush(),
|
||||
}
|
||||
|
||||
return writeDb(
|
||||
|
@ -202,7 +202,7 @@ func epwingExportDb(inputPath, outputPath, language, title string, stride int, p
|
||||
|
||||
recordData := map[string]dbRecordList{
|
||||
"kanji": kanji.crush(),
|
||||
"terms": terms.crush(),
|
||||
"term": terms.crush(),
|
||||
}
|
||||
|
||||
return writeDb(
|
||||
|
12
frequency.go
12
frequency.go
@ -31,7 +31,15 @@ import (
|
||||
|
||||
const frequencyRevision = "frequency1"
|
||||
|
||||
func frequncyExportDb(inputPath, outputPath, language, title string, stride int, pretty bool) error {
|
||||
func frequencyTermsExportDb(inputPath, outputPath, language, title string, stride int, pretty bool) error {
|
||||
return frequncyExportDb(inputPath, outputPath, language, title, stride, pretty, "termfreq")
|
||||
}
|
||||
|
||||
func frequencyKanjiExportDb(inputPath, outputPath, language, title string, stride int, pretty bool) error {
|
||||
return frequncyExportDb(inputPath, outputPath, language, title, stride, pretty, "kanjifreq")
|
||||
}
|
||||
|
||||
func frequncyExportDb(inputPath, outputPath, language, title string, stride int, pretty bool, key string) error {
|
||||
reader, err := os.Open(inputPath)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -60,7 +68,7 @@ func frequncyExportDb(inputPath, outputPath, language, title string, stride int,
|
||||
}
|
||||
|
||||
recordData := map[string]dbRecordList{
|
||||
"frequencies": frequencies.crush(),
|
||||
key: frequencies.crush(),
|
||||
}
|
||||
|
||||
return writeDb(
|
||||
|
@ -131,7 +131,7 @@ func kanjidicExportDb(inputPath, outputPath, language, title string, stride int,
|
||||
|
||||
recordData := map[string]dbRecordList{
|
||||
"kanji": kanji.crush(),
|
||||
"tags": tags.crush(),
|
||||
"tag": tags.crush(),
|
||||
}
|
||||
|
||||
return writeDb(
|
||||
|
12
main.go
12
main.go
@ -47,11 +47,13 @@ func usage() {
|
||||
|
||||
func exportDb(inputPath, outputPath, format, language, title string, stride int, pretty bool) error {
|
||||
handlers := map[string]func(string, string, string, string, int, bool) error{
|
||||
"edict": jmdictExportDb,
|
||||
"enamdict": jmnedictExportDb,
|
||||
"epwing": epwingExportDb,
|
||||
"kanjidic": kanjidicExportDb,
|
||||
"rikai": rikaiExportDb,
|
||||
"edict": jmdictExportDb,
|
||||
"enamdict": jmnedictExportDb,
|
||||
"epwing": epwingExportDb,
|
||||
"kanjidic": kanjidicExportDb,
|
||||
"rikai": rikaiExportDb,
|
||||
"kanjifreq": frequencyKanjiExportDb,
|
||||
"termfreq": frequencyTermsExportDb,
|
||||
}
|
||||
|
||||
handler, ok := handlers[strings.ToLower(format)]
|
||||
|
Loading…
Reference in New Issue
Block a user