mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
24 lines
567 B
Go
24 lines
567 B
Go
package torrsearch
|
|
|
|
import (
|
|
"strings"
|
|
"unicode"
|
|
)
|
|
|
|
// tokenize returns a slice of tokens for the given text.
|
|
func tokenize(text string) []string {
|
|
return strings.FieldsFunc(text, func(r rune) bool {
|
|
// Split on any character that is not a letter or a number.
|
|
return !unicode.IsLetter(r) && !unicode.IsNumber(r)
|
|
})
|
|
}
|
|
|
|
// analyze analyzes the text and returns a slice of tokens.
|
|
func analyze(text string) []string {
|
|
tokens := tokenize(text)
|
|
tokens = lowercaseFilter(tokens)
|
|
tokens = stopwordFilter(tokens)
|
|
//tokens = stemmerFilter(tokens)
|
|
return tokens
|
|
}
|