erigon-pulse/erigon-lib/sais/sais.go

28 lines
409 B
Go
Raw Normal View History

package sais
/*
#include "sais.h"
#include "utils.h"
*/
import "C"
import (
"fmt"
"unsafe"
)
func Sais(data []byte, sa []int32) error {
size := C.int(len(data))
2022-03-19 04:38:37 +00:00
tPtr := unsafe.Pointer(&data[0]) // source "text"
saPtr := unsafe.Pointer(&sa[0])
result := C.sais(
2022-03-19 04:38:37 +00:00
(*C.uchar)(tPtr),
(*C.int)(saPtr),
size,
)
if int(result) != 0 {
return fmt.Errorf("sais returned: %d", result)
}
return nil
}