Coder Social home page Coder Social logo

cppjieba-server's Introduction

CppJieba Server

Build Status Author License

简介

结巴中文分词HTTP服务。

用法

依赖软件

  • g++ (version >= 4.1 is recommended) or clang++;
  • cmake (version >= 2.6 is recommended);

下载和编译

git clone --depth=10 --branch=master git://github.com/yanyiwu/cppjieba-server.git
cd cppjieba-server
mkdir build
cd build
cmake ..
make

服务使用

服务默认使用 MixSegment 切词方式,如果想要修改成其他方式,请参考 src/server.cpp 源码文件。 将对应的方式的代码行注释去掉,重新编译即可。

启动服务

./bin/cjserver ../conf/server_example.conf

客户端请求示例

curl "http://127.0.0.1:11200/?key=南京市长江大桥"
["南京市", "长江大桥"]
curl "http://127.0.0.1:11200/?key=南京市长江大桥&format=simple"
南京市 长江大桥

默认切词算法是MixSegment切词算法,如果想要使用其他算法切词,可以使用参数method来设置。 示例如下:

curl "http://127.0.0.1:11200/?key=南京市长江大桥&format=simple&method=MP"
curl "http://127.0.0.1:11200/?key=南京市长江大桥&format=simple&method=HMM"
curl "http://127.0.0.1:11200/?key=南京市长江大桥&format=simple&method=MIX"
curl "http://127.0.0.1:11200/?key=南京市长江大桥&format=simple&method=FULL"
curl "http://127.0.0.1:11200/?key=南京市长江大桥&format=simple&method=QUERY"

用 chrome 浏览器打开也行 ( chrome 设置默认编码是utf-8):

同时,也支持HTTP POST模式,使用如下调用:

curl -d "南京市长江大桥" "http://127.0.0.1:11200/"

返回结果如下:

["南京市", "长江大桥"]

因为 HTTP GET 请求有长度限制,如果需要请求长文的,请使用POST请求。

安装服务(仅限 linux 系统)

如果有需要安装使用的,可以按照如下操作:

sudo make install

服务启动和停止(仅限 linux 系统)

cd /usr/local/cppjieba-server
./script/cjserver.start
./script/cjserver.stop

卸载服务(仅限 linux 系统)

rm -rf /usr/local/cppjieba-server

客服

image

许可证

MIT http://yanyiwu.mit-license.org

作者

cppjieba-server's People

Contributors

cxzhp avatar yanyiwu avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.