mirror of
https://github.com/yanyiwu/cppjieba.git
synced 2025-07-18 00:00:12 +08:00
init mixSegment.cpp/h
This commit is contained in:
parent
27143066db
commit
70f12f2c97
@ -256,7 +256,7 @@ namespace CppJieba
|
||||
return false;
|
||||
}
|
||||
vector<string> tmp, tmp2;
|
||||
uint16_t unico;
|
||||
uint16_t unico = 0;
|
||||
splitStr(line, tmp, ",");
|
||||
for(uint i = 0; i < tmp.size(); i++)
|
||||
{
|
||||
|
@ -63,6 +63,8 @@ TransCode.ut: TransCode.cpp TransCode.h globals.h $(CMLIB)
|
||||
$(CXX) -o $@ $(CXXFLAGS) TransCode.cpp -DCPPJIEBA_TRANSCODE_UT $(CMLIB)
|
||||
HMMSegment.ut: HMMSegment.cpp TransCode.cpp TransCode.h HMMSegment.h $(CMLIB)
|
||||
$(CXX) -o $@ $(CXXFLAGS) TransCode.cpp HMMSegment.cpp -DHMMSEGMENT_UT $(CMLIB)
|
||||
MixSegment.ut: MixSegment.cpp MixSegment.h HMMSegment.cpp MPSegment.cpp Trie.cpp MPSegment.h Trie.h globals.h $(CMLIB)
|
||||
$(CXX) -o $@ $(CXXFLAGS) MixSegment.cpp HMMSegment.cpp MPSegment.cpp Trie.cpp TransCode.cpp -DMIXSEGMENT_UT $(CMLIB)
|
||||
|
||||
clean:
|
||||
rm -f *.o *.d *.ut $(LIBA)
|
||||
|
59
src/MixSegment.cpp
Normal file
59
src/MixSegment.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
#include "MixSegment.h"
|
||||
|
||||
namespace CppJieba
|
||||
{
|
||||
MixSegment::MixSegment()
|
||||
{
|
||||
}
|
||||
|
||||
MixSegment::~MixSegment()
|
||||
{
|
||||
}
|
||||
|
||||
bool MixSegment::init(const char* const mpSegDict, const char* const hmmSegDict)
|
||||
{
|
||||
if(!_mpSeg.init(mpSegDict))
|
||||
{
|
||||
LogError("_mpSeg init");
|
||||
return false;
|
||||
}
|
||||
if(!_hmmSeg.init(hmmSegDict))
|
||||
{
|
||||
LogError("_hmmSeg init");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MixSegment::dispose()
|
||||
{
|
||||
_mpSeg.dispose();
|
||||
_hmmSeg.dispose();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MixSegment::cut(const string& str, vector<string>& res)
|
||||
{
|
||||
vector<TrieNodeInfo> infos;
|
||||
if(!_mpSeg.cutDAG(str, infos))
|
||||
{
|
||||
LogError("_mpSeg cutDAG failed.");
|
||||
return false;
|
||||
}
|
||||
for(uint = 0; i < infos.size(); i++)
|
||||
{
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MIXSEGMENT_UT
|
||||
using namespace CppJieba;
|
||||
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
26
src/MixSegment.h
Normal file
26
src/MixSegment.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef CPPJIEBA_MIXSEGMENT_H
|
||||
#define CPPJIEBA_MIXSEGMENT_H
|
||||
|
||||
#include "MPSegment.h"
|
||||
#include "HMMSegment.h"
|
||||
#include "cppcommon/headers.h"
|
||||
|
||||
namespace CppJieba
|
||||
{
|
||||
class MixSegment
|
||||
{
|
||||
private:
|
||||
MPSegment _mpSeg;
|
||||
HMMSegment _hmmSeg;
|
||||
public:
|
||||
MixSegment();
|
||||
~MixSegment();
|
||||
public:
|
||||
bool init(const char* const _mpSegDict, const char* const _hmmSegDict);
|
||||
bool dispose();
|
||||
public:
|
||||
bool cut(const string& str, vector<string>& res);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user