-
Notifications
You must be signed in to change notification settings - Fork 39
/
snowball.go
45 lines (39 loc) · 915 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
44
45
package snowball
import (
"fmt"
"github.com/kljensen/snowball/english"
"github.com/kljensen/snowball/french"
"github.com/kljensen/snowball/hungarian"
"github.com/kljensen/snowball/norwegian"
"github.com/kljensen/snowball/russian"
"github.com/kljensen/snowball/spanish"
"github.com/kljensen/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
case "hungarian":
f = hungarian.Stem
default:
err = fmt.Errorf("Unknown language: %s", language)
return
}
stemmed = f(word, stemStopWords)
return
}