scorewinner.go 2.4 KB

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