123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- package main
- import (
- "fmt"
- qu "qfw/util"
- "strings"
- "unicode/utf8"
- )
- func winnerFieldScore(tmp map[string]interface{},score int64) (map[string]interface{}) {
- s_winner := qu.ObjToString(tmp["s_winner"])
- buyer := qu.ObjToString(tmp["buyer"])
- agency := qu.ObjToString(tmp["agency"])
- package_map:=*qu.ObjToMap(tmp["package"])
- reason,desc:=fmt.Sprintf("%d初始分",score),""
- s_winner_arr := strings.Split(s_winner,",")
- if len(s_winner_arr)!=len(package_map) && len(package_map)>0 {
- desc = "分包量"
- reason+="~"+desc
- score -= qu.Int64All(s_winner_score[desc])
- }
- for _,winner:=range s_winner_arr{
- /*错误项*/
- if utf8.RuneCountInString(winner) < 4 || !isHan(winner) ||
- utf8.RuneCountInString(winner) > 20{
- return map[string]interface{}{
- "score":int64(0),
- "reason":"错误",
- }
- }
- countArr := isCharCount(winner)
- if countArr[0] < 4 {
- return map[string]interface{}{
- "score":int64(0),
- "reason":"错误:中文少",
- }
- }
- /*减分项
- "单位库": 1,
- "前缀校验": 1,
- "后缀校验": 1,
- "非纯中文": 1,
- "分包量": 1,
- "切词": 2,
- "单位对比": 2,
- "黑名单": 2
- */
- if !isTest && !qyNameIsExistsQYXY(winner){
- desc = "单位库"
- reason+="~"+desc
- score -= qu.Int64All(s_winner_score[desc])
- }
- if isUnHan(winner){
- desc = "非纯中文"
- reason+="~"+desc
- score -= qu.Int64All(s_winner_score[desc])
- }
- if specHeadReg.MatchString(winner) || !unHanHeadReg.MatchString(winner) {
- desc = "前缀校验"
- reason+="~"+desc
- score -= qu.Int64All(s_winner_score[desc])
- }
- if unConReg.MatchString(winner) || unEndReg.MatchString(winner) {
- if unenableReg1.MatchString(winner) || unenableReg2.MatchString(winner) {
- desc = "黑名单"
- reason+="~"+desc
- score -= qu.Int64All(s_winner_score[desc])
- }
- }else {
- desc = "后缀校验"
- reason+="~"+desc
- score -= qu.Int64All(s_winner_score[desc])
- }
- if (winner==agency || winner==buyer) && winner !="" {
- desc = "单位对比"
- reason+="~"+desc
- score -= qu.Int64All(s_winner_score[desc])
- }
- //切词首部比对-影响性能
- winner_jb_arr := GSE.Cut(winner, true)
- if len(winner_jb_arr)>0 && winner_jb_arr!=nil {
- head_char := qu.ObjToString(winner_jb_arr[0])
- if utf8.RuneCountInString(head_char) == 1{
- desc = "切词"
- reason+="~"+desc
- score -= qu.Int64All(s_winner_score[desc])
- }
- }
- }
- return map[string]interface{}{
- "score":score,
- "reason":reason,
- }
- }
|