scoreMethod.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package main
  2. import (
  3. "regexp"
  4. "time"
  5. "unicode"
  6. )
  7. func isPlaceAddr(str string) bool {
  8. if isTelephone(str) {
  9. return false
  10. }
  11. regx,_ := regexp.Compile(specialaddr)
  12. result:=regx.FindString(str)
  13. if result !="" {
  14. return true
  15. }
  16. return false
  17. }
  18. func isTimestamp(i int64) bool {
  19. now:=time.Now().Unix()
  20. if i<now+86400*180 {
  21. return true
  22. }
  23. return false
  24. }
  25. func isTelephone(str string) bool {
  26. reg1:=`^1[3|4|5|6|7|8|9][0-9]\d{8}$`
  27. regx1,_ := regexp.Compile(reg1)
  28. arr1:=regx1.FindAllString(str,-1)
  29. if len(arr1)>0 {
  30. return true
  31. }
  32. reg2:=`^(\d{2,4}-)?\d{7,8}$`
  33. regx2,_ := regexp.Compile(reg2)
  34. arr2:=regx2.FindAllString(str,-1)
  35. if len(arr2)>0 {
  36. return true
  37. }
  38. return false
  39. }
  40. func isChinese(str string) bool {
  41. var count int
  42. for _, v := range str {
  43. if unicode.Is(unicode.Han, v) {
  44. count++
  45. break
  46. }
  47. }
  48. return count > 0
  49. }
  50. func isChineseChar(str string) bool {
  51. for _, r := range str {
  52. if unicode.Is(unicode.Scripts["Han"], r) || (regexp.MustCompile("[\u3002\uff1b\uff0c\uff1a\u201c\u201d\uff08\uff09\u3001\uff1f\u300a\u300b]").MatchString(string(r))) {
  53. return true
  54. }
  55. }
  56. return false
  57. }