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


C++ Searcher::search方法代码示例

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


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

示例1: search

int search(int argc, char *argv[])
{
	Searcher searcher;

	if (searcher.load(argv[2]) == false)
	{
		cout << "Unable to load index file - file does not exist or is corrupt.\n";
		return -1;
	}

	cout << "Successfully loaded index file.\n";
	std::string query;

	for (;;)
	{
		cout << "Enter your search terms: ";
		getline(cin, query);
		if (query.empty())
			break;

		auto results = searcher.search(query);
		if (results.size() == 0)
			cout << "No results found\n";
		else
		{
			cout << "\n" << results.size() << " matches found:\n";
			for (size_t i = 0; i<results.size(); i++)
				cout << results[i] << endl;
		}
		cout << endl;
	}

	return 0;
}
开发者ID:nehcney,项目名称:Search-Engine,代码行数:34,代码来源:main.cpp

示例2: main

int main()
{
    std::vector <Pair> ghostery_mock = {{0, "doubleclick.com"}, {1, "advertising.com"}, {2, "valueclick.com"}};
    Searcher mysearcher = Searcher(ghostery_mock);
    std::vector <int> res;
    res = mysearcher.search("doubleclick.com/blah?click=advertising.com");

  std::vector <Pair> bigtest_mock;

  std::string line;
  std::ifstream fp ("/usr/share/dict/words");
  int cnt = 0;
  if (fp.is_open())
  {
    while ( fp.good() )
    {
      getline (fp,line);
      Pair line_pair = Pair(cnt, line);

      bigtest_mock.push_back(line_pair);
      cnt+=1;
    }
    fp.close();
  }else{
   std::cout << "Unable to open file"; 
  }

  mysearcher = Searcher(bigtest_mock);
  #define MAX_RUNS 1000

  clock_t start_time = clock();

  fp.seekg(0);
  for(int i = 0; i < MAX_RUNS; i++)
  {
    std::string word;
    getline (fp,word);
    mysearcher.search(word);
  }
  clock_t end_time = clock();
  std::cout <<  "Searching inside of the dictionary took: " << (end_time- start_time)/float(CLOCKS_PER_SEC) << std::endl;

  return 0;
}
开发者ID:mike-seiler,项目名称:techtalk,代码行数:44,代码来源:searcher_main.C

示例3: testSearchLeadsToCorrectSolution

void SearcherTest::testSearchLeadsToCorrectSolution(Searcher searcher, std::string algorithm) {
	searcher.setAlgorithm(algorithm);
	searcher.initializeSingleSource();
	searcher.heapInsertAll();
	searcher.search();
	int* path = searcher.getPath();
	int* distance = searcher.getDistance();
	assert(path[16] == 3  && distance[16] == 1);
	assert(path[20] == 19 && distance[20] == 5);
	assert(path[62] == 49 && distance[62] == 11);
	assert(path[69] == 70 && distance[69] == 18);
	assert(path[95] == 82 && distance[95] == 20);
}
开发者ID:kimmosuo,项目名称:TiRaLab,代码行数:13,代码来源:SearcherTest.cpp

示例4: main

int main(int argc, char *argv[]) {
	// Main application entry point
	
	// Possible configurations to combine are listed here
	// maybe in future it'll change to some arrays or preprocessor operations...
	Input testPhotoInput("E:\\samoloty\\HappyFish.jpg", Input::Type::Photo);

	Searcher standardSearcher(100, 200);

	Recognizer handRecognizer;

	Player pianoPlayer(Player::Tone::Piano);

	// Run combination - choose one from possibilities of each part of processing chain
	// Input->Search->Recognize->Play
	Input *mainInput = &testPhotoInput;
	Searcher *mainSearcher = &standardSearcher;
	Recognizer *mainRecognizer = &handRecognizer;
	Player *mainPlayer = &pianoPlayer;

	// Needed variables and buffers
	Image *currentImage;
	Object *objects = new Object();
	Object *recognizedObjects;

	// Some handy variables
	int count;

	while (true) {
		currentImage = mainInput->getCurrentImage();
		count = mainSearcher->search(currentImage, objects);
		//count = mainRecognizer->recognize(objects, count, recognizedObjects);
		for (; count >= 0; --count) {
			mainPlayer->play();
		}
		delete /*recognizedObjects*/ /*objects*/ currentImage;
	}

	delete mainPlayer, mainRecognizer, mainSearcher, mainInput;
	
	return 0;
}
开发者ID:Bobinho,项目名称:KodalyPlayer,代码行数:42,代码来源:main.cpp


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