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.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。__

View File

@ -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)

View File

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

View File

@ -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<string> _priorSubWords;
set<string> _stopWords;
public:

View File

@ -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<string>& res)
bool MPSegment::cutDAG(const string& str, vector<string>& res)
{
vector<TrieNodeInfo> segWordInfos;
if(!cutDAG(str, segWordInfos))
@ -51,7 +51,7 @@ namespace CppJieba
return true;
}
bool Segment::cutDAG(const string& str, vector<TrieNodeInfo>& segWordInfos)
bool MPSegment::cutDAG(const string& str, vector<TrieNodeInfo>& 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<TrieNodeInfo>& res)
bool MPSegment::_cutDAG(SegmentContext& segContext, vector<TrieNodeInfo>& 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"))
{

View File

@ -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();

View File

@ -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)

View File

@ -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"