Commit 6249c39b by davidstark

根据海亮意见,修改部分代码

parent 2ff355ac
......@@ -44,9 +44,6 @@ type Word struct {
WordRank float64 `json:"wordRank"`
KeywordVersion string `json:"keywordVersion"`
}
const BRAND_TYPE = "1"
const CATEGORY_TYPE = "2"
const MANUAL_TYPE = "3"
var wordMap sync.Map
var brandMap = make(map[string]int)
......@@ -118,30 +115,25 @@ func main() {
}
func checkUnusedData(bulkProcessor *elastic.BulkProcessor) {
var tmpMap = make(map[string]bool)
for brand := range brandMap {
if _, exist := usedMap.Load(brand + BRAND_TYPE); !exist {
addWord(brand,bulkProcessor,BRAND_TYPE)
}
tmpMap[brand] = true;
}
for category := range categoryMap {
if _, exist := usedMap.Load(category + CATEGORY_TYPE); !exist {
addWord(category,bulkProcessor,CATEGORY_TYPE)
}
tmpMap[category] = true
}
for manual := range manualMap {
if _, exist := usedMap.Load(manual + MANUAL_TYPE); !exist {
addWord(manual,bulkProcessor,MANUAL_TYPE)
tmpMap[manual] = true
}
for word := range tmpMap {
if _, exist := usedMap.Load(word); !exist {
addWord(word, bulkProcessor)
}
}
}
func addWord(keyword string, processor *elastic.BulkProcessor, wordType string) {
func addWord(keyword string, processor *elastic.BulkProcessor) {
var w = new(Word)
switch wordType {
case BRAND_TYPE: w.IsBrand = true
case CATEGORY_TYPE: w.IsCategory = true
case MANUAL_TYPE: { w.IsManual = true; w.ManualValue = manualMap[keyword]}
}
w.Keyword = keyword
w.KeywordVersion = dateStr
processWord(w)
......@@ -344,18 +336,18 @@ func processWord(w *Word) {
if _, isExist := brandMap[w.Keyword]; isExist {
w.IsBrand = true
usedMap.Store(w.Keyword + BRAND_TYPE, true)
usedMap.Store(w.Keyword, true)
}
if _, isExist := manualMap[w.Keyword]; isExist {
w.IsManual = true
w.ManualValue = manualMap[w.Keyword]
usedMap.Store(w.Keyword + MANUAL_TYPE,true)
usedMap.Store(w.Keyword,true)
}
if _, isExist := categoryMap[w.Keyword]; isExist {
w.IsCategory = true
usedMap.Store(w.Keyword + CATEGORY_TYPE, true)
usedMap.Store(w.Keyword, true)
}
if _, isExist := sensitiveMap[w.Keyword]; isExist {
......
......@@ -44,10 +44,6 @@ type Word struct {
WordRank float64 `json:"wordRank"`
KeywordVersion string `json:"keywordVersion"`
}
const BRAND_TYPE = "1"
const CATEGORY_TYPE = "2"
const MANUAL_TYPE = "3"
var wordMap sync.Map
var brandMap = make(map[string]int)
var categoryMap = make(map[string]int)
......@@ -109,30 +105,25 @@ func main() {
}
func checkUnusedData(bulkProcessor *elastic.BulkProcessor) {
var tmpMap = make(map[string]bool)
for brand := range brandMap {
if _, exist := usedMap.Load(brand + BRAND_TYPE); !exist {
addWord(brand,bulkProcessor,BRAND_TYPE)
}
tmpMap[brand] = true;
}
for category := range categoryMap {
if _, exist := usedMap.Load(category + CATEGORY_TYPE); !exist {
addWord(category,bulkProcessor,CATEGORY_TYPE)
}
tmpMap[category] = true
}
for manual := range manualMap {
if _, exist := usedMap.Load(manual + MANUAL_TYPE); !exist {
addWord(manual,bulkProcessor,MANUAL_TYPE)
tmpMap[manual] = true
}
for word := range tmpMap {
if _, exist := usedMap.Load(word); !exist {
addWord(word, bulkProcessor)
}
}
}
func addWord(keyword string, processor *elastic.BulkProcessor, wordType string) {
var w = new(Word)
switch wordType {
case BRAND_TYPE: w.IsBrand = true
case CATEGORY_TYPE: w.IsCategory = true
case MANUAL_TYPE: { w.IsManual = true; w.ManualValue = manualMap[keyword]}
}
w.Keyword = keyword
w.KeywordVersion = dateStr
processWord(w)
......@@ -322,18 +313,18 @@ func processWord(w *Word) {
if _, isExist := brandMap[w.Keyword]; isExist {
w.IsBrand = true
usedMap.Store(w.Keyword + BRAND_TYPE, true)
usedMap.Store(w.Keyword, true)
}
if _, isExist := manualMap[w.Keyword]; isExist {
w.IsManual = true
w.ManualValue = manualMap[w.Keyword]
usedMap.Store(w.Keyword + MANUAL_TYPE,true)
usedMap.Store(w.Keyword,true)
}
if _, isExist := categoryMap[w.Keyword]; isExist {
w.IsCategory = true
usedMap.Store(w.Keyword + CATEGORY_TYPE, true)
usedMap.Store(w.Keyword, true)
}
if _, isExist := sensitiveMap[w.Keyword]; isExist {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment