github.com/ledgerwatch/erigon-lib@v1.0.0/sais/sais.go (about) 1 package sais 2 3 /* 4 #include "sais.h" 5 #include "utils.h" 6 */ 7 import "C" 8 import ( 9 "fmt" 10 "unsafe" 11 ) 12 13 func Sais(data []byte, sa []int32) error { 14 size := C.int(len(data)) 15 tPtr := unsafe.Pointer(&data[0]) // source "text" 16 saPtr := unsafe.Pointer(&sa[0]) 17 18 result := C.sais( 19 (*C.uchar)(tPtr), 20 (*C.int)(saPtr), 21 size, 22 ) 23 if int(result) != 0 { 24 return fmt.Errorf("sais returned: %d", result) 25 } 26 return nil 27 }