-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgengen.go
49 lines (41 loc) · 1.3 KB
/
gengen.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
46
47
48
49
// +build ignore
package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
)
// tool to generate the go generate commands
var excludeAlgorithms = map[string]struct{}{
"german2": struct{}{},
"kraaij_pohlmann": struct{}{},
"lovins": struct{}{},
}
func main() {
flag.Parse()
if flag.NArg() < 1 {
log.Fatal("must specify algorithms directory")
}
files, err := ioutil.ReadDir(flag.Arg(0))
if err != nil {
log.Fatal(err)
}
for _, file := range files {
if _, ok := excludeAlgorithms[file.Name()]; ok {
continue
}
if _, err = os.Stat(filepath.Join(flag.Arg(0), file.Name(), "stem_Unicode.sbl")); err == nil {
fmt.Printf("//go:generate $SNOWBALL/snowball $SNOWBALL/algorithms/%s/stem_Unicode.sbl -go -o %s/%s_stemmer -gop %s -gor github.com/blevesearch/snowballstem\n",
file.Name(), file.Name(), file.Name(), file.Name())
} else if _, err = os.Stat(filepath.Join(flag.Arg(0), file.Name(), "stem_ISO_8859_1.sbl")); err == nil {
fmt.Printf("//go:generate $SNOWBALL/snowball $SNOWBALL/algorithms/%s/stem_ISO_8859_1.sbl -go -o %s/%s_stemmer -gop %s -gor github.com/blevesearch/snowballstem\n",
file.Name(), file.Name(), file.Name(), file.Name())
}
fmt.Printf("//go:generate gofmt -s -w %s/%s_stemmer.go\n",
file.Name(), file.Name())
fmt.Println()
}
}