2020-08-05 17:14:10 +00:00
|
|
|
package main
|
|
|
|
|
2020-09-01 16:53:21 +00:00
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2020-08-05 17:14:10 +00:00
|
|
|
type stringSlice []string
|
|
|
|
|
|
|
|
func (s stringSlice) has(value string) bool {
|
|
|
|
for _, v := range s {
|
|
|
|
if v == value {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
2020-09-01 16:53:21 +00:00
|
|
|
|
|
|
|
func urlize(str string) string {
|
|
|
|
newStr := ""
|
|
|
|
for _, c := range strings.Split(strings.ToLower(str), "") {
|
|
|
|
if c >= "a" && c <= "z" || c >= "A" && c <= "Z" || c >= "0" && c <= "9" {
|
|
|
|
newStr += c
|
|
|
|
} else if c == " " {
|
|
|
|
newStr += "-"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return newStr
|
|
|
|
}
|
2020-09-15 15:01:53 +00:00
|
|
|
|
|
|
|
func firstSentences(value string, count int) string {
|
|
|
|
for i := range value {
|
|
|
|
if value[i] == '.' || value[i] == '!' || value[i] == '?' {
|
|
|
|
count -= 1
|
|
|
|
if count == 0 && i < len(value) {
|
|
|
|
return value[0 : i+1]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return value
|
|
|
|
}
|