1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- package main
- import (
- "fmt"
- qu "qfw/util"
- "unicode/utf8"
- )
- 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 !isTest && !buyerNameIsExists(buyer) {
- desc = "单位库"
- reason+="~"+desc
- score -= qu.Int64All(buyer_score[desc])
- }
- if isUnHan(buyer){
- desc = "非纯中文"
- reason+="~"+desc
- score -= qu.Int64All(buyer_score[desc])
- }
- if specHeadReg.MatchString(buyer) || !unHanHeadReg.MatchString(buyer) {
- desc = "前缀校验"
- reason+="~"+desc
- score -= qu.Int64All(buyer_score[desc])
- }
- if unConReg.MatchString(buyer) || unEndReg.MatchString(buyer) {
- if unenableReg1.MatchString(buyer) || unenableReg2.MatchString(buyer) {
- desc = "黑名单"
- reason+="~"+desc
- score -= qu.Int64All(buyer_score[desc])
- }
- }else {
- desc = "后缀校验"
- reason+="~"+desc
- score -= qu.Int64All(buyer_score[desc])
- }
- //与其他单位比对
- if buyer==agency || buyer==winner {
- desc = "单位对比"
- reason+="~"+desc
- score -= qu.Int64All(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
- score -= qu.Int64All(buyer_score[desc])
- }
- }
- return map[string]interface{}{
- "score":score,
- "reason":reason,
- }
- }
|