本文整理汇总了C++中Search::getResults方法的典型用法代码示例。如果您正苦于以下问题:C++ Search::getResults方法的具体用法?C++ Search::getResults怎么用?C++ Search::getResults使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Search
的用法示例。
在下文中一共展示了Search::getResults方法的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++ )
//.........这里部分代码省略.........