2021-08-31 18:49:08 +02:00
|
|
|
//go:build ignore
|
2019-12-10 16:58:01 +01:00
|
|
|
// +build ignore
|
|
|
|
|
|
|
|
// This generates stopwords.go by running "go generate"
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bufio"
|
|
|
|
"io"
|
2019-12-11 14:10:20 +01:00
|
|
|
"os"
|
2019-12-10 16:58:01 +01:00
|
|
|
"text/template"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
file, err := os.Open("./resources/stopwords.txt")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
defer file.Close()
|
|
|
|
|
|
|
|
reader := bufio.NewReader(file)
|
|
|
|
words := []string{}
|
|
|
|
|
|
|
|
for {
|
|
|
|
line, _, err := reader.ReadLine()
|
|
|
|
|
|
|
|
if err == io.EOF {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
words = append(words, string(line))
|
|
|
|
}
|
|
|
|
|
|
|
|
f, err := os.Create("stopwords.go")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
defer f.Close()
|
|
|
|
|
|
|
|
packageTemplate.Execute(f, struct {
|
|
|
|
Words []string
|
|
|
|
}{
|
|
|
|
Words: words,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-04-25 09:53:55 +02:00
|
|
|
var packageTemplate = template.Must(template.New("").Parse(`
|
2020-01-12 14:00:56 +01:00
|
|
|
package txt
|
2019-12-10 16:58:01 +01:00
|
|
|
|
2022-04-25 09:53:55 +02:00
|
|
|
// Generated code, do not edit.
|
|
|
|
|
2020-06-24 07:38:08 +02:00
|
|
|
// StopWords contains a list of stopwords for full-text indexing.
|
|
|
|
var StopWords = map[string]bool{
|
2019-12-10 16:58:01 +01:00
|
|
|
{{- range .Words }}
|
|
|
|
{{ printf "%q" . }}: true,
|
|
|
|
{{- end }}
|
|
|
|
}`))
|