1

rename Tags to DefinitionTags

This commit is contained in:
siikamiika 2017-10-13 02:46:06 +03:00
parent 3100950efa
commit 26d01e0d56
2 changed files with 21 additions and 29 deletions

View File

@ -74,50 +74,42 @@ func (freqs dbMetaList) crush() dbRecordList {
}
type dbTerm struct {
Expression string
Reading string
Tags []string
TermTags []string
Rules []string
Score int
Glossary []string
Sequence int
Expression string
Reading string
DefinitionTags []string
Rules []string
Score int
Glossary []string
Sequence int
TermTags []string
}
type dbTermList []dbTerm
func (term *dbTerm) addTags(tags ...string) {
term.Tags = appendStringUnique(term.Tags, tags...)
func (term *dbTerm) addDefinitionTags(tags ...string) {
term.DefinitionTags = appendStringUnique(term.DefinitionTags, tags...)
}
func (term *dbTerm) addTermTags(termTags ...string) {
term.TermTags = appendStringUnique(term.TermTags, termTags...)
func (term *dbTerm) addTermTags(tags ...string) {
term.TermTags = appendStringUnique(term.TermTags, tags...)
}
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,
t.crushTags(),
strings.Join(t.DefinitionTags, " "),
strings.Join(t.Rules, " "),
t.Score,
t.Glossary,
t.Sequence,
strings.Join(t.TermTags, " "),
}
results = append(results, result)

View File

@ -32,7 +32,7 @@ import (
const jmdictRevision = "jmdict4"
func jmdictBuildRules(term *dbTerm) {
for _, tag := range term.Tags {
for _, tag := range term.DefinitionTags {
switch tag {
case "adj-i", "v1", "vk":
term.addRules(tag)
@ -47,7 +47,7 @@ func jmdictBuildRules(term *dbTerm) {
}
func jmdictBuildScore(term *dbTerm) {
for _, tag := range term.Tags {
for _, tag := range term.DefinitionTags {
switch tag {
case "arch":
term.Score -= 100
@ -170,12 +170,12 @@ func jmdictExtractTerms(edictEntry jmdict.JmdictEntry, language string) []dbTerm
continue
}
term.addTags(termBase.Tags...)
term.addDefinitionTags(termBase.DefinitionTags...)
term.addTermTags(termBase.TermTags...)
term.addTags(partsOfSpeech...)
term.addTags(sense.Fields...)
term.addTags(sense.Misc...)
term.addTags(sense.Dialects...)
term.addDefinitionTags(partsOfSpeech...)
term.addDefinitionTags(sense.Fields...)
term.addDefinitionTags(sense.Misc...)
term.addDefinitionTags(sense.Dialects...)
jmdictBuildRules(&term)
jmdictBuildScore(&term)