photoprism/internal/ling/keywords.go
Michael Mayer f6d4e62ea8 Backend: Split up "util" package
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
2020-01-06 15:22:46 +01:00

23 lines
345 B
Go

package ling
import (
"regexp"
"strings"
)
var KeywordsRegexp = regexp.MustCompile("[\\p{L}]{3,}")
func Keywords(s string) (results []string) {
all := KeywordsRegexp.FindAllString(s, -1)
for _, w := range all {
w = strings.ToLower(w)
if _, ok := Stopwords[w]; ok == false {
results = append(results, w)
}
}
return results
}