MeCab binding for Go.
- os: mac osx
- mecab: install by homebrew
go get github.com/yukihir0/mecab-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
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)
}
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)
}
Copyright © 2015 yukihir0