mirror of
https://github.com/yanyiwu/cppjieba.git
synced 2025-07-18 00:00:12 +08:00
add tools.cpp
This commit is contained in:
parent
53ce28ae09
commit
86cf38bfef
@ -181,8 +181,12 @@ using namespace CppJieba;
|
||||
|
||||
int main()
|
||||
{
|
||||
/*
|
||||
cout<<__FILE__<<__LINE__<<endl;
|
||||
Segment segment;
|
||||
cout<<__FILE__<<__LINE__<<endl;
|
||||
segment.init();
|
||||
cout<<__FILE__<<__LINE__<<endl;
|
||||
if(!segment.loadSegDict("../dicts/segdict.utf8.v2.1"))
|
||||
{
|
||||
cerr<<"1"<<endl;
|
||||
@ -195,12 +199,14 @@ int main()
|
||||
while(getline(ifile, line))
|
||||
{
|
||||
res.clear();
|
||||
cout<<__FILE__<<__LINE__<<endl;
|
||||
segment.cutDAG(line, res);
|
||||
PRINT_VECTOR(res);
|
||||
getchar();
|
||||
}
|
||||
|
||||
segment.dispose();
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -398,6 +398,7 @@ namespace CppJieba
|
||||
using namespace CppJieba;
|
||||
int main()
|
||||
{
|
||||
cout<<__FILE__<<__FILE__<<endl;
|
||||
Trie trie;
|
||||
trie.init();
|
||||
trie.loadDict("../dicts/segdict.utf8.v2.1");
|
||||
|
@ -87,8 +87,6 @@ namespace CppJieba
|
||||
bool _getInitFlag();
|
||||
|
||||
public:
|
||||
//const TrieNodeInfo* find(const string& uniStr);
|
||||
//const TrieNodeInfo* find(const ChUnicode* const chUniStr, size_t len);
|
||||
const TrieNodeInfo* find(const string& str);
|
||||
const TrieNodeInfo* findPrefix(const string& str);
|
||||
|
||||
|
@ -7,8 +7,8 @@ PACKOPT = rc
|
||||
SOURCES := $(wildcard *.cpp)
|
||||
OBJS := $(patsubst %.cpp,%.o,$(SOURCES))
|
||||
|
||||
DOPACK = $(PACK) $(PACKOPT) $@ $?
|
||||
DOLINK = $(LINK) $(LINKOPT) -o $@ $?
|
||||
DOPACK = $(PACK) $(PACKOPT) $@ $^
|
||||
DOLINK = $(LINK) $(LINKOPT) -o $@ $^
|
||||
|
||||
CMLIB = libcm.a
|
||||
|
||||
|
@ -6,13 +6,13 @@
|
||||
|
||||
namespace CPPCOMMON
|
||||
{
|
||||
const string& UnicodeEncoding::UTF8ENC = "utf-8";
|
||||
const string& UnicodeEncoding::GBKENC = "gbk";
|
||||
|
||||
UnicodeEncoding::UnicodeEncoding(const string& enc)
|
||||
{
|
||||
|
||||
_encVec.push_back(UTF8ENC);
|
||||
_encVec.push_back(GBKENC);
|
||||
|
||||
if(!isInVec<string>(_encVec, enc))
|
||||
{
|
||||
//default
|
||||
@ -100,7 +100,7 @@ int main()
|
||||
//}
|
||||
ifile.close();
|
||||
ifile.open("testdata/dict.gbk");
|
||||
enc.setEncoding(UnicodeEncoding::GBKENC);
|
||||
enc.setEncoding(GBKENC);
|
||||
while(getline(ifile, line))
|
||||
{
|
||||
|
||||
|
@ -12,11 +12,12 @@
|
||||
namespace CPPCOMMON
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
const char* const UTF8ENC = "utf-8";
|
||||
const char* const GBKENC = "gbk";
|
||||
|
||||
class UnicodeEncoding
|
||||
{
|
||||
public:
|
||||
static const string& UTF8ENC;
|
||||
static const string& GBKENC;
|
||||
private:
|
||||
string _encoding;
|
||||
vector<string> _encVec;
|
||||
|
6
src/tools.cpp
Normal file
6
src/tools.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include "tools.h"
|
||||
|
||||
namespace CppJieba
|
||||
{
|
||||
UnicodeEncoding gEncoding(UTF8ENC);
|
||||
}
|
13
src/tools.h
Normal file
13
src/tools.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef CPPJIEBA_TOOLS_H
|
||||
#define CPPJIEBA_TOOLS_H
|
||||
|
||||
#include "cppcommon/encoding.h"
|
||||
|
||||
namespace CppJieba
|
||||
{
|
||||
using namespace CPPCOMMON;
|
||||
//global singleton encoding class.
|
||||
extern UnicodeEncoding gEncoding;
|
||||
}
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user