This commit is contained in:
gwdwyy 2013-08-02 21:19:57 +08:00
parent d15c7dd75c
commit 35647189a6
3 changed files with 19 additions and 7 deletions

View File

@ -13,8 +13,8 @@ int main(int argc, char ** argv)
}
KeyWordExt ext;
ext.init();
if(!ext.loadSegDict("../dicts/jieba.dict.utf8"))
if(!ext.loadSegDict("../dicts/jieba.dict.gbk"))
{
cerr<<"1"<<endl;
return 1;
@ -25,11 +25,14 @@ int main(int argc, char ** argv)
while(getline(ifile, line))
{
res.clear();
ext.extract(line, res, 20);
cout<<line<<"\n"<<joinStr(res," ")<<endl;
if(!line.empty())
{
ext.extract(line, res, 20);
cout<<line<<"\n"<<joinStr(res," ")<<endl;
}
}
ext.dispose();
return 0;
return 0;
}

View File

@ -154,6 +154,11 @@ namespace CppJieba
bool KeyWordExt::extract(const string& title, vector<string>& keywords, uint topN)
{
if(title.empty())
{
return false;
}
#ifdef DEBUG
LogDebug(string_format("title:[%s]",title.c_str()));
#endif

View File

@ -46,6 +46,10 @@ namespace CppJieba
bool Segment::cutDAG(const string& str, vector<string>& res)
{
if(str.empty())
{
return false;
}
res.clear();
bool retFlag;