mirror of
https://github.com/yanyiwu/cppjieba.git
synced 2025-07-18 00:00:12 +08:00
rm unused server in test
This commit is contained in:
parent
3e0aaf73a5
commit
94ae4bdd6f
@ -1,58 +0,0 @@
|
||||
#include <CppJieba/Husky/ServerFrame.h>
|
||||
#include <CppJieba/Husky/Daemon.h>
|
||||
#include <CppJieba/Limonp/ArgvContext.hpp>
|
||||
#include <CppJieba/MPSegment.h>
|
||||
#include <CppJieba/HMMSegment.h>
|
||||
#include <CppJieba/MixSegment.h>
|
||||
|
||||
using namespace Husky;
|
||||
using namespace CppJieba;
|
||||
|
||||
const char * const DEFAULT_DICTPATH = "../dict/jieba.dict.utf8";
|
||||
const char * const DEFAULT_MODELPATH = "../dict/hmm_model.utf8";
|
||||
|
||||
class ServerDemo: public IRequestHandler
|
||||
{
|
||||
public:
|
||||
ServerDemo(){};
|
||||
virtual ~ServerDemo(){};
|
||||
virtual bool init(){return _segment.init(DEFAULT_DICTPATH, DEFAULT_MODELPATH);};
|
||||
virtual bool dispose(){return _segment.dispose();};
|
||||
public:
|
||||
virtual bool do_GET(const HttpReqInfo& httpReq, string& strSnd)
|
||||
{
|
||||
string sentence, tmp;
|
||||
vector<string> words;
|
||||
httpReq.GET("key", tmp);
|
||||
URLDecode(tmp, sentence);
|
||||
_segment.cut(sentence, words);
|
||||
strSnd << words;
|
||||
return true;
|
||||
}
|
||||
private:
|
||||
MixSegment _segment;
|
||||
};
|
||||
|
||||
int main(int argc,char* argv[])
|
||||
{
|
||||
if(argc != 7)
|
||||
{
|
||||
printf("usage: %s -n THREAD_NUMBER -p LISTEN_PORT -k start|stop\n",argv[0]);
|
||||
return -1;
|
||||
}
|
||||
ArgvContext arg(argc, argv);
|
||||
unsigned int port = atoi(arg["-p"].c_str());
|
||||
unsigned int threadNum = atoi(arg["-n"].c_str());
|
||||
|
||||
ServerDemo s;
|
||||
Daemon daemon(&s);
|
||||
if(arg["-k"] == "start")
|
||||
{
|
||||
return !daemon.Start(port, threadNum);
|
||||
}
|
||||
else
|
||||
{
|
||||
return !daemon.Stop();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user