๐Ÿ“š shamoji - Awesome Go Library for Natural Language Processing

Go Gopher mascot for shamoji

The shamoji is word filtering package written in Go.

๐Ÿท๏ธ Natural Language Processing
๐Ÿ“‚ Libraries for working with human languages.
โญ 13 stars
View on GitHub ๐Ÿ”—

Detailed Description of shamoji

shamoji

GitHub Actions codecov Go Report Card codebeat badge GoDoc GitHub license

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.