mirror of
https://github.com/gotoeasy/glogcenter.git
synced 2025-09-15 12:58:34 +08:00
31 lines
747 B
Go
31 lines
747 B
Go
/**
|
|
* TODO 待整理
|
|
*/
|
|
package tokenizer
|
|
|
|
import (
|
|
"path/filepath"
|
|
"runtime"
|
|
|
|
"github.com/gotoeasy/glang/cmn"
|
|
)
|
|
|
|
var jiebago *cmn.TokenizerJiebago
|
|
|
|
// 初始化装载字典
|
|
func init() {
|
|
_, filename, _, _ := runtime.Caller(0) // 当前go文件所在路径
|
|
dictfile := filepath.Join(filepath.Dir(filename), "dict.txt")
|
|
jiebago = cmn.NewTokenizerJiebago(dictfile)
|
|
}
|
|
|
|
// 按搜索引擎模式进行分词后返回分词数组
|
|
func CutForSearch(text string) []string {
|
|
return jiebago.CutForSearch(text)
|
|
}
|
|
|
|
// 按搜索引擎模式进行分词后返回分词数组,可自定义添加或删除分词
|
|
func CutForSearchEx(text string, addWords []string, delWords []string) []string {
|
|
return jiebago.CutForSearchEx(text, addWords, delWords)
|
|
}
|