This commit is contained in:
wyy 2013-12-06 02:45:25 -08:00
parent d82ac83a8a
commit ceeff56cdd
2 changed files with 61 additions and 0 deletions

View File

@ -1 +1,2 @@
g++ -o segment.demo segment.cpp -std=c++0x -L/usr/lib/CppJieba -lcppjieba
g++ -o test_performance test_performance.cpp -std=c++0x -O3

60
test/test_performance.cpp Normal file
View File

@ -0,0 +1,60 @@
#include <iostream>
#include <fstream>
#include "../src/Limonp/ArgvContext.hpp"
#include "../src/MPSegment.hpp"
#include "../src/HMMSegment.hpp"
#include "../src/MixSegment.hpp"
using namespace CppJieba;
void cut(const ISegment * seg, const char * const filePath)
{
ifstream ifile(filePath);
vector<string> res;
string line;
while(getline(ifile, line))
{
if(!line.empty())
{
res.clear();
seg->cut(line, res);
//cout<<join(res.begin(), res.end(),"/")<<endl;
}
}
}
int main(int argc, char ** argv)
{
//demo
//{
// HMMSegment seg;
// if(!seg.init("../dicts/hmm_model.utf8"))
// {
// cout<<"seg init failed."<<endl;
// return EXIT_FAILURE;
// }
// cut(&seg, "testlines.utf8");
// seg.dispose();
//}
//{
// MixSegment seg;
// if(!seg.init("../dicts/jieba.dict.utf8", "../dicts/hmm_model.utf8"))
// {
// cout<<"seg init failed."<<endl;
// return EXIT_FAILURE;
// }
// cut(&seg, "testlines.utf8");
// seg.dispose();
//}
{
MPSegment seg("../dicts/jieba.dict.utf8");
if(!seg.init())
{
cout<<"seg init failed."<<endl;
return false;
}
cut(&seg, argv[1]);
seg.dispose();
}
return EXIT_SUCCESS;
}