add TermTags
This commit is contained in:
parent
46492eb926
commit
23488d97f6
16
common.go
16
common.go
@ -77,6 +77,7 @@ type dbTerm struct {
|
||||
Expression string
|
||||
Reading string
|
||||
Tags []string
|
||||
TermTags []string
|
||||
Rules []string
|
||||
Score int
|
||||
Glossary []string
|
||||
@ -89,17 +90,30 @@ func (term *dbTerm) addTags(tags ...string) {
|
||||
term.Tags = appendStringUnique(term.Tags, tags...)
|
||||
}
|
||||
|
||||
func (term *dbTerm) addTermTags(termTags ...string) {
|
||||
term.TermTags = appendStringUnique(term.TermTags, termTags...)
|
||||
}
|
||||
|
||||
func (term *dbTerm) addRules(rules ...string) {
|
||||
term.Rules = appendStringUnique(term.Rules, rules...)
|
||||
}
|
||||
|
||||
func (term *dbTerm) crushTags() string {
|
||||
tags := strings.Join(term.Tags, " ")
|
||||
if len(term.TermTags) == 0 {
|
||||
return tags
|
||||
} else {
|
||||
return tags + "\t" + strings.Join(term.TermTags, " ")
|
||||
}
|
||||
}
|
||||
|
||||
func (terms dbTermList) crush() dbRecordList {
|
||||
var results dbRecordList
|
||||
for _, t := range terms {
|
||||
result := dbRecord{
|
||||
t.Expression,
|
||||
t.Reading,
|
||||
strings.Join(t.Tags, " "),
|
||||
t.crushTags(),
|
||||
strings.Join(t.Rules, " "),
|
||||
t.Score,
|
||||
t.Glossary,
|
||||
|
9
edict.go
9
edict.go
@ -63,10 +63,10 @@ func jmdictAddPriorities(term *dbTerm, priorities ...string) {
|
||||
for _, priority := range priorities {
|
||||
switch priority {
|
||||
case "news1", "ichi1", "spec1", "gai1":
|
||||
term.addTags("P")
|
||||
term.addTermTags("P")
|
||||
fallthrough
|
||||
case "news2", "ichi2", "spec2", "gai2":
|
||||
term.addTags(priority[:len(priority)-1])
|
||||
term.addTermTags(priority[:len(priority)-1])
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -107,7 +107,7 @@ func jmdictExtractTerms(edictEntry jmdict.JmdictEntry, language string) []dbTerm
|
||||
}
|
||||
|
||||
var termBase dbTerm
|
||||
termBase.addTags(reading.Information...)
|
||||
termBase.addTermTags(reading.Information...)
|
||||
|
||||
if kanji == nil {
|
||||
termBase.Expression = reading.Reading
|
||||
@ -115,7 +115,7 @@ func jmdictExtractTerms(edictEntry jmdict.JmdictEntry, language string) []dbTerm
|
||||
} else {
|
||||
termBase.Expression = kanji.Expression
|
||||
termBase.Reading = reading.Reading
|
||||
termBase.addTags(kanji.Information...)
|
||||
termBase.addTermTags(kanji.Information...)
|
||||
|
||||
for _, priority := range kanji.Priorities {
|
||||
if hasString(priority, reading.Priorities) {
|
||||
@ -152,6 +152,7 @@ func jmdictExtractTerms(edictEntry jmdict.JmdictEntry, language string) []dbTerm
|
||||
}
|
||||
|
||||
term.addTags(termBase.Tags...)
|
||||
term.addTermTags(termBase.TermTags...)
|
||||
term.addTags(sense.PartsOfSpeech...)
|
||||
term.addTags(sense.Fields...)
|
||||
term.addTags(sense.Misc...)
|
||||
|
Loading…
Reference in New Issue
Block a user