From 27143066dbe8215d70f0c553c5d5d6167a33dfeb Mon Sep 17 00:00:00 2001 From: wyy Date: Sun, 8 Sep 2013 23:51:48 +0800 Subject: [PATCH] rename Segment into MPSegment --- README.md | 6 +++--- demo/Makefile | 2 +- demo/segment_demo.cpp | 2 +- src/KeyWordExt.h | 4 ++-- src/{Segment.cpp => MPSegment.cpp} | 22 +++++++++++----------- src/{Segment.h => MPSegment.h} | 6 +++--- src/Makefile | 8 ++++---- src/headers.h | 2 +- 8 files changed, 26 insertions(+), 26 deletions(-) rename src/{Segment.cpp => MPSegment.cpp} (89%) rename src/{Segment.h => MPSegment.h} (93%) diff --git a/README.md b/README.md index bbeaa5e..0c51004 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ ###Trie树 Trie.cpp/Trie.h 负责载入词典的trie树,主要供Segment模块使用。 ###Segment模块 -Segment.cpp/Segment.h -负责根据Trie树构建有向无环图和进行动态规划算法,是分词算法的核心。 +MPSegment.cpp/MPSegment.h +最大概率发:负责根据Trie树构建有向无环图和进行动态规划算法,是分词算法的核心。 ###TransCode模块 TransCode.cpp/TransCode.h 负责转换编码类型,将utf8和gbk都转换成`uint16_t`类型,也负责逆转换。 ###HMMSegment模块 @@ -20,7 +20,7 @@ HMM模型由dicts/下面的`hmm_model.utf8`提供。 ##Demo -### Segment's demo +### MPSegment's demo __这部分的功能经过线上考验,一直稳定运行,暂时没有发现什么bug。__ diff --git a/demo/Makefile b/demo/Makefile index 379abba..febcf92 100644 --- a/demo/Makefile +++ b/demo/Makefile @@ -44,7 +44,7 @@ $(SRCLIB): cd $(SRCDIR) && $(MAKE) clean: - rm -f *.o *.ut *.d keywordext_demo segment_demo + rm -f *.o *.ut *.d *.d.* keywordext_demo segment_demo cd $(SRCDIR) && make clean sinclude $(SOURCES:.cpp=.d) diff --git a/demo/segment_demo.cpp b/demo/segment_demo.cpp index 4f7754d..aa512e0 100644 --- a/demo/segment_demo.cpp +++ b/demo/segment_demo.cpp @@ -4,7 +4,7 @@ using namespace CppJieba; -Segment seg; +MPSegment seg; HMMSegment hmmseg; bool init(const char * const dictPath, const char * const modelPath) { diff --git a/src/KeyWordExt.h b/src/KeyWordExt.h index ced6978..5f9432b 100644 --- a/src/KeyWordExt.h +++ b/src/KeyWordExt.h @@ -5,7 +5,7 @@ #ifndef CPPJIEBA_KEYWORDEXT_H #define CPPJIEBA_KEYWORDEXT_H -#include "Segment.h" +#include "MPSegment.h" #include "structs.h" namespace CppJieba @@ -14,7 +14,7 @@ namespace CppJieba class KeyWordExt { private: - Segment _segment; + MPSegment _segment; vector _priorSubWords; set _stopWords; public: diff --git a/src/Segment.cpp b/src/MPSegment.cpp similarity index 89% rename from src/Segment.cpp rename to src/MPSegment.cpp index 9919a75..3409e63 100644 --- a/src/Segment.cpp +++ b/src/MPSegment.cpp @@ -2,19 +2,19 @@ * file enc : AISCII * author : wuyanyi09@gmail.com ************************************/ -#include "Segment.h" +#include "MPSegment.h" 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()) { @@ -31,12 +31,12 @@ namespace CppJieba return true; } - bool Segment::dispose() + bool MPSegment::dispose() { return _trie.dispose(); } - bool Segment::cutDAG(const string& str, vector& res) + bool MPSegment::cutDAG(const string& str, vector& res) { vector segWordInfos; if(!cutDAG(str, segWordInfos)) @@ -51,7 +51,7 @@ namespace CppJieba return true; } - bool Segment::cutDAG(const string& str, vector& segWordInfos) + bool MPSegment::cutDAG(const string& str, vector& segWordInfos) { if(str.empty()) { @@ -88,7 +88,7 @@ namespace CppJieba return true; } - bool Segment::_calcDAG(SegmentContext& segContext) + bool MPSegment::_calcDAG(SegmentContext& segContext) { if(segContext.uintVec.empty()) { @@ -114,7 +114,7 @@ namespace CppJieba return true; } - bool Segment::_calcDP(SegmentContext& segContext) + bool MPSegment::_calcDP(SegmentContext& segContext) { if(segContext.uintVec.empty()) { @@ -162,7 +162,7 @@ namespace CppJieba return true; } - bool Segment::_cutDAG(SegmentContext& segContext, vector& res) + bool MPSegment::_cutDAG(SegmentContext& segContext, vector& res) { if(segContext.dp.empty() || segContext.uintVec.empty() || segContext.dp.size() != segContext.uintVec.size()) { @@ -208,7 +208,7 @@ using namespace CppJieba; int main() { - Segment segment; + MPSegment segment; segment.init(); if(!segment._loadSegDict("../dicts/segdict.gbk.v3.0")) { diff --git a/src/Segment.h b/src/MPSegment.h similarity index 93% rename from src/Segment.h rename to src/MPSegment.h index dd7c82a..f4b5439 100644 --- a/src/Segment.h +++ b/src/MPSegment.h @@ -13,14 +13,14 @@ namespace CppJieba { - class Segment + class MPSegment { private: Trie _trie; public: - Segment(); - ~Segment(); + MPSegment(); + ~MPSegment(); public: bool init(const char* const filePath); bool dispose(); diff --git a/src/Makefile b/src/Makefile index fe55b4c..a6b92c3 100644 --- a/src/Makefile +++ b/src/Makefile @@ -53,11 +53,11 @@ $(CMLIB): Trie.ut: Trie.cpp Trie.h globals.h TransCode.cpp TransCode.h $(CMLIB) $(CXX) -o $@ $(CXXFLAGS) Trie.cpp TransCode.cpp -DTRIE_UT $(CMLIB) -Segment.ut: Segment.cpp Trie.cpp Segment.h Trie.h globals.h $(CMLIB) - $(CXX) -o $@ $(CXXFLAGS) Segment.cpp Trie.cpp TransCode.cpp -DSEGMENT_UT $(CMLIB) +MPSegment.ut: MPSegment.cpp Trie.cpp MPSegment.h Trie.h globals.h $(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) - $(CXX) -o $@ $(CXXFLAGS) KeyWordExt.cpp Segment.cpp Trie.cpp TransCode.cpp -DKEYWORDEXT_UT $(CMLIB) +KeyWordExt.ut: KeyWordExt.cpp KeyWordExt.h MPSegment.h Trie.h globals.h TransCode.cpp TransCode.h $(CMLIB) + $(CXX) -o $@ $(CXXFLAGS) KeyWordExt.cpp MPSegment.cpp Trie.cpp TransCode.cpp -DKEYWORDEXT_UT $(CMLIB) TransCode.ut: TransCode.cpp TransCode.h globals.h $(CMLIB) $(CXX) -o $@ $(CXXFLAGS) TransCode.cpp -DCPPJIEBA_TRANSCODE_UT $(CMLIB) diff --git a/src/headers.h b/src/headers.h index 8063397..1227cac 100644 --- a/src/headers.h +++ b/src/headers.h @@ -8,7 +8,7 @@ #include "cppcommon/headers.h" #include "globals.h" #include "KeyWordExt.h" -#include "Segment.h" +#include "MPSegment.h" #include "Trie.h" #include "TransCode.h" #include "HMMSegment.h"