|
|
@ -36,7 +36,7 @@ type Entry struct {
|
|
|
|
|
|
|
|
|
|
|
|
type Definition struct {
|
|
|
|
type Definition struct {
|
|
|
|
Definition string
|
|
|
|
Definition string
|
|
|
|
PartOfSpeech string
|
|
|
|
PartOfSpeech []string
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func ParseEntry(entry jmdict.JmdictEntry) Entry {
|
|
|
|
func ParseEntry(entry jmdict.JmdictEntry) Entry {
|
|
|
@ -49,17 +49,17 @@ func ParseEntry(entry jmdict.JmdictEntry) Entry {
|
|
|
|
reading = entry.Readings[0].Reading
|
|
|
|
reading = entry.Readings[0].Reading
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var definitions []Definition
|
|
|
|
var definitions []Definition
|
|
|
|
if len(entry.Sense) > 0 && len(entry.Sense[0].Glossary) > 0 {
|
|
|
|
definitions = make([]Definition, len(entry.Sense))
|
|
|
|
definitions = make([]Definition, len(entry.Sense[0].Glossary))
|
|
|
|
for i, sense := range entry.Sense {
|
|
|
|
for i, glossary := range entry.Sense[0].Glossary {
|
|
|
|
definition := sense.Glossary[0].Content
|
|
|
|
var pos string
|
|
|
|
if len(sense.Glossary) > 1 {
|
|
|
|
if len(entry.Sense[0].PartsOfSpeech) > i+1 {
|
|
|
|
for _, glossary := range sense.Glossary[1:] {
|
|
|
|
pos = entry.Sense[0].PartsOfSpeech[i]
|
|
|
|
definition += "; " + glossary.Content
|
|
|
|
}
|
|
|
|
}
|
|
|
|
definitions[i] = Definition{
|
|
|
|
|
|
|
|
Definition: glossary.Content,
|
|
|
|
|
|
|
|
PartOfSpeech: pos,
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
definitions[i] = Definition{
|
|
|
|
|
|
|
|
Definition: definition,
|
|
|
|
|
|
|
|
PartOfSpeech: sense.PartsOfSpeech,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Entry{
|
|
|
|
return Entry{
|
|
|
|