mirror of
https://github.com/yanyiwu/cppjieba.git
synced 2025-07-18 00:00:12 +08:00
more flexible
This commit is contained in:
parent
9218ccb9c9
commit
d34ed79b03
@ -5,18 +5,19 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "Limonp/Config.hpp"
|
#include "Limonp/Config.hpp"
|
||||||
#include "Husky/ThreadPoolServer.hpp"
|
#include "Husky/ThreadPoolServer.hpp"
|
||||||
#include "MPSegment.hpp"
|
|
||||||
#include "HMMSegment.hpp"
|
|
||||||
#include "MixSegment.hpp"
|
#include "MixSegment.hpp"
|
||||||
|
#include "QuerySegment.hpp"
|
||||||
|
#include "FullSegment.hpp"
|
||||||
|
|
||||||
using namespace Husky;
|
using namespace Husky;
|
||||||
using namespace CppJieba;
|
using namespace CppJieba;
|
||||||
|
|
||||||
class ReqHandler: public IRequestHandler {
|
class ReqHandler: public IRequestHandler {
|
||||||
public:
|
public:
|
||||||
ReqHandler(const string& dictPath, const string& modelPath, const string& userDictPath): _segment(dictPath, modelPath, userDictPath) {};
|
ReqHandler(const ISegment& segment): _segment(segment) {
|
||||||
|
}
|
||||||
virtual ~ReqHandler() {};
|
virtual ~ReqHandler() {};
|
||||||
public:
|
|
||||||
virtual bool do_GET(const HttpReqInfo& httpReq, string& strSnd) const {
|
virtual bool do_GET(const HttpReqInfo& httpReq, string& strSnd) const {
|
||||||
string sentence, tmp;
|
string sentence, tmp;
|
||||||
vector<string> words;
|
vector<string> words;
|
||||||
@ -37,7 +38,7 @@ class ReqHandler: public IRequestHandler {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
MixSegment _segment;
|
const ISegment& _segment;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool run(int argc, char** argv) {
|
bool run(int argc, char** argv) {
|
||||||
@ -65,7 +66,15 @@ bool run(int argc, char** argv) {
|
|||||||
|
|
||||||
LogInfo("config info: %s", conf.getConfigInfo().c_str());
|
LogInfo("config info: %s", conf.getConfigInfo().c_str());
|
||||||
|
|
||||||
ReqHandler reqHandler(dictPath, modelPath, userDictPath);
|
/*
|
||||||
|
* segment can be one of (MPSegment, HMMSegment, MixSegment, QuerySegment ...)
|
||||||
|
*/
|
||||||
|
//MPSegment segment(dictPath, userDictPath);
|
||||||
|
//HMMSegment segment(modelPath);
|
||||||
|
MixSegment segment(dictPath, modelPath, userDictPath);
|
||||||
|
//QuerySegment segment(dictPath, modelPath);
|
||||||
|
|
||||||
|
ReqHandler reqHandler(segment);
|
||||||
ThreadPoolServer sf(threadNumber, queueMaxSize, port, reqHandler);
|
ThreadPoolServer sf(threadNumber, queueMaxSize, port, reqHandler);
|
||||||
return sf.start();
|
return sf.start();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user