void testKeyWordExt(const char * dictPath, const char * filePath)
{
	KeyWordExt ext;
	ext.init();

	if(!ext.loadSegDict(dictPath))
	{
		cerr<<__FILE__<<__LINE__<<endl;
		return ;
	}
	if(!ext.loadStopWords("../dicts/stopwords.gbk.v1.0"))
	{
		cerr<<__FILE__<<__LINE__<<endl;
		return ;
	}
	ifstream ifile(filePath);
	vector<KeyWordInfo> res;
	string line;
	while(getline(ifile, line))
	{
		res.clear();
		if(!line.empty())
		{
			ext.extract(line, res, 20);
			cout<<line<<'\n'<<joinWordInfos(res)<<endl;
		}

	}
	ext.dispose();
}
Beispiel #2
0
int main(int argc, char * argv[])
{
    LogInfo("program start ...");
    TaggerClient taggerClient;
    LogicalSegment logicalSegment;
    KeyWordExt keywordExt;
    WordCluster wordCluster;
    TemplateExtractor tplExt;
    taggerClient.init();
    logicalSegment.init();
    keywordExt.init();
    wordCluster.init();
    tplExt.init();

    string s = loadFile2Str("sample_input.txt");
    string res = taggerClient.run(s);
    vector<SentenceBlockSt>  SBs = logicalSegment.run(res);
    FOR_VECTOR(SBs, i)
    {
        keywordExt.run(SBs[i]);
        wordCluster.run(SBs[i]);
        tplExt.run(SBs[i]);
        printSentenceBlockSt(SBs[i]);
        getchar();
    }
void testKeyWordExt2(const char * dictPath, const char * filePath)
{
	Segment seg;
	seg.init();
	KeyWordExt ext;
	ext.init();

	if(!seg.loadSegDict(dictPath))
	{
		cerr<<__FILE__<<__LINE__<<endl;
		return ;
	}

	if(!ext.loadSegDict(dictPath));
	{
		cerr<<__FILE__<<__LINE__<<endl;
		return ;
	}

	ifstream ifile(filePath);
	vector<string> words;
	vector<KeyWordInfo> res;
	string line;
	while(getline(ifile, line))
	{
		if(!line.empty())
		{
			seg.cutDAG(line, words);
			ext.extract(words, res, 20);
			cout<<line<<"\n"<<joinWordInfos(res)<<endl;
		}

	}
	seg.dispose();
	ext.dispose();
}