scoreprojectname.go 946 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package main
  2. import (
  3. "fmt"
  4. qu "qfw/util"
  5. "unicode/utf8"
  6. )
  7. func projectnameFieldScore(tmp map[string]interface{},score int64) (map[string]interface{}) {
  8. projectname := qu.ObjToString(tmp["projectname"])
  9. reason,desc:=fmt.Sprintf("%d初始分",score),""
  10. /*错误项*/
  11. if utf8.RuneCountInString(projectname) <= 6 {
  12. return map[string]interface{}{
  13. "score":int64(0),
  14. "reason":"错误:长度",
  15. }
  16. }
  17. if !isHan(projectname) {
  18. return map[string]interface{}{
  19. "score":int64(0),
  20. "reason":"错误:无中文",
  21. }
  22. }
  23. /*减分项
  24. "长度过长":1,
  25. "中文比例": 2
  26. */
  27. if utf8.RuneCountInString(projectname) >= 40 {
  28. desc = "长度过长"
  29. reason+="~"+desc
  30. score -= qu.Int64All(projectname_score[desc])
  31. }
  32. if !isHanLenToLittle(projectname) {
  33. desc = "中文比例"
  34. reason+="~"+desc
  35. score -= qu.Int64All(projectname_score[desc])
  36. }
  37. return map[string]interface{}{
  38. "score":score,
  39. "reason":reason,
  40. }
  41. }