modify democ.pp

This commit is contained in:
gwdwyy 2013-07-23 11:15:53 +08:00
parent 176bc04d7a
commit ddb55f7e8e
2 changed files with 15 additions and 21 deletions

View File

@ -24,7 +24,7 @@ all: demo
$(CC) $(CCOPT) $< $(CC) $(CCOPT) $<
demo: $(OBJS) $(SRCLIB) demo: $(OBJS) $(SRCLIB)
$(DOLINK) -liconv $(DOLINK)
$(SRCLIB): $(SRCLIB):
cd $(SRCDIR) && $(MAKE) cd $(SRCDIR) && $(MAKE)

View File

@ -1,6 +1,9 @@
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include "src/KeyWordExt.h" #include "src/KeyWordExt.h"
#include "src/cppcommon/str_functs.h"
#include "src/cppcommon/vec_functs.h"
using namespace std; using namespace std;
using namespace CppJieba; using namespace CppJieba;
@ -8,33 +11,24 @@ using namespace CppJieba;
int main() int main()
{ {
KeyWordExt ext; KeyWordExt ext;
ext.init();
if(!ext.init("./dicts/segdict.utf8.v2.1")) if(!ext.loadSegDict("./dicts/segdict.gbk.v3.0"))
{ {
cerr<<"1"<<endl; cerr<<"1"<<endl;
return 1; return 1;
} }
//ext.init("dicts/jieba.dict.utf8"); ifstream ifile("dress.gbk");
vector<string> res; vector<string> res;
string title; string line;
title = "我来到北京清华大学"; while(getline(ifile, line))
res.clear(); {
ext.extract(title, res, 10); res.clear();
ext.extract(line, res, 20);
cout<<line<<"\n"<<joinStr(res," ")<<endl;
}
title = "特价camel骆驼 柔软舒适头层牛皮平底凉鞋女 休闲平跟妈妈鞋夏"; ext.dispose();
res.clear();
ext.extract(title, res, 10);
title = "包邮拉菲草18cm大檐进口草帽子超强遮阳防晒欧美日韩新款夏天 女";
res.clear();
ext.extract(title, res, 10);
title = "2013新款19CM超大檐帽 遮阳草帽子 沙滩帽防晒大檐欧美新款夏天女";
res.clear();
ext.extract(title, res, 10);
ext.destroy();
return 0; return 0;
} }