Awesome Go

shamoji

CategoryNatural Language Processing
SubcategoryTokenizers
Stars0

The shamoji is word filtering package written in Go

About shamoji

shamoji

CI 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.

Frequently Asked Questions

What is shamoji?

shamoji is a Natural Language Processing library for the Go programming language. The shamoji is word filtering package written in Go

How do I install shamoji?

Install shamoji with the Go module system using `go get osamingo/shamoji`. Check the repository for the current installation instructions.

What category does shamoji belong to?

shamoji is listed under Natural Language Processing, specifically Tokenizers.

← Back to Tokenizers