Sign inSign up

terry2010/gojieba-api

By terry2010

•Updated over 6 years ago

Image
0

281

terry2010/gojieba-api repository overview

⁠gojiebaAPI

基于gojieba 做的分词api和高亮关键词/高亮敏感词 api

⁠使用方法

config 在当前版本无需配置,直接用就行了

go build -a -ldflags '-extldflags "-static"'  -o  api main.go
./api --mode=debug --port=8080
⁠编译常见问题
⁠1.在干净服务器上第一次安装会缺少库
go get -u -v github.com/yanyiwu/gojieba
⁠2.安装gojieba库的时候提示缺少g++
go build github.com/yanyiwu/gojieba: g++: exec: "g++": executable file not found in $PATH

执行

yum install gcc-c++
⁠3.编译的时候提示缺少gcc
exec: "gcc": executable file not found in $PATH

执行

yum install gcc
⁠4.编译的时候提示缺少ld lxxx 库
# command-line-arguments
/usr/lib/golang/pkg/tool/linux_amd64/link: running g++ failed: exit status 1
/usr/bin/ld: cannot find -lpthread
/usr/bin/ld: cannot find -lstdc++
/usr/bin/ld: cannot find -lm
/usr/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status

执行

yum install -y glibc-static  libstdc++-static

⁠接口

⁠热加载用户自定义词库 (data/update.dict.utf8)

/reload/:id

curl 127.0.0.1:8080/reload/1
⁠分词接口:

/cut/:id/:type/:text

id 随便写
type : 分词类型  
       all         全模式
       search1     搜索引擎模式     关闭 HMM新词发现
       search0     搜索引擎模式     开启 HMM新词发现
       auto1       精确模式,        开启 HMM新词发现
       auto0       精确模式,       关闭 HMM新词发现
text: 需要分词的中文内容

示例:

curl 127.0.0.1:8080/cut/1/all/用阿拉啦云计算测试一一下比特币分词效果
curl 127.0.0.1:8080/cut/1/search1/用阿拉啦云计算测试一一下比特币分词效果
curl 127.0.0.1:8080/cut/1/search0/用阿拉啦云计算测试一一下比特币分词效果
curl 127.0.0.1:8080/cut/1/auto1/用阿拉啦云计算测试一一下比特币分词效果
curl 127.0.0.1:8080/cut/1/auto0/用阿拉啦云计算测试一一下比特币分词效果
⁠高亮关键词/高亮敏感词接口

/highlight/:id/:type/:text

id 随便写
type : 分词类型
       all         全模式
       search1     搜索引擎模式     关闭 HMM新词发现
       search0     搜索引擎模式     开启 HMM新词发现
       auto1       精确模式,        开启 HMM新词发现
       auto0       精确模式,       关闭 HMM新词发现
text: 需要高亮的中文内容

示例:

在正式使用前,加载自定义敏感词词库
curl 127.0.0.1:8080/reload/1

加载完毕一次之后,就可以任意使用了
分词模式可以自己尝试各个模式下的效果, 推荐使用 search0 
curl 127.0.0.1:8080/highlight/1/search0/用阿拉啦云计算测试一一下比特币分词效果

Tag summary

Content type

Image

Digest

Size

14.7 MB

Last updated

over 6 years ago

docker pull terry2010/gojieba-api