README ¶ shamoji About The shamoji (杓文字) is word filtering package. Install $ go get github.com/osamingo/shamoji@latest Usage package main import ( "fmt" "sync" "github.com/osamingo/shamoji" "github.com/osamingo/shamoji/filter" "github.com/osamingo/shamoji/tokenizer" "golang.org/x/text/unicode/norm" ) var ( o sync.Once s *shamoji.Serve ) func main() { yes, word := Contains("我が生涯に一片の悔い無し") fmt.Printf("Result: %v, Word: %s", yes, word) } func Contains(sentence string) (bool, string) { o.Do(func() { tok, err := tokenizer.NewKagomeTokenizer(norm.NFKC) if err != nil { panic(err) } s = &shamoji.Serve{ Tokenizer: tok, Filer: filter.NewCuckooFilter("涯に", "悔い"), } }) return s.Do(sentence) } License Released under the MIT License. Expand ▾ Collapse ▴ Documentation ¶ Index ¶ type Filter type Serve func (s *Serve) Do(sentence string) (bool, string) func (s *Serve) DoAsync(ctx context.Context, sentence string) (bool, string) type Tokenizer Constants ¶ This section is empty. Variables ¶ This section is empty. Functions ¶ This section is empty. Types ¶ type Filter ¶ type Filter interface { Test(src []byte) (result bool) } Filter implements Test method. type Serve ¶ type Serve struct { Tokenizer Tokenizer Filer Filter } Serve has Tokenizer and Filter interfaces. func (*Serve) Do ¶ func (s *Serve) Do(sentence string) (bool, string) Do filtering sentence. func (*Serve) DoAsync ¶ func (s *Serve) DoAsync(ctx context.Context, sentence string) (bool, string) DoAsync filtering sentence. type Tokenizer ¶ type Tokenizer interface { Tokenize(sentence string) (tokens [][]byte) } Tokenizer implements Tokenize method. Source Files ¶ View all Source files shamoji.go Directories ¶ Show internal Expand all Path Synopsis filter tokenizer Click to show internal directories. Click to hide internal directories.