|
@@ -24,6 +24,8 @@ var OperatorReg = regexp.MustCompile("^中国(电信|联通|移动).*公司$")
|
|
|
|
|
|
var CleanTitleReg1 = regexp.MustCompile("[((].*[))]")
|
|
var CleanTitleReg1 = regexp.MustCompile("[((].*[))]")
|
|
|
|
|
|
|
|
+var CleanCutWords = regexp.MustCompile("^(范县|西区|东区|城区|矿区)$")
|
|
|
|
+
|
|
// 取特殊类数据
|
|
// 取特殊类数据
|
|
func GetFilialeByBuyerInfo(buyer string) string {
|
|
func GetFilialeByBuyerInfo(buyer string) string {
|
|
if FilialeReg1.MatchString(buyer) {
|
|
if FilialeReg1.MatchString(buyer) {
|
|
@@ -35,7 +37,6 @@ func GetFilialeByBuyerInfo(buyer string) string {
|
|
if FilialeReg3.MatchString(buyer) {
|
|
if FilialeReg3.MatchString(buyer) {
|
|
return FilialeReg3.ReplaceAllString(buyer, "${2}")
|
|
return FilialeReg3.ReplaceAllString(buyer, "${2}")
|
|
}
|
|
}
|
|
-
|
|
|
|
return ""
|
|
return ""
|
|
}
|
|
}
|
|
|
|
|
|
@@ -197,12 +198,11 @@ func (e *ExtractTask) GetRegionFromText(text string, regions *map[string]map[str
|
|
return regionValues
|
|
return regionValues
|
|
}
|
|
}
|
|
wordsArr := []string{}
|
|
wordsArr := []string{}
|
|
- //if from == 1 {
|
|
|
|
- // wordsArr = e.Seg_PCD.Cut(text, true)
|
|
|
|
- //} else if from == 2 {
|
|
|
|
- // wordsArr = e.Seg_SV.Cut(text, true)
|
|
|
|
- //}
|
|
|
|
- wordsArr = e.Seg_Full.Cut(text, true)
|
|
|
|
|
|
+ if from == 1 {
|
|
|
|
+ wordsArr = e.Seg_PCD.Cut(text, true)
|
|
|
|
+ } else if from == 2 {
|
|
|
|
+ wordsArr = e.Seg_SV.Cut(text, true)
|
|
|
|
+ }
|
|
//词组清洗
|
|
//词组清洗
|
|
wordsArr = CleanRegionTextWords(wordsArr)
|
|
wordsArr = CleanRegionTextWords(wordsArr)
|
|
regionsArr := []map[string]string{}
|
|
regionsArr := []map[string]string{}
|
|
@@ -494,9 +494,9 @@ func CleanRegionTextWords(wordsArr []string) []string {
|
|
return newArr
|
|
return newArr
|
|
}
|
|
}
|
|
|
|
|
|
- //清除特殊词组~城区
|
|
|
|
|
|
+ //清除特殊词组~城区,范县等
|
|
for _, v := range wordsArr {
|
|
for _, v := range wordsArr {
|
|
- if v == "城区" {
|
|
|
|
|
|
+ if CleanCutWords.MatchString(v) {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
newArr = append(newArr, v)
|
|
newArr = append(newArr, v)
|
|
@@ -507,8 +507,7 @@ func CleanRegionTextWords(wordsArr []string) []string {
|
|
// 链路补充~全称类
|
|
// 链路补充~全称类
|
|
func (e *ExtractTask) LinkSpecialRuleFullStep(text string, area *string, city *string, district *string) {
|
|
func (e *ExtractTask) LinkSpecialRuleFullStep(text string, area *string, city *string, district *string) {
|
|
regions := map[string]map[string]map[string]string{}
|
|
regions := map[string]map[string]map[string]string{}
|
|
- //wordsArr := e.Seg_SV.Cut(text, true)
|
|
|
|
- wordsArr := e.Seg_Full.Cut(text, true)
|
|
|
|
|
|
+ wordsArr := e.Seg_SV.Cut(text, true)
|
|
for _, word := range wordsArr {
|
|
for _, word := range wordsArr {
|
|
for pos_full, trie_full := range e.Trie_Fulls {
|
|
for pos_full, trie_full := range e.Trie_Fulls {
|
|
if pos_full == 3 {
|
|
if pos_full == 3 {
|
|
@@ -565,12 +564,11 @@ func (e *ExtractTask) LinkSpecialRuleBriefStep2(text string, area *string, city
|
|
func (e *ExtractTask) FetchBriefRules(text string, cutype int) map[string]map[string]map[string]string {
|
|
func (e *ExtractTask) FetchBriefRules(text string, cutype int) map[string]map[string]map[string]string {
|
|
regions := map[string]map[string]map[string]string{}
|
|
regions := map[string]map[string]map[string]string{}
|
|
wordsArr := []string{}
|
|
wordsArr := []string{}
|
|
- //if cutype == 1 {
|
|
|
|
- // wordsArr = e.Seg_Full.Cut(text, true)
|
|
|
|
- //} else {
|
|
|
|
- // wordsArr = e.Seg_SV.Cut(text, true)
|
|
|
|
- //}
|
|
|
|
- wordsArr = e.Seg_Full.Cut(text, true)
|
|
|
|
|
|
+ if cutype == 1 {
|
|
|
|
+ wordsArr = e.Seg_Full.Cut(text, true)
|
|
|
|
+ } else {
|
|
|
|
+ wordsArr = e.Seg_SV.Cut(text, true)
|
|
|
|
+ }
|
|
for _, word := range wordsArr {
|
|
for _, word := range wordsArr {
|
|
for pos_sim, trie_sim := range e.Trie_Sims {
|
|
for pos_sim, trie_sim := range e.Trie_Sims {
|
|
if pos_sim == 2 {
|
|
if pos_sim == 2 {
|
|
@@ -636,6 +634,13 @@ func LinkSpecialQyxyStep(buyer string, area *string, city *string, district *str
|
|
qyxy_arr, _ := ju.Qyxy_Mgo.Find("qyxy_std", map[string]interface{}{
|
|
qyxy_arr, _ := ju.Qyxy_Mgo.Find("qyxy_std", map[string]interface{}{
|
|
"company_name": buyer,
|
|
"company_name": buyer,
|
|
}, nil, nil)
|
|
}, nil, nil)
|
|
|
|
+ if qyxy_arr != nil && len(qyxy_arr) > 0 {
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ qyxy_arr, _ = ju.Qyxy_Mgo.Find("qyxy_std", map[string]interface{}{
|
|
|
|
+ "history_name": buyer,
|
|
|
|
+ }, nil, nil)
|
|
|
|
+ }
|
|
if qyxy_arr != nil && len(qyxy_arr) > 0 {
|
|
if qyxy_arr != nil && len(qyxy_arr) > 0 {
|
|
for _, v := range qyxy_arr {
|
|
for _, v := range qyxy_arr {
|
|
qy_area := qu.ObjToString(v["company_area"])
|
|
qy_area := qu.ObjToString(v["company_area"])
|