|
@@ -809,7 +809,13 @@ func ExtRuleCore(doc map[string]interface{}, e *ExtractTask, vc *RuleCore, j *ju
|
|
|
j.Result[k] = [](*ju.ExtField){}
|
|
|
}
|
|
|
for _, tmp := range v {
|
|
|
- field := &ju.ExtField{Weight: qu.IntAll(tmp["weight"]), ExtFrom: qu.ObjToString(tmp["extfrom"]), Field: k, Code: qu.ObjToString(tmp["code"]), Type: qu.ObjToString(tmp["type"]), MatchType: qu.ObjToString(tmp["matchtype"]), RuleText: qu.ObjToString(tmp["ruletext"]), SourceValue: tmp["sourcevalue"], Value: tmp["value"]}
|
|
|
+ field := &ju.ExtField{Weight: qu.IntAll(tmp["weight"]),
|
|
|
+ ExtFrom: qu.ObjToString(tmp["extfrom"]), Field: k,
|
|
|
+ Code: qu.ObjToString(tmp["code"]), Type: qu.ObjToString(tmp["type"]),
|
|
|
+ MatchType: qu.ObjToString(tmp["matchtype"]),
|
|
|
+ RuleText: qu.ObjToString(tmp["ruletext"]),
|
|
|
+ SourceValue: tmp["sourcevalue"],
|
|
|
+ Value: tmp["value"]}
|
|
|
if k == "bidamount" && field.ExtFrom == "第一候选人" {
|
|
|
field.Score = 1
|
|
|
}
|
|
@@ -1223,10 +1229,12 @@ func extractFromKv(field, fieldname string, blocks []*ju.Block, vc *RuleCore, kv
|
|
|
//正则提取结果
|
|
|
func extRegCoreToResult(extfrom, text string, tag *map[string]string, j *ju.Job, vre *RegLuaInfo, isSite bool) map[string][]map[string]interface{} {
|
|
|
defer qu.Catch()
|
|
|
- var score int
|
|
|
+ var score float64
|
|
|
+ score = vre.Score
|
|
|
if isSite {
|
|
|
- score = 1
|
|
|
+ score = score+1.0
|
|
|
}
|
|
|
+
|
|
|
extinfo := map[string][]map[string]interface{}{}
|
|
|
rep := map[string]string{}
|
|
|
if vre.RegCore.Bextract { //正则是两部分的,可以直接抽取的(含下划线)
|
|
@@ -1300,7 +1308,17 @@ func extRegCoreToResult(extfrom, text string, tag *map[string]string, j *ju.Job,
|
|
|
}
|
|
|
tmps = append(tmps, tmp)
|
|
|
|
|
|
- exfield := ju.ExtField{BlockTag: *tag, Field: vre.Field, Code: vre.Code, RuleText: vre.RuleText, Type: "regexp", MatchType: "regcontent", ExtFrom: extfrom, SourceValue: rep[vre.Field+"_"+fmt.Sprint(i)], Value: rep[vre.Field+"_"+fmt.Sprint(i)]}
|
|
|
+ exfield := ju.ExtField{
|
|
|
+ BlockTag: *tag,
|
|
|
+ Field: vre.Field,
|
|
|
+ Code: vre.Code,
|
|
|
+ RuleText: vre.RuleText,
|
|
|
+ Type: "regexp",
|
|
|
+ MatchType: "regcontent",
|
|
|
+ ExtFrom: extfrom,
|
|
|
+ SourceValue: rep[vre.Field+"_"+fmt.Sprint(i)],
|
|
|
+ Value: rep[vre.Field+"_"+fmt.Sprint(i)],
|
|
|
+ Score:score}
|
|
|
if tmp["blocktag"] != nil {
|
|
|
exfield.BlockTag = tmp["blocktag"].(map[string]string)
|
|
|
}
|
|
@@ -1308,6 +1326,7 @@ func extRegCoreToResult(extfrom, text string, tag *map[string]string, j *ju.Job,
|
|
|
}
|
|
|
}
|
|
|
if len(tmps) > 0 {
|
|
|
+ //fmt.Println(tmps)
|
|
|
extinfo[vre.Field] = tmps
|
|
|
}
|
|
|
}
|
|
@@ -1340,7 +1359,9 @@ func extRegCoreToResult(extfrom, text string, tag *map[string]string, j *ju.Job,
|
|
|
if j.Result[vre.Field] == nil {
|
|
|
j.Result[vre.Field] = [](*ju.ExtField){}
|
|
|
}
|
|
|
- field := &ju.ExtField{BlockTag: *tag, Field: vre.Field, Code: vre.Code, RuleText: vre.RuleText, Type: "regexp", MatchType: "regcontent", ExtFrom: extfrom, SourceValue: text, Value: val}
|
|
|
+ field := &ju.ExtField{BlockTag: *tag, Field: vre.Field, Code: vre.Code, RuleText: vre.RuleText, Type: "regexp", MatchType: "regcontent", ExtFrom: extfrom, SourceValue: text,
|
|
|
+ Value: val,
|
|
|
+ Score:score}
|
|
|
if tmp["blocktag"] != nil {
|
|
|
field.BlockTag = tmp["blocktag"].(map[string]string)
|
|
|
}
|
|
@@ -1364,7 +1385,9 @@ func ExtRegBack(j *ju.Job, in *RegLuaInfo, t *TaskInfo) {
|
|
|
if tmps, ok := v.([]map[string]interface{}); ok {
|
|
|
j.Result[k] = [](*ju.ExtField){}
|
|
|
for _, tmp := range tmps {
|
|
|
- field := &ju.ExtField{Field: k, Code: qu.ObjToString(tmp["code"]), RuleText: qu.ObjToString(tmp["ruletext"]), Type: qu.ObjToString(tmp["type"]), MatchType: qu.ObjToString(tmp["matchtype"]), ExtFrom: qu.ObjToString(tmp["extfrom"]), Value: tmp["value"]}
|
|
|
+ field := &ju.ExtField{Field: k, Code: qu.ObjToString(tmp["code"]), RuleText: qu.ObjToString(tmp["ruletext"]), Type: qu.ObjToString(tmp["type"]), MatchType: qu.ObjToString(tmp["matchtype"]),
|
|
|
+ ExtFrom: qu.ObjToString(tmp["extfrom"]),
|
|
|
+ Value: tmp["value"]}
|
|
|
if tmp["blocktag"] != nil {
|
|
|
field.BlockTag = tmp["blocktag"].(map[string]string)
|
|
|
}
|