|
@@ -260,6 +260,7 @@ func FormatContactKv(kvs *[]*Kv, title string, buyers []string, contactFormat *C
|
|
//处理联系人信息
|
|
//处理联系人信息
|
|
var indexMap map[int]string
|
|
var indexMap map[int]string
|
|
var matchMap map[string]map[string]bool
|
|
var matchMap map[string]map[string]bool
|
|
|
|
+ hasMatch := make(map[string]bool)
|
|
if contactFormat == nil || title != "" {
|
|
if contactFormat == nil || title != "" {
|
|
indexMap = map[int]string{}
|
|
indexMap = map[int]string{}
|
|
matchMap = map[string]map[string]bool{}
|
|
matchMap = map[string]map[string]bool{}
|
|
@@ -288,6 +289,7 @@ func FormatContactKv(kvs *[]*Kv, title string, buyers []string, contactFormat *C
|
|
}
|
|
}
|
|
isCanAddToIndexMap = true
|
|
isCanAddToIndexMap = true
|
|
}
|
|
}
|
|
|
|
+ n := 1
|
|
for _, ct_k := range HasOrderContactType(k) {
|
|
for _, ct_k := range HasOrderContactType(k) {
|
|
if !ContactType[ct_k].MatchString(k) {
|
|
if !ContactType[ct_k].MatchString(k) {
|
|
continue
|
|
continue
|
|
@@ -297,18 +299,23 @@ func FormatContactKv(kvs *[]*Kv, title string, buyers []string, contactFormat *C
|
|
if isContinue || !ascFindFlag {
|
|
if isContinue || !ascFindFlag {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- if isCanAddToIndexMap && len(indexMap) == 0 {
|
|
|
|
- indexMap[1] = ct_k
|
|
|
|
|
|
+ // if isCanAddToIndexMap && len(indexMap) == 0 {
|
|
|
|
+ if isCanAddToIndexMap {
|
|
|
|
+ indexMap[n] = ct_k
|
|
|
|
+ n++
|
|
ascFind = false
|
|
ascFind = false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
mustMatchFirst := len(indexMap) > 0 //第一个必须匹配上
|
|
mustMatchFirst := len(indexMap) > 0 //第一个必须匹配上
|
|
titleMatch := false
|
|
titleMatch := false
|
|
- if titleMatchType := ContactTypeTitleMatch(title); titleMatchType != "" {
|
|
|
|
|
|
+ if titleMatchType := ContactTypeTitleMatch(title); len(titleMatchType) != 0 {
|
|
titleMatch = true
|
|
titleMatch = true
|
|
mustMatchFirst = false
|
|
mustMatchFirst = false
|
|
- indexMap = map[int]string{1: titleMatchType}
|
|
|
|
|
|
+ for i, t := range titleMatchType {
|
|
|
|
+ indexMap[i+1] = t
|
|
|
|
+ }
|
|
|
|
+ //indexMap = map[int]string{1: titleMatchType}
|
|
}
|
|
}
|
|
// if buyers == nil {
|
|
// if buyers == nil {
|
|
// Debug("title-------", mustMatchFirst, title, indexMap, matchMap, totalIndexMap, ascFind)
|
|
// Debug("title-------", mustMatchFirst, title, indexMap, matchMap, totalIndexMap, ascFind)
|
|
@@ -326,6 +333,7 @@ func FormatContactKv(kvs *[]*Kv, title string, buyers []string, contactFormat *C
|
|
mapIndexInKvs := map[string]map[string]interface{}{} //map在数组总的索引位置
|
|
mapIndexInKvs := map[string]map[string]interface{}{} //map在数组总的索引位置
|
|
kvsTemp := make([]*Kv, len(*kvs))
|
|
kvsTemp := make([]*Kv, len(*kvs))
|
|
copy(kvsTemp, *kvs)
|
|
copy(kvsTemp, *kvs)
|
|
|
|
+ //again := 0
|
|
for kv_index, kv := range *kvs {
|
|
for kv_index, kv := range *kvs {
|
|
isBreak := true
|
|
isBreak := true
|
|
v := strings.TrimSpace(kv.Value)
|
|
v := strings.TrimSpace(kv.Value)
|
|
@@ -381,6 +389,7 @@ func FormatContactKv(kvs *[]*Kv, title string, buyers []string, contactFormat *C
|
|
}
|
|
}
|
|
} else if ascFind {
|
|
} else if ascFind {
|
|
for _, ct_k := range HasOrderContactType(k) {
|
|
for _, ct_k := range HasOrderContactType(k) {
|
|
|
|
+ //again++
|
|
if k_length < 3 || k_length > 15 {
|
|
if k_length < 3 || k_length > 15 {
|
|
isBreak = false
|
|
isBreak = false
|
|
continue
|
|
continue
|
|
@@ -451,10 +460,10 @@ func FormatContactKv(kvs *[]*Kv, title string, buyers []string, contactFormat *C
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
isBreak = false
|
|
isBreak = false
|
|
- if index != 0 || notmatchCount != 0 {
|
|
|
|
- startIndex = 0
|
|
|
|
- indexMap = map[int]string{}
|
|
|
|
- }
|
|
|
|
|
|
+ // if index != 0 || notmatchCount != 0 {
|
|
|
|
+ // startIndex = 0
|
|
|
|
+ // indexMap = map[int]string{}
|
|
|
|
+ // }
|
|
if startIndex == 0 {
|
|
if startIndex == 0 {
|
|
indexMap = map[int]string{}
|
|
indexMap = map[int]string{}
|
|
}
|
|
}
|
|
@@ -502,12 +511,28 @@ func FormatContactKv(kvs *[]*Kv, title string, buyers []string, contactFormat *C
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
isBreak = false
|
|
isBreak = false
|
|
- if prevKey != k {
|
|
|
|
|
|
+
|
|
|
|
+ // if again > 0 {
|
|
|
|
+ // if again%2 == 1 {
|
|
|
|
+ // index = 1
|
|
|
|
+ // } else {
|
|
|
|
+ // index = 2
|
|
|
|
+ // }
|
|
|
|
+ // } else {
|
|
|
|
+ // if prevKey != k {
|
|
|
|
+ // prevKey = k
|
|
|
|
+ // index = 1
|
|
|
|
+ // } else if prevKey == k {
|
|
|
|
+ // index++
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ if prevKey != k && !hasMatch[k] {
|
|
prevKey = k
|
|
prevKey = k
|
|
index = 1
|
|
index = 1
|
|
- } else if prevKey == k {
|
|
|
|
|
|
+ } else if index < 2 {
|
|
index++
|
|
index++
|
|
}
|
|
}
|
|
|
|
+ hasMatch[k] = true
|
|
//过滤值
|
|
//过滤值
|
|
if filterValue.MatchString(v) {
|
|
if filterValue.MatchString(v) {
|
|
continue
|
|
continue
|
|
@@ -577,28 +602,48 @@ func FormatContactKv(kvs *[]*Kv, title string, buyers []string, contactFormat *C
|
|
(*contactFormat).MatchMap = matchMap
|
|
(*contactFormat).MatchMap = matchMap
|
|
}
|
|
}
|
|
// if buyers == nil {
|
|
// if buyers == nil {
|
|
- // for _, kv := range *kvs {
|
|
|
|
- // Debug("bbbbbbbbbb", kv.Key, kv.Value)
|
|
|
|
- // }
|
|
|
|
|
|
+ // for _, kv := range *kvs {
|
|
|
|
+ // Debug("bbbbbbbbbb", kv.Key, kv.Value)
|
|
|
|
+ // }
|
|
// }
|
|
// }
|
|
//Debug("totalIndexMap", len(totalIndexMap))
|
|
//Debug("totalIndexMap", len(totalIndexMap))
|
|
}
|
|
}
|
|
-func ContactTypeTitleMatch(title string) string {
|
|
|
|
- matchType := ""
|
|
|
|
|
|
+func ContactTypeTitleMatch(title string) []string {
|
|
|
|
+ matchType := []string{}
|
|
|
|
+ matchTypeMap := map[string]bool{}
|
|
if title != "" && len([]rune(title)) < 15 {
|
|
if title != "" && len([]rune(title)) < 15 {
|
|
if ContactBuyerTitleReg.MatchString(title) {
|
|
if ContactBuyerTitleReg.MatchString(title) {
|
|
- matchType = "采购单位"
|
|
|
|
- } else if ContactAgencyTitleReg.MatchString(title) {
|
|
|
|
- matchType = "代理机构"
|
|
|
|
- } else {
|
|
|
|
- for _, ct_k := range HasOrderContactType(title) {
|
|
|
|
- if ContactType[ct_k].MatchString(title) {
|
|
|
|
- matchType = ct_k
|
|
|
|
- break
|
|
|
|
- }
|
|
|
|
|
|
+ matchType = append(matchType, "采购单位")
|
|
|
|
+ matchTypeMap["采购单位"] = true
|
|
|
|
+ }
|
|
|
|
+ if ContactAgencyTitleReg.MatchString(title) {
|
|
|
|
+ matchType = append(matchType, "代理机构")
|
|
|
|
+ matchTypeMap["代理机构"] = true
|
|
|
|
+ }
|
|
|
|
+ if len(matchType) == 2 {
|
|
|
|
+ return matchType
|
|
|
|
+ }
|
|
|
|
+ for _, ct_k := range HasOrderContactType(title) {
|
|
|
|
+ if ContactType[ct_k].MatchString(title) && !matchTypeMap[ct_k] {
|
|
|
|
+ matchType = append(matchType, ct_k)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ // matchType := ""
|
|
|
|
+ // if title != "" && len([]rune(title)) < 15 {
|
|
|
|
+ // if ContactBuyerTitleReg.MatchString(title) {
|
|
|
|
+ // matchType = "采购单位"
|
|
|
|
+ // } else if ContactAgencyTitleReg.MatchString(title) {
|
|
|
|
+ // matchType = "代理机构"
|
|
|
|
+ // } else {
|
|
|
|
+ // for _, ct_k := range HasOrderContactType(title) {
|
|
|
|
+ // if ContactType[ct_k].MatchString(title) {
|
|
|
|
+ // matchType = ct_k
|
|
|
|
+ // break
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
return matchType
|
|
return matchType
|
|
}
|
|
}
|
|
|
|
|