More database updates
This commit is contained in:
parent
fcee6e009f
commit
c170cfd321
26
common.go
26
common.go
@ -28,9 +28,21 @@ import (
|
|||||||
"strings"
|
"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 {
|
type termJson struct {
|
||||||
Entities [][]string `json:"e"`
|
Entities []termEntJson `json:"e"`
|
||||||
Defs [][]interface{} `json:"d"`
|
Defs []termDefJson `json:"d"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type termSource struct {
|
type termSource struct {
|
||||||
@ -64,13 +76,17 @@ func (s *termSource) addTagsPri(tags ...string) {
|
|||||||
func buildTermJson(entries []termSource, entities map[string]string) termJson {
|
func buildTermJson(entries []termSource, entities map[string]string) termJson {
|
||||||
var dict termJson
|
var dict termJson
|
||||||
|
|
||||||
for key, value := range entities {
|
for name, value := range entities {
|
||||||
ent := []string{key, value}
|
ent := termEntJson{
|
||||||
|
Name: name,
|
||||||
|
Value: value,
|
||||||
|
}
|
||||||
|
|
||||||
dict.Entities = append(dict.Entities, ent)
|
dict.Entities = append(dict.Entities, ent)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, e := range entries {
|
for _, e := range entries {
|
||||||
def := []interface{}{
|
def := termDefJson{
|
||||||
e.Expression,
|
e.Expression,
|
||||||
e.Reading,
|
e.Reading,
|
||||||
strings.Join(e.Tags, " "),
|
strings.Join(e.Tags, " "),
|
||||||
|
22
kanjidic.go
22
kanjidic.go
@ -32,8 +32,16 @@ import (
|
|||||||
"github.com/FooSoft/jmdict"
|
"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 {
|
type kanjiJson struct {
|
||||||
Defs [][]interface{} `json:"d"`
|
Defs []kanjiDefJson `json:"d"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type kanjiSource struct {
|
type kanjiSource struct {
|
||||||
@ -56,12 +64,12 @@ func buildKanjiJson(kanji []kanjiSource) kanjiJson {
|
|||||||
var dict kanjiJson
|
var dict kanjiJson
|
||||||
|
|
||||||
for _, k := range kanji {
|
for _, k := range kanji {
|
||||||
def := []interface{}{
|
def := kanjiDefJson{
|
||||||
k.Character,
|
Character: k.Character,
|
||||||
strings.Join(k.Onyomi, " "),
|
Onyomi: strings.Join(k.Onyomi, " "),
|
||||||
strings.Join(k.Kunyomi, " "),
|
Kunyomi: strings.Join(k.Kunyomi, " "),
|
||||||
strings.Join(k.Tags, " "),
|
Tags: strings.Join(k.Tags, " "),
|
||||||
k.Meanings,
|
Meanings: k.Meanings,
|
||||||
}
|
}
|
||||||
|
|
||||||
dict.Defs = append(dict.Defs, def)
|
dict.Defs = append(dict.Defs, def)
|
||||||
|
Loading…
Reference in New Issue
Block a user