yanyiwu / gojieba

"结巴"中文分词的Golang版本
MIT License
2.45k stars 303 forks source link

怎样初始化jieba #84

Closed jw-star closed 3 years ago

jw-star commented 3 years ago

我这样尝试了,但是调用失败

var x   *gojieba.Jieba

func init() {
    x = gojieba.NewJieba()
    defer x.Free()
}
FANJIYU0825 commented 2 years ago

SAME QUESTION

glxe commented 1 year ago

我也是同样的问题,这是为啥?没有 defer x.Free() 反而是正常的。

WangSongsen commented 1 month ago

func init() { //本地开发使用 if DevelopmentStage { JiebaObj = gojieba.NewJieba() } else { //编译部署测试服,生产服使用 //从程序运行的当前目录下的dict文件夹中读取utf8文件 dictDir := path.Join(filepath.Dir(os.Args[0]), "dict") jiebaPath := path.Join(dictDir, "jieba.dict.utf8") hmmPath := path.Join(dictDir, "hmm_model.utf8") userPath := path.Join(dictDir, "user.dict.utf8") idfPath := path.Join(dictDir, "idf.utf8") stopPath := path.Join(dictDir, "stop_words.utf8") JiebaObj = gojieba.NewJieba(jiebaPath, hmmPath, userPath, idfPath, stopPath) }

————————————————

                        版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

原文链接:https://blog.csdn.net/rgc_520_zyl/article/details/126040494