Beispiel #1
0
// CalculateAllTags finds the tags for each tag level.
func (k KyTea) CalculateAllTags(s Sentence) error {
	err := C.kytea_calculate_all_tags(k.kytea, s.sentence)
	if err != nil {
		defer C.kytea_std_string_destroy(err)
		return errors.New(C.GoString(C.kytea_std_string_cstring(err)))
	}
	return nil
}
Beispiel #2
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
}
Beispiel #3
0
// Tag returns a particular tag and its score.
func (w KyTeaWord) Tag(i, j int, util StringUtil) (string, float64) {
	tag := C.kytea_word_tag(w.word, C.int(i), C.int(j), util.util)
	defer C.kytea_std_string_destroy(tag.feature)
	return C.GoString(C.kytea_std_string_cstring(tag.feature)), float64(tag.score)
}
Beispiel #4
0
// Surface returns the surface of the word.
func (w KyTeaWord) Surface(util StringUtil) string {
	s := C.kytea_word_surface(w.word, util.util)
	defer C.kytea_std_string_destroy(s)
	return C.GoString(C.kytea_std_string_cstring(s))
}
Beispiel #5
0
// WsConstraint is a character type that do not segment.
func (c Config) WsConstraint() string {
	s := C.kytea_config_get_ws_constraint(c.config)
	defer C.kytea_std_string_destroy(s)
	return C.GoString(C.kytea_std_string_cstring(s))
}
Beispiel #6
0
// ModelFile returns the model file to use when analyzing text.
// Default values is "$INSTALL_DIRECTORY/share/kytea/model.bin".
func (c Config) ModelFile() string {
	path := C.kytea_config_get_model_file(c.config)
	defer C.kytea_std_string_destroy(path)
	return C.GoString(C.kytea_std_string_cstring(path))
}
Beispiel #7
0
// DefaultTag is tag for words that cannot be given any tag.
func (c Config) DefaultTag() string {
	s := C.kytea_config_get_default_tag(c.config)
	defer C.kytea_std_string_destroy(s)
	return C.GoString(C.kytea_std_string_cstring(s))
}