mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
add rutor api
This commit is contained in:
23
server/rutor/torrsearch/tokenizer.go
Normal file
23
server/rutor/torrsearch/tokenizer.go
Normal file
@@ -0,0 +1,23 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user