|
@@ -387,7 +387,11 @@ func (e *ExtractTask) ExtractDetail(j *ju.Job) {
|
|
|
//if len(j.Result[vc.Field]) < 1 {//如果抽取有结果,不走标题。待验证,暂时标题加入选举逻辑
|
|
|
field := &ju.ExtField{Field: vc.Field, Code: "title", RuleText: "title", Type: "title", ExtFrom: vc.ExtFrom, SourceValue: j.Title, Value: j.Title}
|
|
|
if tmp["blocktag"] != nil {
|
|
|
- field.BlockTag = tmp["blocktag"].(map[string]bool)
|
|
|
+ btag:= make(map[string]string)
|
|
|
+ for k := range tmp["blocktag"].(map[string]bool){
|
|
|
+ btag[k] = TagConfigDesc[k]
|
|
|
+ }
|
|
|
+ field.BlockTag = btag
|
|
|
}
|
|
|
j.Result[vc.Field] = append(j.Result[vc.Field], field)
|
|
|
//}
|
|
@@ -621,7 +625,11 @@ func ExtRegCore(extfrom string, doc map[string]interface{}, j *ju.Job, in *RegLu
|
|
|
for _, tmp := range tmps {
|
|
|
field := &ju.ExtField{Field: k, Code: qu.ObjToString(tmp["code"]), RuleText: qu.ObjToString(tmp["ruletext"]), SourceValue: tmp["sourcevalue"], Value: tmp["value"]}
|
|
|
if tmp["blocktag"] != nil {
|
|
|
- field.BlockTag = tmp["blocktag"].(map[string]bool)
|
|
|
+ btag := make(map[string]string)
|
|
|
+ for k := range tmp["blocktag"].(map[string]bool){
|
|
|
+ btag[k] = TagConfigDesc[k]
|
|
|
+ }
|
|
|
+ field.BlockTag = btag
|
|
|
}
|
|
|
j.Result[k] = append(j.Result[k], field)
|
|
|
}
|
|
@@ -643,13 +651,17 @@ func ExtRegCore(extfrom string, doc map[string]interface{}, j *ju.Job, in *RegLu
|
|
|
//块抽取
|
|
|
if in.Field != "" {
|
|
|
if extfrom == "title" {
|
|
|
- extinfo := extRegCoreToResult(extfrom, qu.ObjToString(doc[extfrom]), &map[string]bool{"title": true}, j, in)
|
|
|
+ extinfo := extRegCoreToResult(extfrom, qu.ObjToString(doc[extfrom]), &map[string]string{}, j, in)
|
|
|
if len(extinfo) > 0 {
|
|
|
AddExtLog("extract", j.SourceMid, nil, extinfo, in, et.TaskInfo) //抽取日志
|
|
|
}
|
|
|
} else {
|
|
|
for _, v := range j.Block {
|
|
|
- extinfo := extRegCoreToResult(extfrom, v.Text, &v.Classify, j, in)
|
|
|
+ btag := make(map[string]string)
|
|
|
+ for k:=range v.Classify{
|
|
|
+ btag[k] = TagConfigDesc[k]
|
|
|
+ }
|
|
|
+ extinfo := extRegCoreToResult(extfrom, v.Text, &btag, j, in)
|
|
|
if len(extinfo) > 0 {
|
|
|
AddExtLog("extract", j.SourceMid, nil, extinfo, in, et.TaskInfo) //抽取日志
|
|
|
}
|
|
@@ -840,7 +852,7 @@ func getKvByLuaFields(extfrom string, j *ju.Job, in *RegLuaInfo, t map[string][]
|
|
|
}
|
|
|
|
|
|
//正则提取结果
|
|
|
-func extRegCoreToResult(extfrom, text string, tag *map[string]bool, j *ju.Job, v *RegLuaInfo) map[string][]map[string]interface{} {
|
|
|
+func extRegCoreToResult(extfrom, text string, tag *map[string]string, j *ju.Job, v *RegLuaInfo) map[string][]map[string]interface{} {
|
|
|
defer qu.Catch()
|
|
|
extinfo := map[string][]map[string]interface{}{}
|
|
|
if v.RegCore.Bextract { //正则是两部分的,可以直接抽取的(含下划线)
|
|
@@ -879,7 +891,7 @@ func extRegCoreToResult(extfrom, text string, tag *map[string]bool, j *ju.Job, v
|
|
|
}
|
|
|
exfield := ju.ExtField{BlockTag: *tag, Field: k, Code: v.Code, RuleText: v.RuleText, Type: "regexp", MatchType: "regcontent", ExtFrom: extfrom, SourceValue: sourcevalue, Value: val}
|
|
|
if tmp["blocktag"] != nil {
|
|
|
- exfield.BlockTag = tmp["blocktag"].(map[string]bool)
|
|
|
+ exfield.BlockTag = tmp["blocktag"].(map[string]string)
|
|
|
}
|
|
|
j.Result[k] = append(j.Result[k], &exfield)
|
|
|
//j.Result[k] = append(j.Result[k], &ju.ExtField{tmp["blocktag"].(map[string]bool), k, v.Code, v.RuleText, "regexp", "regcontent", extfrom, val, 0})
|
|
@@ -912,7 +924,7 @@ func extRegCoreToResult(extfrom, text string, tag *map[string]bool, j *ju.Job, v
|
|
|
extinfo[v.Field] = tmps
|
|
|
exfield := ju.ExtField{BlockTag: *tag, Field: v.Field, Code: v.Code + "去除__*后", RuleText: v.RuleText, Type: "regexp", MatchType: "regcontent", ExtFrom: extfrom, SourceValue: text, Value: value}
|
|
|
if tmp["blocktag"] != nil {
|
|
|
- exfield.BlockTag = tmp["blocktag"].(map[string]bool)
|
|
|
+ exfield.BlockTag = tmp["blocktag"].(map[string]string)
|
|
|
}
|
|
|
j.Result[v.Field] = append(j.Result[v.Field], &exfield)
|
|
|
//j.Result[k] = append(j.Result[k], &ju.ExtField{tmp["blocktag"].(map[string]bool), k, v.Code, v.RuleText, "regexp", "regcontent", extfrom, val, 0})
|
|
@@ -951,7 +963,7 @@ func extRegCoreToResult(extfrom, text string, tag *map[string]bool, j *ju.Job, v
|
|
|
}
|
|
|
field := &ju.ExtField{BlockTag: *tag, Field: v.Field, Code: v.Code, RuleText: v.RuleText, Type: "regexp", MatchType: "regcontent", ExtFrom: extfrom, SourceValue: text, Value: val}
|
|
|
if tmp["blocktag"] != nil {
|
|
|
- field.BlockTag = tmp["blocktag"].(map[string]bool)
|
|
|
+ field.BlockTag = tmp["blocktag"].(map[string]string)
|
|
|
}
|
|
|
j.Result[v.Field] = append(j.Result[v.Field], field)
|
|
|
}
|
|
@@ -975,7 +987,7 @@ func ExtRegBack(j *ju.Job, in *RegLuaInfo, t *TaskInfo) {
|
|
|
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"], Score: 0}
|
|
|
if tmp["blocktag"] != nil {
|
|
|
- field.BlockTag = tmp["blocktag"].(map[string]bool)
|
|
|
+ field.BlockTag = tmp["blocktag"].(map[string]string)
|
|
|
}
|
|
|
j.Result[k] = append(j.Result[k], field)
|
|
|
//j.Result[k] = append(j.Result[k], &ju.ExtField{tmp["blocktag"].(map[string]bool), k, qu.ObjToString(tmp["code"]), qu.ObjToString(tmp["ruletext"]), qu.ObjToString(tmp["type"]), qu.ObjToString(tmp["matchtype"]), qu.ObjToString(tmp["extfrom"]), tmp["value"], 0})
|