当前位置: 首页>>代码示例>>C++>>正文


C++ Search::SearchForMatch方法代码示例

本文整理汇总了C++中Search::SearchForMatch方法的典型用法代码示例。如果您正苦于以下问题:C++ Search::SearchForMatch方法的具体用法?C++ Search::SearchForMatch怎么用?C++ Search::SearchForMatch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Search的用法示例。


在下文中一共展示了Search::SearchForMatch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _tmain

int _tmain(int argc, _TCHAR* argv[])
{ 
	welcomeMessage();
	
	SearchInput SearchObject;
	vector <string> SearchValues = SearchObject.processSearchInput();

	setVerbose();
	cout << endl;

	DirExplorer explore; // Open the directory
	cout << endl;
	cout << " Opening the directory... " << endl;
	vector<string> FileList = explore.getFilePaths(); // Get the names of the files from the directory 
	if (verbose) // Verbose used to indicate whether to show the next piece of code or not 
	{
		cout << "Printing the list of files found.. " << endl;
		Print(FileList);
	}

	std::vector<FileReader*> p; 
	FileReader* file;
	vector<Word> SplittedWords;
	vector<Word*> Results; 
	vector<Line> Sentences;
	Search mySearch;
	myLine.clear();
	MatchedResults.clear();
	int results = 0;
	int totalresult = 0;
	cout << " Reading and storing the matching results... " << endl;
	for ( size_t n = 0; n < FileList.size(); n++ ) // loop through the list of files in the directory 
    {
		string filename = FileList[ n ]; 
		file = new FileReader(filename);
		if ( (file->open()) != true ) // open a single file 
		{
			return false;
		}
		else
		{
			file->split(SearchValues); // split the file's content into words and store in a vector of objects 
			file->clearFile(); // clear the file's EOF flag once done with reading 
		}

	   // create Search object
		
		mySearch.SearchForMatch(SearchValues);
		results = mySearch.getResults();
		totalresult = totalresult + results;

	   p.push_back( file );		
    }
		
	if( SearchValues.size() == 1 ) // simple query
	{
		cout << " Scoring.. " << endl;
		mySearch.scoreByFrequency();
		sortData();
		cout << "/**                               RESULTS                               **/\n";
		cout << "/*----------------------------------------------------------------------**/\n";
		cout << "  Total Results: " << totalresult << "\n" << endl;
		displayResults1(); //Display the sorted array
	}
	else // composed query
	{
		cout << " Scoring.. " << endl;
		string st1 = "and";
		string st2 = "or";
		string stype = searchType;
		if ( st1.compare(stype) == 0 )
		{
			if(verbose)
			cout << "Search is of type AND" << endl;
			mySearch.scoreByDistance();
			sortData();
			cout << "/**                               RESULTS                               **/\n";
			cout << "/*----------------------------------------------------------------------**/\n";
			cout << "/**  Total Results: " << totalresult << "\n" << endl;
			displayResults2(); 
		}
		if ( st2.compare(stype) == 0 )
		{
			if(verbose)
			cout << "Search is of type OR" << endl;

			mySearch.scoreByFrequency();
			sortData();
			cout << "/**                               RESULTS                               **/\n";
			cout << "/*----------------------------------------------------------------------**/\n";
			cout << "  Total Results: " << totalresult << "\n" << endl;
			displayResults1(); //Display the sorted array
		}
		//score by frequency plus distance
	}
	

	MatchedResults.clear();
	/* Close all files */
	for ( size_t i = 0; i < p.size(); i++ )
//.........这里部分代码省略.........
开发者ID:AnumQ,项目名称:SearchPlanet,代码行数:101,代码来源:main.cpp


注:本文中的Search::SearchForMatch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。