1

More database updates

This commit is contained in:
Alex Yatskov 2016-08-21 22:06:35 -07:00
parent fcee6e009f
commit c170cfd321
2 changed files with 36 additions and 12 deletions

View File

@ -28,9 +28,21 @@ import (
"strings"
)
type termDefJson struct {
Expression string `json:"e"`
Reading string `json:"r"`
Tags string `json:"t"`
Glossary []string `json:"g"`
}
type termEntJson struct {
Name string `json:"n"`
Value string `json:"v"`
}
type termJson struct {
Entities [][]string `json:"e"`
Defs [][]interface{} `json:"d"`
Entities []termEntJson `json:"e"`
Defs []termDefJson `json:"d"`
}
type termSource struct {
@ -64,13 +76,17 @@ func (s *termSource) addTagsPri(tags ...string) {
func buildTermJson(entries []termSource, entities map[string]string) termJson {
var dict termJson
for key, value := range entities {
ent := []string{key, value}
for name, value := range entities {
ent := termEntJson{
Name: name,
Value: value,
}
dict.Entities = append(dict.Entities, ent)
}
for _, e := range entries {
def := []interface{}{
def := termDefJson{
e.Expression,
e.Reading,
strings.Join(e.Tags, " "),

View File

@ -32,8 +32,16 @@ import (
"github.com/FooSoft/jmdict"
)
type kanjiDefJson struct {
Character string `json:"c"`
Onyomi string `json:"o"`
Kunyomi string `json:"k"`
Tags string `json:"t"`
Meanings []string `json:"m"`
}
type kanjiJson struct {
Defs [][]interface{} `json:"d"`
Defs []kanjiDefJson `json:"d"`
}
type kanjiSource struct {
@ -56,12 +64,12 @@ func buildKanjiJson(kanji []kanjiSource) kanjiJson {
var dict kanjiJson
for _, k := range kanji {
def := []interface{}{
k.Character,
strings.Join(k.Onyomi, " "),
strings.Join(k.Kunyomi, " "),
strings.Join(k.Tags, " "),
k.Meanings,
def := kanjiDefJson{
Character: k.Character,
Onyomi: strings.Join(k.Onyomi, " "),
Kunyomi: strings.Join(k.Kunyomi, " "),
Tags: strings.Join(k.Tags, " "),
Meanings: k.Meanings,
}
dict.Defs = append(dict.Defs, def)