forked from kljensen/snowball
-
Notifications
You must be signed in to change notification settings - Fork 1
/
snowball.go
43 lines (37 loc) · 854 Bytes
/
snowball.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package snowball
import (
"fmt"
"github.com/blevesearch/snowball/english"
"github.com/blevesearch/snowball/french"
"github.com/blevesearch/snowball/norwegian"
"github.com/blevesearch/snowball/russian"
"github.com/blevesearch/snowball/spanish"
"github.com/blevesearch/snowball/swedish"
)
const (
VERSION string = "v0.7.0"
)
// Stem a word in the specified language.
//
func Stem(word, language string, stemStopWords bool) (stemmed string, err error) {
var f func(string, bool) string
switch language {
case "english":
f = english.Stem
case "spanish":
f = spanish.Stem
case "french":
f = french.Stem
case "russian":
f = russian.Stem
case "swedish":
f = swedish.Stem
case "norwegian":
f = norwegian.Stem
default:
err = fmt.Errorf("Unknown language: %s", language)
return
}
stemmed = f(word, stemStopWords)
return
}