123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- package qua
- import (
- "fmt"
- qu "qfw/util"
- "unicode/utf8"
- u "util"
- )
- func BuyerFieldScore(tmp map[string]interface{},score int64) (map[string]interface{}) {
- buyer := qu.ObjToString(tmp["buyer"])
- agency := qu.ObjToString(tmp["agency"])
- winner := qu.ObjToString(tmp["winner"])
- reason,desc:=fmt.Sprintf("%d初始分",score),""
- /*错误项*/
- if utf8.RuneCountInString(buyer) < 4 || !isHan(buyer) ||
- utf8.RuneCountInString(buyer) >= 20{
- return map[string]interface{}{
- "score":int64(0),
- "reason":"错误:长度",
- }
- }
- countArr := isCharCount(buyer)
- if countArr[0] < 4 {
- return map[string]interface{}{
- "score":int64(0),
- "reason":"错误:中文少",
- }
- }
- /*减分项
- "单位库": 1,
- "前缀校验": 1,
- "后缀校验": 1,
- "非纯中文": 1,
- "切词": 2,
- "单位对比": 2,
- "黑名单":2
- */
- if !buyerNameIsExists(buyer) {
- desc = "单位库"
- reason+="~"+desc + fmt.Sprintf("-%d",qu.Int64All(u.Buyer_Score[desc]))
- score -= qu.Int64All(u.Buyer_Score[desc])
- }
- if isUnHan(buyer){
- desc = "非纯中文"
- reason+="~"+desc + fmt.Sprintf("-%d",qu.Int64All(u.Buyer_Score[desc]))
- score -= qu.Int64All(u.Buyer_Score[desc])
- }
- if specHeadReg.MatchString(buyer) || !unHanHeadReg.MatchString(buyer) {
- desc = "前缀校验"
- reason+="~"+desc + fmt.Sprintf("-%d",qu.Int64All(u.Buyer_Score[desc]))
- score -= qu.Int64All(u.Buyer_Score[desc])
- }
- if unConReg.MatchString(buyer) || unEndReg.MatchString(buyer) {
- if unenableReg1.MatchString(buyer) || unenableReg2.MatchString(buyer) {
- desc = "黑名单"
- reason+="~"+desc + fmt.Sprintf("-%d",qu.Int64All(u.Buyer_Score[desc]))
- score -= qu.Int64All(u.Buyer_Score[desc])
- }
- }else {
- desc = "后缀校验"
- reason+="~"+desc + fmt.Sprintf("-%d",qu.Int64All(u.Buyer_Score[desc]))
- score -= qu.Int64All(u.Buyer_Score[desc])
- }
- //与其他单位比对
- if buyer==agency || buyer==winner {
- desc = "单位对比"
- reason+="~"+desc + fmt.Sprintf("-%d",qu.Int64All(u.Buyer_Score[desc]))
- score -= qu.Int64All(u.Buyer_Score[desc])
- }
- //切词首部比对-
- buyer_jb_arr := GSE.Cut(buyer, true)
- if len(buyer_jb_arr)>0 && buyer_jb_arr!=nil {
- head_char := qu.ObjToString(buyer_jb_arr[0])
- if utf8.RuneCountInString(head_char) == 1{
- desc = "切词"
- reason+="~"+desc + fmt.Sprintf("-%d",qu.Int64All(u.Buyer_Score[desc]))
- score -= qu.Int64All(u.Buyer_Score[desc])
- }
- }
- return map[string]interface{}{
- "score":score,
- "reason":reason,
- }
- }
|