-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
53 lines (46 loc) · 1.62 KB
/
options.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
50
51
52
53
package words
// Option defines the interface for
// applying options to the extraction
type Option func(c *config)
// IncludeSymbols includes symbols in the extraction. E.g. "beer>food" => []{"beer", ">", "food"}
func IncludeSymbols() Option {
return func(c *config) {
c.includeSymbols = true
}
}
// IncludePunctuation includes punctuation in extraction. E.g. "a.nested_path" => []{"a", ".", "nested", "-", "path"}
func IncludePunctuation() Option {
return func(c *config) {
c.includePunctuation = true
}
}
// IncludeSpaces includes spaces in the extraction. E.g. "the moon" => []{"the", " ", "moon"}
func IncludeSpaces() Option {
return func(c *config) {
c.includeSpaces = true
}
}
// AllowHyphenatedWords allows hyphenated words in the extraction.
// E.g. "a family-sized pizza" => []{"a", "family-sized", "pizza"}
func AllowHyphenatedWords() Option {
return func(c *config) {
c.allowHyphenatedWords = true
}
}
// WithIgnoredRunes tells the extractor to ignore these runes
// when they are encountered, simply adding them to the output
// as the rune was of most recent rune kind.
// E.g. => WithIgnoredRunes('.') "Etc. and so on" becomes => []{"Etc.", "and", "so", "on"}
func WithIgnoredRunes(runes ...rune) Option {
return func(c *config) {
c.ignoredRunes = append(c.ignoredRunes, runes...)
}
}
// WithIgnoredRuneKinds tells the extractor to ignore these rune kinds
// when they are encountered, simply adding them to the output
// as the rune was of most recent rune kind.
func WithIgnoredRuneKinds(runeKinds ...RuneKind) Option {
return func(c *config) {
c.ignoredRunesKinds = append(c.ignoredRunesKinds, runeKinds...)
}
}