Esempio n. 1
0
// ReadModel loads a KyTea model from a model file
func (k KyTea) ReadModel(path string) error {
	cpath := C.CString(path)
	defer C.free(unsafe.Pointer(cpath))
	err := C.kytea_read_model(k.kytea, cpath)
	if err != nil {
		defer C.kytea_std_string_destroy(err)
		return errors.New(C.GoString(C.kytea_std_string_cstring(err)))
	}
	return nil
}
Esempio n. 2
0
// Create creates a Tagger object
// It is the caller's responsiblity to delete the tagger when it is done with it.
func Create(filename string) (*Tagger, error) {
	var rep *C.kytea_t
	name := C.CString(filename)
	defer C.free(unsafe.Pointer(name))
	rep = C.kytea_create()
	if rep == nil {
		return nil, errors.New("Cannot create a KyTea object")
	}
	if ret := C.kytea_read_model(rep, name); ret < 0 {
		return nil, errors.New("Cannot read the model")
	}

	config := C.kytea_get_config(rep)
	if config == nil {
		return nil, errors.New("Cannot get a KyTea config object")
	}
	return &Tagger{rep: rep, config: config}, nil
}