scorebuyer.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. package qua
  2. import (
  3. "fmt"
  4. qu "qfw/util"
  5. "unicode/utf8"
  6. u "util"
  7. )
  8. func BuyerFieldScore(tmp map[string]interface{},score int64) (map[string]interface{}) {
  9. buyer := qu.ObjToString(tmp["buyer"])
  10. agency := qu.ObjToString(tmp["agency"])
  11. winner := qu.ObjToString(tmp["winner"])
  12. reason,desc:=fmt.Sprintf("%d初始分",score),""
  13. /*错误项*/
  14. if utf8.RuneCountInString(buyer) < 4 || !isHan(buyer) ||
  15. utf8.RuneCountInString(buyer) >= 20{
  16. return map[string]interface{}{
  17. "score":int64(0),
  18. "reason":"错误:长度",
  19. }
  20. }
  21. countArr := isCharCount(buyer)
  22. if countArr[0] < 4 {
  23. return map[string]interface{}{
  24. "score":int64(0),
  25. "reason":"错误:中文少",
  26. }
  27. }
  28. /*减分项
  29. "单位库": 1,
  30. "前缀校验": 1,
  31. "后缀校验": 1,
  32. "非纯中文": 1,
  33. "切词": 2,
  34. "单位对比": 2,
  35. "黑名单":2
  36. */
  37. if !buyerNameIsExists(buyer) {
  38. desc = "单位库"
  39. reason+="~"+desc + fmt.Sprintf("-%d",qu.Int64All(u.Buyer_Score[desc]))
  40. score -= qu.Int64All(u.Buyer_Score[desc])
  41. }
  42. if isUnHan(buyer){
  43. desc = "非纯中文"
  44. reason+="~"+desc + fmt.Sprintf("-%d",qu.Int64All(u.Buyer_Score[desc]))
  45. score -= qu.Int64All(u.Buyer_Score[desc])
  46. }
  47. if specHeadReg.MatchString(buyer) || !unHanHeadReg.MatchString(buyer) {
  48. desc = "前缀校验"
  49. reason+="~"+desc + fmt.Sprintf("-%d",qu.Int64All(u.Buyer_Score[desc]))
  50. score -= qu.Int64All(u.Buyer_Score[desc])
  51. }
  52. if unConReg.MatchString(buyer) || unEndReg.MatchString(buyer) {
  53. if unenableReg1.MatchString(buyer) || unenableReg2.MatchString(buyer) {
  54. desc = "黑名单"
  55. reason+="~"+desc + fmt.Sprintf("-%d",qu.Int64All(u.Buyer_Score[desc]))
  56. score -= qu.Int64All(u.Buyer_Score[desc])
  57. }
  58. }else {
  59. desc = "后缀校验"
  60. reason+="~"+desc + fmt.Sprintf("-%d",qu.Int64All(u.Buyer_Score[desc]))
  61. score -= qu.Int64All(u.Buyer_Score[desc])
  62. }
  63. //与其他单位比对
  64. if buyer==agency || buyer==winner {
  65. desc = "单位对比"
  66. reason+="~"+desc + fmt.Sprintf("-%d",qu.Int64All(u.Buyer_Score[desc]))
  67. score -= qu.Int64All(u.Buyer_Score[desc])
  68. }
  69. //切词首部比对-
  70. buyer_jb_arr := GSE.Cut(buyer, true)
  71. if len(buyer_jb_arr)>0 && buyer_jb_arr!=nil {
  72. head_char := qu.ObjToString(buyer_jb_arr[0])
  73. if utf8.RuneCountInString(head_char) == 1{
  74. desc = "切词"
  75. reason+="~"+desc + fmt.Sprintf("-%d",qu.Int64All(u.Buyer_Score[desc]))
  76. score -= qu.Int64All(u.Buyer_Score[desc])
  77. }
  78. }
  79. return map[string]interface{}{
  80. "score":score,
  81. "reason":reason,
  82. }
  83. }