diff --git a/dict/main.go b/dict/main.go index 6ba40da..422f92e 100644 --- a/dict/main.go +++ b/dict/main.go @@ -36,7 +36,7 @@ type Entry struct { type Definition struct { Definition string - PartOfSpeech string + PartOfSpeech []string } func ParseEntry(entry jmdict.JmdictEntry) Entry { @@ -49,18 +49,18 @@ func ParseEntry(entry jmdict.JmdictEntry) Entry { reading = entry.Readings[0].Reading } var definitions []Definition - if len(entry.Sense) > 0 && len(entry.Sense[0].Glossary) > 0 { - definitions = make([]Definition, len(entry.Sense[0].Glossary)) - for i, glossary := range entry.Sense[0].Glossary { - var pos string - if len(entry.Sense[0].PartsOfSpeech) > i+1 { - pos = entry.Sense[0].PartsOfSpeech[i] - } - definitions[i] = Definition{ - Definition: glossary.Content, - PartOfSpeech: pos, + definitions = make([]Definition, len(entry.Sense)) + for i, sense := range entry.Sense { + definition := sense.Glossary[0].Content + if len(sense.Glossary) > 1 { + for _, glossary := range sense.Glossary[1:] { + definition += "; " + glossary.Content } } + definitions[i] = Definition{ + Definition: definition, + PartOfSpeech: sense.PartsOfSpeech, + } } return Entry{ Kanji: kanji, diff --git a/dict/static/index.html b/dict/static/index.html index cfebb64..3ebf623 100644 --- a/dict/static/index.html +++ b/dict/static/index.html @@ -5,6 +5,11 @@
{{ $count := (len .) }}{{ if eq $count 0 }}No results{{ else }}{{ $count }} result{{ if ne $count 1}}s{{ end }}{{ end }}.
-{{- range . -}} +{{ range . -}}