scorebuyer.go 2.0 KB

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