1
This commit is contained in:
Alex Yatskov 2017-09-10 13:45:06 -07:00
parent 2017635e01
commit 6cb74cc8c1
8 changed files with 29 additions and 19 deletions

View File

@ -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) {

View File

@ -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(

View File

@ -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(

View File

@ -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(

View File

@ -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(

View File

@ -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
View File

@ -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)]

View File

@ -167,8 +167,8 @@ func rikaiExportDb(inputPath, outputPath, language, title string, stride int, pr
}
recordData := map[string]dbRecordList{
"terms": terms.crush(),
"tags": tags.crush(),
"term": terms.crush(),
"tag": tags.crush(),
}
return writeDb(