Skip to content
The shamoji (杓文字) is word filtering package
Go
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Create FUNDING.yml Sep 11, 2019
filter Remove global variable Jan 7, 2019
tokenizer Rename KagomeTokenizer to KagomeSimpleTokenizer Jul 26, 2017
.gitignore Use go modules Sep 11, 2019
.golangci.yml Move linter to golanci-lint Jan 7, 2019
.travis.yml Edit .travis.yml Sep 11, 2019
LICENSE Add LICENSE Jul 25, 2017
README.md
codecov.yml Update testing Jul 25, 2017
go.mod
go.sum Use go modules Sep 11, 2019
shamoji.go
shamoji_test.go Refactor tests and example Aug 3, 2017

README.md

shamoji

Travis branch codecov Go Report Card codebeat badge GoDoc GitHub license

About

The shamoji (杓文字) is word filtering package.

Install

$ go get -u github.com/osamingo/shamoji

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() {
		s = &shamoji.Serve{
			Tokenizer: tokenizer.NewKagomeSimpleTokenizer(norm.NFKC),
			Filer:     filter.NewCuckooFilter("涯に", "悔い"),
		}
	})
	return s.Do(sentence)
}

License

Released under the MIT License.

You can’t perform that action at this time.