示例#1
0
func NewMecab(s string) (*TokenizeMecab, error) {
	config := C.CString(s)
	newMecabPtr := C.mecab_new2(config)
	if newMecabPtr == nil {
		errStrPtr := C.mecab_strerror(newMecabPtr)
		return nil, errors.New(C.GoString(errStrPtr))
	}
	return &TokenizeMecab{mecab: newMecabPtr}, nil
}
示例#2
0
// NewTagger2 is a factory method to create new Tagger with a string parameter representation, i.e., "-d /user/local/mecab/dic/ipadic -Ochasen"
func NewTagger2(arg string) (*Tagger, error) {
	a := C.CString(arg)
	// defer C.free(unsafe.Pointer(a))
	tagger, err := newTagger(C.mecab_new2(a))
	if err != nil {
		return nil, err
	}
	tagger.memorize.Cache("NewTagger2", a)
	return tagger, nil
}