rename Segment into MPSegment

This commit is contained in:
wyy 2013-09-08 23:51:48 +08:00
parent 789ea7c1da
commit 27143066db
8 changed files with 26 additions and 26 deletions

View File

@ -8,8 +8,8 @@
###Trie树 ###Trie树
Trie.cpp/Trie.h 负责载入词典的trie树主要供Segment模块使用。 Trie.cpp/Trie.h 负责载入词典的trie树主要供Segment模块使用。
###Segment模块 ###Segment模块
Segment.cpp/Segment.h MPSegment.cpp/MPSegment.h
负责根据Trie树构建有向无环图和进行动态规划算法是分词算法的核心。 最大概率发:负责根据Trie树构建有向无环图和进行动态规划算法是分词算法的核心。
###TransCode模块 ###TransCode模块
TransCode.cpp/TransCode.h 负责转换编码类型将utf8和gbk都转换成`uint16_t`类型,也负责逆转换。 TransCode.cpp/TransCode.h 负责转换编码类型将utf8和gbk都转换成`uint16_t`类型,也负责逆转换。
###HMMSegment模块 ###HMMSegment模块
@ -20,7 +20,7 @@ HMM模型由dicts/下面的`hmm_model.utf8`提供。
##Demo ##Demo
### Segment's demo ### MPSegment's demo
__这部分的功能经过线上考验一直稳定运行暂时没有发现什么bug。__ __这部分的功能经过线上考验一直稳定运行暂时没有发现什么bug。__

View File

@ -44,7 +44,7 @@ $(SRCLIB):
cd $(SRCDIR) && $(MAKE) cd $(SRCDIR) && $(MAKE)
clean: clean:
rm -f *.o *.ut *.d keywordext_demo segment_demo rm -f *.o *.ut *.d *.d.* keywordext_demo segment_demo
cd $(SRCDIR) && make clean cd $(SRCDIR) && make clean
sinclude $(SOURCES:.cpp=.d) sinclude $(SOURCES:.cpp=.d)

View File

@ -4,7 +4,7 @@
using namespace CppJieba; using namespace CppJieba;
Segment seg; MPSegment seg;
HMMSegment hmmseg; HMMSegment hmmseg;
bool init(const char * const dictPath, const char * const modelPath) bool init(const char * const dictPath, const char * const modelPath)
{ {

View File

@ -5,7 +5,7 @@
#ifndef CPPJIEBA_KEYWORDEXT_H #ifndef CPPJIEBA_KEYWORDEXT_H
#define CPPJIEBA_KEYWORDEXT_H #define CPPJIEBA_KEYWORDEXT_H
#include "Segment.h" #include "MPSegment.h"
#include "structs.h" #include "structs.h"
namespace CppJieba namespace CppJieba
@ -14,7 +14,7 @@ namespace CppJieba
class KeyWordExt class KeyWordExt
{ {
private: private:
Segment _segment; MPSegment _segment;
vector<string> _priorSubWords; vector<string> _priorSubWords;
set<string> _stopWords; set<string> _stopWords;
public: public:

View File

@ -2,19 +2,19 @@
* file enc : AISCII * file enc : AISCII
* author : wuyanyi09@gmail.com * author : wuyanyi09@gmail.com
************************************/ ************************************/
#include "Segment.h" #include "MPSegment.h"
namespace CppJieba namespace CppJieba
{ {
Segment::Segment() MPSegment::MPSegment()
{ {
} }
Segment::~Segment() MPSegment::~MPSegment()
{ {
} }
bool Segment::init(const char* const filePath) bool MPSegment::init(const char* const filePath)
{ {
if(!_trie.init()) if(!_trie.init())
{ {
@ -31,12 +31,12 @@ namespace CppJieba
return true; return true;
} }
bool Segment::dispose() bool MPSegment::dispose()
{ {
return _trie.dispose(); return _trie.dispose();
} }
bool Segment::cutDAG(const string& str, vector<string>& res) bool MPSegment::cutDAG(const string& str, vector<string>& res)
{ {
vector<TrieNodeInfo> segWordInfos; vector<TrieNodeInfo> segWordInfos;
if(!cutDAG(str, segWordInfos)) if(!cutDAG(str, segWordInfos))
@ -51,7 +51,7 @@ namespace CppJieba
return true; return true;
} }
bool Segment::cutDAG(const string& str, vector<TrieNodeInfo>& segWordInfos) bool MPSegment::cutDAG(const string& str, vector<TrieNodeInfo>& segWordInfos)
{ {
if(str.empty()) if(str.empty())
{ {
@ -88,7 +88,7 @@ namespace CppJieba
return true; return true;
} }
bool Segment::_calcDAG(SegmentContext& segContext) bool MPSegment::_calcDAG(SegmentContext& segContext)
{ {
if(segContext.uintVec.empty()) if(segContext.uintVec.empty())
{ {
@ -114,7 +114,7 @@ namespace CppJieba
return true; return true;
} }
bool Segment::_calcDP(SegmentContext& segContext) bool MPSegment::_calcDP(SegmentContext& segContext)
{ {
if(segContext.uintVec.empty()) if(segContext.uintVec.empty())
{ {
@ -162,7 +162,7 @@ namespace CppJieba
return true; return true;
} }
bool Segment::_cutDAG(SegmentContext& segContext, vector<TrieNodeInfo>& res) bool MPSegment::_cutDAG(SegmentContext& segContext, vector<TrieNodeInfo>& res)
{ {
if(segContext.dp.empty() || segContext.uintVec.empty() || segContext.dp.size() != segContext.uintVec.size()) if(segContext.dp.empty() || segContext.uintVec.empty() || segContext.dp.size() != segContext.uintVec.size())
{ {
@ -208,7 +208,7 @@ using namespace CppJieba;
int main() int main()
{ {
Segment segment; MPSegment segment;
segment.init(); segment.init();
if(!segment._loadSegDict("../dicts/segdict.gbk.v3.0")) if(!segment._loadSegDict("../dicts/segdict.gbk.v3.0"))
{ {

View File

@ -13,14 +13,14 @@
namespace CppJieba namespace CppJieba
{ {
class Segment class MPSegment
{ {
private: private:
Trie _trie; Trie _trie;
public: public:
Segment(); MPSegment();
~Segment(); ~MPSegment();
public: public:
bool init(const char* const filePath); bool init(const char* const filePath);
bool dispose(); bool dispose();

View File

@ -53,11 +53,11 @@ $(CMLIB):
Trie.ut: Trie.cpp Trie.h globals.h TransCode.cpp TransCode.h $(CMLIB) Trie.ut: Trie.cpp Trie.h globals.h TransCode.cpp TransCode.h $(CMLIB)
$(CXX) -o $@ $(CXXFLAGS) Trie.cpp TransCode.cpp -DTRIE_UT $(CMLIB) $(CXX) -o $@ $(CXXFLAGS) Trie.cpp TransCode.cpp -DTRIE_UT $(CMLIB)
Segment.ut: Segment.cpp Trie.cpp Segment.h Trie.h globals.h $(CMLIB) MPSegment.ut: MPSegment.cpp Trie.cpp MPSegment.h Trie.h globals.h $(CMLIB)
$(CXX) -o $@ $(CXXFLAGS) Segment.cpp Trie.cpp TransCode.cpp -DSEGMENT_UT $(CMLIB) $(CXX) -o $@ $(CXXFLAGS) MPSegment.cpp Trie.cpp TransCode.cpp -DSEGMENT_UT $(CMLIB)
KeyWordExt.ut: KeyWordExt.cpp KeyWordExt.h Segment.h Trie.h globals.h TransCode.cpp TransCode.h $(CMLIB) KeyWordExt.ut: KeyWordExt.cpp KeyWordExt.h MPSegment.h Trie.h globals.h TransCode.cpp TransCode.h $(CMLIB)
$(CXX) -o $@ $(CXXFLAGS) KeyWordExt.cpp Segment.cpp Trie.cpp TransCode.cpp -DKEYWORDEXT_UT $(CMLIB) $(CXX) -o $@ $(CXXFLAGS) KeyWordExt.cpp MPSegment.cpp Trie.cpp TransCode.cpp -DKEYWORDEXT_UT $(CMLIB)
TransCode.ut: TransCode.cpp TransCode.h globals.h $(CMLIB) TransCode.ut: TransCode.cpp TransCode.h globals.h $(CMLIB)
$(CXX) -o $@ $(CXXFLAGS) TransCode.cpp -DCPPJIEBA_TRANSCODE_UT $(CMLIB) $(CXX) -o $@ $(CXXFLAGS) TransCode.cpp -DCPPJIEBA_TRANSCODE_UT $(CMLIB)

View File

@ -8,7 +8,7 @@
#include "cppcommon/headers.h" #include "cppcommon/headers.h"
#include "globals.h" #include "globals.h"
#include "KeyWordExt.h" #include "KeyWordExt.h"
#include "Segment.h" #include "MPSegment.h"
#include "Trie.h" #include "Trie.h"
#include "TransCode.h" #include "TransCode.h"
#include "HMMSegment.h" #include "HMMSegment.h"