cppjieba/demo.cpp
2013-07-12 17:10:34 +08:00

41 lines
881 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <iostream>
#include <fstream>
#include "src/Segment.h"
using namespace std;
using namespace CppJieba;
int main()
{
Segment segment;
if(!segment.init("./dicts/segdict.utf8.v2.1"))
{
cerr<<"1"<<endl;
return 1;
}
//segment.init("dicts/jieba.dict.utf8");
vector<string> res;
string title;
title = "我来到北京清华大学";
res.clear();
segment.extract(title, res, 10);
title = "特价camel骆驼 柔软舒适头层牛皮平底凉鞋女 休闲平跟妈妈鞋夏";
res.clear();
segment.extract(title, res, 10);
title = "包邮拉菲草18cm大檐进口草帽子超强遮阳防晒欧美日韩新款夏天 女";
res.clear();
segment.extract(title, res, 10);
title = "2013新款19CM超大檐帽 遮阳草帽子 沙滩帽防晒大檐欧美新款夏天女";
res.clear();
segment.extract(title, res, 10);
segment.destroy();
return 0;
}