scoreprojectname.go 854 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package main
  2. import (
  3. qu "qfw/util"
  4. "unicode/utf8"
  5. )
  6. func projectnameFieldScore(tmp map[string]interface{}) (map[string]interface{}) {
  7. projectname := qu.ObjToString(tmp["projectname"])
  8. score := int64(100)
  9. reason:=""
  10. /*错误项*/
  11. if utf8.RuneCountInString(projectname) <= 6 || !isHan(projectname) {
  12. return map[string]interface{}{
  13. "score":int64(0),
  14. "reason":"错误项",
  15. }
  16. }
  17. /*减分项*/
  18. //长度过长
  19. if utf8.RuneCountInString(projectname) >= 25 {
  20. reason+="~过长-1"
  21. score -= 1
  22. }
  23. //标题切词与名称比对-待开发
  24. //符号数量
  25. countArr := isCharCount(projectname)
  26. if countArr[3] > 3 {
  27. reason+="~符号-2"
  28. score -= 2
  29. }
  30. //中文-长度-比例
  31. if !isHanLenToLittle(projectname) {
  32. reason+="~中文比例-2"
  33. score -= 2
  34. }
  35. return map[string]interface{}{
  36. "score":score,
  37. "reason":reason,
  38. }
  39. }