mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-02 03:48:37 +08:00
d67853fa89
relate: https://github.com/milvus-io/milvus/issues/35853 https://github.com/milvus-io/milvus/issues/36751 --------- Signed-off-by: aoiasd <zhicheng.yue@zilliz.com>
39 lines
883 B
Go
39 lines
883 B
Go
package ctokenizer
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestTokenizer(t *testing.T) {
|
|
// default tokenizer.
|
|
{
|
|
m := "{\"tokenizer\": \"standard\"}"
|
|
tokenizer, err := NewTokenizer(m)
|
|
assert.NoError(t, err)
|
|
defer tokenizer.Destroy()
|
|
|
|
tokenStream := tokenizer.NewTokenStream("football, basketball, pingpang")
|
|
defer tokenStream.Destroy()
|
|
for tokenStream.Advance() {
|
|
fmt.Println(tokenStream.Token())
|
|
}
|
|
}
|
|
|
|
// jieba tokenizer.
|
|
{
|
|
m := "{\"tokenizer\": \"jieba\"}"
|
|
tokenizer, err := NewTokenizer(m)
|
|
assert.NoError(t, err)
|
|
defer tokenizer.Destroy()
|
|
|
|
tokenStream := tokenizer.NewTokenStream("张华考上了北京大学;李萍进了中等技术学校;我在百货公司当售货员:我们都有光明的前途")
|
|
defer tokenStream.Destroy()
|
|
for tokenStream.Advance() {
|
|
fmt.Println(tokenStream.Token())
|
|
}
|
|
}
|
|
}
|