mirror of
https://github.com/yanyiwu/cppjieba.git
synced 2025-07-18 00:00:12 +08:00
modify democ.pp
This commit is contained in:
parent
176bc04d7a
commit
ddb55f7e8e
2
Makefile
2
Makefile
@ -24,7 +24,7 @@ all: demo
|
||||
$(CC) $(CCOPT) $<
|
||||
|
||||
demo: $(OBJS) $(SRCLIB)
|
||||
$(DOLINK) -liconv
|
||||
$(DOLINK)
|
||||
|
||||
$(SRCLIB):
|
||||
cd $(SRCDIR) && $(MAKE)
|
||||
|
34
demo.cpp
34
demo.cpp
@ -1,6 +1,9 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include "src/KeyWordExt.h"
|
||||
#include "src/cppcommon/str_functs.h"
|
||||
#include "src/cppcommon/vec_functs.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
using namespace CppJieba;
|
||||
@ -8,33 +11,24 @@ using namespace CppJieba;
|
||||
int main()
|
||||
{
|
||||
KeyWordExt ext;
|
||||
ext.init();
|
||||
|
||||
if(!ext.init("./dicts/segdict.utf8.v2.1"))
|
||||
if(!ext.loadSegDict("./dicts/segdict.gbk.v3.0"))
|
||||
{
|
||||
cerr<<"1"<<endl;
|
||||
return 1;
|
||||
}
|
||||
//ext.init("dicts/jieba.dict.utf8");
|
||||
|
||||
ifstream ifile("dress.gbk");
|
||||
vector<string> res;
|
||||
string title;
|
||||
title = "我来到北京清华大学";
|
||||
res.clear();
|
||||
ext.extract(title, res, 10);
|
||||
string line;
|
||||
while(getline(ifile, line))
|
||||
{
|
||||
res.clear();
|
||||
ext.extract(line, res, 20);
|
||||
cout<<line<<"\n"<<joinStr(res," ")<<endl;
|
||||
}
|
||||
|
||||
title = "特价!camel骆驼 柔软舒适头层牛皮平底凉鞋女 休闲平跟妈妈鞋夏";
|
||||
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();
|
||||
ext.dispose();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user