mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-20 09:21:11 +00:00
231e468e19
git-subtree-dir: erigon-lib git-subtree-mainline: 3c8cbda8098cc073a668b9e9b0aafe6c361f17da git-subtree-split: 93d9c9d9fe4bd8a49f7a98a6bce0f0da7094c7d3
28 lines
409 B
Go
28 lines
409 B
Go
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))
|
|
tPtr := unsafe.Pointer(&data[0]) // source "text"
|
|
saPtr := unsafe.Pointer(&sa[0])
|
|
|
|
result := C.sais(
|
|
(*C.uchar)(tPtr),
|
|
(*C.int)(saPtr),
|
|
size,
|
|
)
|
|
if int(result) != 0 {
|
|
return fmt.Errorf("sais returned: %d", result)
|
|
}
|
|
return nil
|
|
}
|