WIP
This commit is contained in:
parent
e84763a8a6
commit
98615708ca
2
edict.go
2
edict.go
@ -87,7 +87,7 @@ func convertEdictEntry(edictEntry jmdict.JmdictEntry) []vocabSource {
|
||||
return entries
|
||||
}
|
||||
|
||||
func processEdict(writer io.Writer, reader io.Reader, flags int) error {
|
||||
func outputEdictJson(writer io.Writer, reader io.Reader, flags int) error {
|
||||
dict, entities, err := jmdict.LoadJmdictNoTransform(reader)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -73,7 +73,7 @@ func convertJmnedictEntry(enamdictEntry jmdict.JmnedictEntry) []vocabSource {
|
||||
return entries
|
||||
}
|
||||
|
||||
func processJmnedict(writer io.Writer, reader io.Reader, flags int) error {
|
||||
func outputJmnedictJson(writer io.Writer, reader io.Reader, flags int) error {
|
||||
dict, entities, err := jmdict.LoadJmnedictNoTransform(reader)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -139,7 +139,7 @@ func convertKanjidicCharacter(kanjidicCharacter jmdict.KanjidicCharacter) kanjiS
|
||||
return character
|
||||
}
|
||||
|
||||
func processKanjidic(writer io.Writer, reader io.Reader, flags int) error {
|
||||
func outputKanjidicJson(writer io.Writer, reader io.Reader, flags int) error {
|
||||
dict, err := jmdict.LoadKanjidic(reader)
|
||||
if err != nil {
|
||||
return err
|
||||
|
10
main.go
10
main.go
@ -42,11 +42,11 @@ func usage() {
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
|
||||
func process(fileFormat, inputFile, outputFile string, flags int) error {
|
||||
func outputJson(fileFormat, inputFile, outputFile string, flags int) error {
|
||||
handlers := map[string]func(io.Writer, io.Reader, int) error{
|
||||
"edict": processEdict,
|
||||
"enamdict": processJmnedict,
|
||||
"kanjidic": processKanjidic,
|
||||
"edict": outputEdictJson,
|
||||
"enamdict": outputJmnedictJson,
|
||||
"kanjidic": outputKanjidicJson,
|
||||
}
|
||||
|
||||
handler, ok := handlers[fileFormat]
|
||||
@ -79,7 +79,7 @@ func main() {
|
||||
}
|
||||
|
||||
if flag.NArg() == 3 {
|
||||
if err := process(flag.Arg(0), flag.Arg(1), flag.Arg(2), flags); err != nil {
|
||||
if err := outputJson(flag.Arg(0), flag.Arg(1), flag.Arg(2), flags); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user