Explorar el Código

没有匹配到段标签不打分

fengweiqiang hace 6 años
padre
commit
377a76093b
Se han modificado 1 ficheros con 122 adiciones y 122 borrados
  1. 122 122
      src/jy/extract/score.go

+ 122 - 122
src/jy/extract/score.go

@@ -16,7 +16,7 @@ var SoreConfig map[string]map[string]interface{}
 var TagConfig map[string]map[string]float64
 
 func init() {
-	qu.ReadConfig("./res/tagscore.json",&TagConfig)
+	qu.ReadConfig("./res/tagscore.json", &TagConfig)
 	qu.ReadConfig("./res/fieldscore.json", &SoreConfig)
 	//实例化正则
 	for _, tmp := range SoreConfig {
@@ -102,8 +102,8 @@ func ScoreFields(j *ju.Job) map[string][]*ju.ExtField {
 				tmps[tmpsindex].Score += 2 * qz //乘以权重系数
 			} else {
 				//没有段标签,走其他
-				qz := TagConfig["其他"][field]
-				tmps[tmpsindex].Score += 2 * qz //乘以权重系数
+				//qz := TagConfig["其他"][field]
+				//tmps[tmpsindex].Score += 2 * qz //乘以权重系数
 			}
 
 			//是否有kv值
@@ -199,7 +199,7 @@ func ScoreFields(j *ju.Job) map[string][]*ju.ExtField {
 				}
 			}
 			//5.数据范围打分
-			if scoreRule["type"] == "float"  {
+			if scoreRule["type"] == "float" {
 				min := qu.IntAll(scoreRule["min"])
 				max := qu.IntAll(scoreRule["max"])
 				val := qu.IntAll(tmpsvalue.Value)
@@ -242,126 +242,126 @@ func ScoreFields(j *ju.Job) map[string][]*ju.ExtField {
 	//		if scoreRule == nil {
 	//			continue
 	//		}
-			//extractype := SoreConfig["extractype"]
-			//fieldtype := scoreRule["type"]
+	//extractype := SoreConfig["extractype"]
+	//fieldtype := scoreRule["type"]
 	//		for _, v := range tmps {
 	//			fmt.Println(v)
-				//	if len(fmt.Sprint(v.Value)) < 1 {
-				//		continue //空串跳过
-				//	}
-				//	//长度超过100个字,直接负分
-				//	vlen := len([]rune(qu.ObjToString(v.Value)))
-				//	if vlen > 100 && field != "projectscope" {
-				//		v.Score = -1
-				//	} else {
-				//		//类型打分
-				//		if v.ExtFrom == "title" {
-				//			v.Score += qu.IntAll(extractype["title"])
-				//		} else {
-				//			if strings.Contains(v.Type, "table") {
-				//				v.Score += qu.IntAll(extractype["table"])
-				//			} else if strings.Contains(v.Type, "colon") {
-				//				v.Score += qu.IntAll(extractype["colon"])
-				//			} else if strings.Contains(v.Type, "space") {
-				//				v.Score += qu.IntAll(extractype["space"])
-				//			} else if strings.Contains(v.Type, "regexp") {
-				//				v.Score += qu.IntAll(extractype["regexp"])
-				//			} else if strings.Contains(v.Type, "winnerorder") {
-				//				v.Score += qu.IntAll(extractype["winnerorder"])
-				//			}
-				//		}
-				//		//字符型打分
-				//		if fieldtype == "string" {
-				//			//位置打分
-				//			if positions, ok := scoreRule["position"].([]interface{}); ok {
-				//				for _, position := range positions {
-				//					if p, ok := position.(map[string]interface{}); ok {
-				//						qu.Try(func() {
-				//							if p["regexp"] != nil {
-				//								reg := p["regexp"].(*regexp.Regexp)
-				//								if reg.MatchString(qu.ObjToString(v.Value)) {
-				//									v.Score += qu.IntAll(p["score"])
-				//								}
-				//							}
-				//						}, func(err interface{}) {
-				//							log.Println(err)
-				//						})
-				//					}
-				//				}
-				//			}
-				//			//长度打分
-				//			if lengths, ok := scoreRule["length"].([]interface{}); ok {
-				//				for _, tmp := range lengths {
-				//					if length, ok := tmp.(map[string]interface{}); ok {
-				//						min := qu.IntAll(length["min"])
-				//						max := qu.IntAll(length["max"])
-				//						scores, _ := length["score"].([]interface{})
-				//						if len(scores) < 3 {
-				//							continue
-				//						}
-				//						if vlen < min {
-				//							v.Score += qu.IntAll(scores[0])
-				//						} else if vlen > max {
-				//							v.Score += qu.IntAll(scores[2])
-				//						} else {
-				//							v.Score += qu.IntAll(scores[1])
-				//						}
-				//					}
-				//				}
-				//			}
-				//			//
-				//			if winnerorders, ok := scoreRule["winnerorder"].([]interface{}); ok {
-				//				for _, winnerorder := range winnerorders {
-				//					if p, ok := winnerorder.(map[string]interface{}); ok {
-				//						qu.Try(func() {
-				//							if p["regexp"] != nil {
-				//								reg := p["regexp"].(*regexp.Regexp)
-				//								if reg.MatchString(qu.ObjToString(v.Value)) {
-				//									v.Score += qu.IntAll(p["score"])
-				//								}
-				//							}
-				//						}, func(err interface{}) {
-				//							log.Println(err)
-				//						})
-				//					}
-				//				}
-				//			}
-				//		}
-				//		//float类型打分
-				//		if fieldtype == "float" {
-				//			min := qu.IntAll(scoreRule["min"])
-				//			max := qu.IntAll(scoreRule["max"])
-				//			val := qu.IntAll(v.Value)
-				//			scores, _ := scoreRule["score"].([]interface{})
-				//			if len(scores) < 3 {
-				//				continue
-				//			}
-				//			if val < min && 0 < val {
-				//				v.Score += qu.IntAll(scores[0])
-				//			} else if val > max {
-				//				v.Score += qu.IntAll(scores[2])
-				//			} else if val <= max && val >= min {
-				//				v.Score += qu.IntAll(scores[1])
-				//			}
-				//		}
-				//		//decimal
-				//		if fieldtype == "decimal" {
-				//			min := qu.IntAll(scoreRule["min"])
-				//			max := qu.IntAll(scoreRule["max"])
-				//			val := qu.IntAll(v.Value)
-				//			scores, _ := scoreRule["score"].([]interface{})
-				//			if len(scores) < 3 {
-				//				continue
-				//			}
-				//			if val > max {
-				//				v.Score += qu.IntAll(scores[2])
-				//			} else if val <= max && val > min {
-				//				v.Score += qu.IntAll(scores[1])
-				//			}
-				//		}
-				//	}
-			//}
-		//}
+	//	if len(fmt.Sprint(v.Value)) < 1 {
+	//		continue //空串跳过
+	//	}
+	//	//长度超过100个字,直接负分
+	//	vlen := len([]rune(qu.ObjToString(v.Value)))
+	//	if vlen > 100 && field != "projectscope" {
+	//		v.Score = -1
+	//	} else {
+	//		//类型打分
+	//		if v.ExtFrom == "title" {
+	//			v.Score += qu.IntAll(extractype["title"])
+	//		} else {
+	//			if strings.Contains(v.Type, "table") {
+	//				v.Score += qu.IntAll(extractype["table"])
+	//			} else if strings.Contains(v.Type, "colon") {
+	//				v.Score += qu.IntAll(extractype["colon"])
+	//			} else if strings.Contains(v.Type, "space") {
+	//				v.Score += qu.IntAll(extractype["space"])
+	//			} else if strings.Contains(v.Type, "regexp") {
+	//				v.Score += qu.IntAll(extractype["regexp"])
+	//			} else if strings.Contains(v.Type, "winnerorder") {
+	//				v.Score += qu.IntAll(extractype["winnerorder"])
+	//			}
+	//		}
+	//		//字符型打分
+	//		if fieldtype == "string" {
+	//			//位置打分
+	//			if positions, ok := scoreRule["position"].([]interface{}); ok {
+	//				for _, position := range positions {
+	//					if p, ok := position.(map[string]interface{}); ok {
+	//						qu.Try(func() {
+	//							if p["regexp"] != nil {
+	//								reg := p["regexp"].(*regexp.Regexp)
+	//								if reg.MatchString(qu.ObjToString(v.Value)) {
+	//									v.Score += qu.IntAll(p["score"])
+	//								}
+	//							}
+	//						}, func(err interface{}) {
+	//							log.Println(err)
+	//						})
+	//					}
+	//				}
+	//			}
+	//			//长度打分
+	//			if lengths, ok := scoreRule["length"].([]interface{}); ok {
+	//				for _, tmp := range lengths {
+	//					if length, ok := tmp.(map[string]interface{}); ok {
+	//						min := qu.IntAll(length["min"])
+	//						max := qu.IntAll(length["max"])
+	//						scores, _ := length["score"].([]interface{})
+	//						if len(scores) < 3 {
+	//							continue
+	//						}
+	//						if vlen < min {
+	//							v.Score += qu.IntAll(scores[0])
+	//						} else if vlen > max {
+	//							v.Score += qu.IntAll(scores[2])
+	//						} else {
+	//							v.Score += qu.IntAll(scores[1])
+	//						}
+	//					}
+	//				}
+	//			}
+	//			//
+	//			if winnerorders, ok := scoreRule["winnerorder"].([]interface{}); ok {
+	//				for _, winnerorder := range winnerorders {
+	//					if p, ok := winnerorder.(map[string]interface{}); ok {
+	//						qu.Try(func() {
+	//							if p["regexp"] != nil {
+	//								reg := p["regexp"].(*regexp.Regexp)
+	//								if reg.MatchString(qu.ObjToString(v.Value)) {
+	//									v.Score += qu.IntAll(p["score"])
+	//								}
+	//							}
+	//						}, func(err interface{}) {
+	//							log.Println(err)
+	//						})
+	//					}
+	//				}
+	//			}
+	//		}
+	//		//float类型打分
+	//		if fieldtype == "float" {
+	//			min := qu.IntAll(scoreRule["min"])
+	//			max := qu.IntAll(scoreRule["max"])
+	//			val := qu.IntAll(v.Value)
+	//			scores, _ := scoreRule["score"].([]interface{})
+	//			if len(scores) < 3 {
+	//				continue
+	//			}
+	//			if val < min && 0 < val {
+	//				v.Score += qu.IntAll(scores[0])
+	//			} else if val > max {
+	//				v.Score += qu.IntAll(scores[2])
+	//			} else if val <= max && val >= min {
+	//				v.Score += qu.IntAll(scores[1])
+	//			}
+	//		}
+	//		//decimal
+	//		if fieldtype == "decimal" {
+	//			min := qu.IntAll(scoreRule["min"])
+	//			max := qu.IntAll(scoreRule["max"])
+	//			val := qu.IntAll(v.Value)
+	//			scores, _ := scoreRule["score"].([]interface{})
+	//			if len(scores) < 3 {
+	//				continue
+	//			}
+	//			if val > max {
+	//				v.Score += qu.IntAll(scores[2])
+	//			} else if val <= max && val > min {
+	//				v.Score += qu.IntAll(scores[1])
+	//			}
+	//		}
+	//	}
+	//}
+	//}
 	//}, func(err interface{}) {
 	//	log.Println("ScoreFields err", err)
 	//})