基于gojieba 做的分词api和高亮关键词/高亮敏感词 api
config 在当前版本无需配置,直接用就行了
go build -a -ldflags '-extldflags "-static"' -o api main.go
./api --mode=debug --port=8080
go get -u -v github.com/yanyiwu/gojieba
go build github.com/yanyiwu/gojieba: g++: exec: "g++": executable file not found in $PATH
执行
yum install gcc-c++
exec: "gcc": executable file not found in $PATH
执行
yum install gcc
# 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
/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/用阿拉啦云计算测试一一下比特币分词效果
Content type
Image
Digest
Size
14.7 MB
Last updated
over 6 years ago
docker pull terry2010/gojieba-api