WIP
This commit is contained in:
parent
673c7d8e84
commit
60212ff4c1
22
epwing.go
22
epwing.go
@ -24,7 +24,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
)
|
)
|
||||||
@ -46,12 +45,11 @@ type epwingDict struct {
|
|||||||
SubBooks []epwingBook `json:"subBooks"`
|
SubBooks []epwingBook `json:"subBooks"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func extractEpwingTerms(entry epwingEntry) []dbTerm {
|
func extractDaijisenTerms(entry epwingEntry) []dbTerm {
|
||||||
fmt.Print(entry.Heading)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func extractEpwingKanji(entry epwingEntry) []dbKanji {
|
func extractDaijisenKanji(entry epwingEntry) []dbKanji {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,17 +64,29 @@ func exportEpwingDb(outputDir, title string, reader io.Reader, flags int) error
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
termExtractors := map[string]func(epwingEntry) []dbTerm{
|
||||||
|
"大辞泉": extractDaijisenTerms,
|
||||||
|
}
|
||||||
|
|
||||||
var terms dbTermList
|
var terms dbTermList
|
||||||
for _, subBook := range dict.SubBooks {
|
for _, subBook := range dict.SubBooks {
|
||||||
|
if extractor, ok := termExtractors[subBook.Title]; ok {
|
||||||
for _, entry := range subBook.Entries {
|
for _, entry := range subBook.Entries {
|
||||||
terms = append(terms, extractEpwingTerms(entry)...)
|
terms = append(terms, extractor(entry)...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
kanjiExtractors := map[string]func(epwingEntry) []dbKanji{
|
||||||
|
"大辞泉": extractDaijisenKanji,
|
||||||
|
}
|
||||||
|
|
||||||
var kanji dbKanjiList
|
var kanji dbKanjiList
|
||||||
for _, subBook := range dict.SubBooks {
|
for _, subBook := range dict.SubBooks {
|
||||||
|
if extractor, ok := kanjiExtractors[subBook.Title]; ok {
|
||||||
for _, entry := range subBook.Entries {
|
for _, entry := range subBook.Entries {
|
||||||
kanji = append(kanji, extractEpwingKanji(entry)...)
|
kanji = append(kanji, extractor(entry)...)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user