photoprism/internal/util/keywords.go
Michael Mayer f92c21aef9 Indexer: Improve labels
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
2019-12-13 03:07:26 +01:00

22 lines
348 B
Go

package util
import (
"regexp"
"strings"
)
var KeywordsRegexp = regexp.MustCompile("[\\p{L}\\d]{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
}