MeCab binding for Go.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
cmd/mg
sample
.gitignore
.travis.yml
LICENSE.txt
README.md
args.go
args_test.go
error.go
generate.sh
install.sh
mecab.go
mecab_gen.go
mecab_gen_test.go
node.go
node_test.go
parser_gen.go
parser_gen_test.go

README.md

mecab-go Build Status Coverage Status

MeCab binding for Go.

Original

Environment

  • os: mac osx
  • mecab: install by homebrew

Install

go get github.com/yukihir0/mecab-go

Generate *_gen.go

*_gen.go is a generated file that is setuped cflags and ldflag for cgo.
It is a goal that can support multiple operating systems.

./generate.sh

How to use 1

input := "すもももももももものうち"

args := mecab.NewArgs()
args.DicDir = "/usr/local/Cellar/mecab/0.996/lib/mecab/dic/mecab-ipadic-neologd"
mecab.Initialize(args)

nodes, err := mecab.Parse(input)
if err != nil {
	panic(err)
}

for _, node := range nodes {
	fmt.Println(node.Surface)
}

How to use 2

input := "すもももももももものうち"

args := mecab.NewArgs()
args.DicDir = "/usr/local/Cellar/mecab/0.996/lib/mecab/dic/mecab-ipadic-neologd"
parser, err := mecab.InitializeParser(args)
if err != nil {
  panic(err)
}
defer parser.Release()

nodes, err := parser.Parse(input)
if err != nil {
	panic(err)
}

for _, node := range nodes {
	fmt.Println(node.Surface)
}

License

Copyright © 2015 yukihir0