Example #1
0
void CTraceZler::ProcessTrList2()
{
	m_nTraceStage = 2;
	if (FetchTrList2(m_nIdxRed) == false)
	{
		ReorderResult();
		OutputResult();
		OnTraceEnd();
		return;
	}
	SendViewInd_CrackState();
	SendMenuInd_CrackState();

	//初始化破解线程,并启动定时器
	TCrackParam tCrackParam;
	tCrackParam.board = board;
	tCrackParam.bPesudo = false;
	tCrackParam.nMaxDepth = (m_nTraceRound ? m_nTraceRound : 40) * 2;
	tCrackParam.nFurther = 0;
	tCrackParam.src = TrList2[m_nIdxRed - 1].src;
	tCrackParam.dest = TrList2[m_nIdxRed - 1].dest;
	WChess_InitThreadRFCrack(&tCrackParam);

	window->SetTimer(TM_UPDATE_VIEW, 1000);
	window->SetTimer(TM_TRACE_GUARD, 600 * 1000);
}
Example #2
0
void SearchWorker::Go()
{	
	local_queries.Clear();
	SetupThreadQueries(*global_queries, local_queries, thread_id, options->running_options->num_threads);
	if (local_queries.max_length == 0) return;
	
    local_queries.MakeBlastnaQuery();
    local_queries.GetScanRanges(options->seed_options->seed_size, dust_masker, window_masker);
    BLAST_GapAlignSetup();
	
    Seeding();

	PrelimSearchStage(seeds,
					  &local_queries,
					  dbinfo,
					  options->seed_options->seed_size,
					  ungapped_results,
					  gapped_results,
					  word_params,
					  sbp,
					  hit_params,
					  &itree,
					  options->hit_options->min_diag_separation,
					  gapped_aligner,
					  soa);

    BLAST_ComputeTraceback(); 
	
    OutputResult(results);

	local_queries.query_names.set_data(NULL, 0, 0, TRUE);
    local_queries.query_offsets.set_data(NULL, 0, 0, TRUE);
    local_queries.org_queries.set_data(NULL, 0, 0, TRUE);
}
Example #3
0
void StarWay(const std::string & inFile, const std::string & outFile)
{
	std::vector<Planet> planets;
	if (ReadFile(planets, inFile))
	{
		MarksPlanets(planets);
		FindWay(planets);
		OutputResult(planets, outFile);
	}
}
Example #4
0
void TestSegmentation::Run(const string filename)
{
	//string filename = "dgk_shooter_z.conv";

	try
	{
		HopeLove::InitializeBrain("..\\Data\\");

	}
	catch (const std::exception& e)
	{
		cout << e.what() << endl;
	}

	ofstream out("Incorrect segmentation.txt");

// 	string raw = "合金材、优质板分别增加21.7%和28%特别是市场紧俏的优质镀锌钢丝和镀锌钢丝绳分别比去年同期增长60.8%和94.8%,";
// 	vector<vector<string>> result2 = HopeLove::WordSegmentAll(raw.c_str(), HopeLove::ForwardSegment);


	int correctNum = 0;
	int totalNum = 0;
	vector<SentenceSample> samples = ReadSentences(filename);

	for (unsigned int i=0;i<samples.size();++i)
	{
		try
		{
			vector<vector<string>> result = HopeLove::WordSegmentAll(samples[i].raw.c_str(), HopeLove::BackwardSegment);
			if (IsCorrect(samples[i].segmented, result))
			{
				correctNum++;
			}
			else
			{
				OutputResult(samples[i].segmented, result, out);
			}

			++totalNum;
		}
		catch (const std::exception&)
		{
			continue;
		}
		
	}

	cout << "Correct Ratio: " << (double)correctNum / totalNum << endl;
	cout << "Total Number: " << totalNum << endl;
}
Example #5
0
void TestPOSTagging::Run(const string corpusFilename)
{
	//Running too slow
	try
	{
		HopeLove::InitializeBrain("..\\Data\\");

	}
	catch (const std::exception& e)
	{
		cout << e.what() << endl;
	}

	ofstream out("Incorrect posTagging.txt");

	auto samples = ReadSentences(corpusFilename);
	int correctNum = 0;
	int totalNum = 0;

	for (unsigned int i = 0; i < samples.size(); ++i)
	{
		try
		{
			auto result = HopeLove::POSTagging(samples[i].raw);
			if (IsCorrect(samples[i].POSTag, result))
			{
				correctNum++;
			}
			else
			{
				OutputResult(samples[i].POSUnsplit, result, out);
			}

			++totalNum;
		}
		catch (const std::exception&)
		{
			continue;
		}

	}

	cout << "Correct Ratio: " << (double)correctNum / totalNum << endl;
	cout << "Total Number: " << totalNum << endl;
}
Example #6
0
void cScenarioArmEval::Update(double time_elapsed)
{
	cScenarioArm::Update(time_elapsed);
	UpdateTrackError();

	if (mErrSampleCount == mMaxSamples)
	{
		if (mOutputFile != "")
		{
			OutputResult(mOutputFile);
		}
	}

	if (mOutputData)
	{
		OutputData();
	}
}
Example #7
0
void FNAnalyseMgr::RunOnCondition() {
	
	m_vctResult.clear();
	
	FNAnalyser* pAnalyser = FNAnalyserFactory::sharedInstance()->getAnalyser(0);
	
	assert(pAnalyser);
	
	for (std::map<int, std::vector<FNData> >::iterator iter = m_dicStockData.begin(); iter != m_dicStockData.end(); ++iter) {

		if (pAnalyser->AnalyserData(iter->second)) {
			
			m_vctResult.push_back(iter->first);
		}
	}

	OutputResult();
}
Example #8
0
BOOL CConsumer::ConsumerProcessTrace(TRACEHANDLE hTrace, DWORD processId, LPWSTR logFilePath)
{


// 	HRESULT hr = ConnectToETWNameSpace(_bstr_t(L"root\\wmi"));
// 	if(FAILED(hr))
// 	{
// 		wprintf(L"ConnectoETWNameSpace failed with 0x%x\r\n", hr);	
// 	}
	m_logFilePath = logFilePath;
	m_processId = processId;

	SymSetOptions(SYMOPT_DEBUG);

	HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS,FALSE, m_processId);
	if(hProcess == NULL)
	{
		wprintf(L"OpenProcess Failed with %lu\r\n", GetLastError());
	}
	else
	{

		HMODULE hMod[1024];
		DWORD	cbNeeded;
		TCHAR	szModName[MAX_PATH] = {0};
		std::string pdbSerchPath = "\\\\192.168.14.181\\public\\symbols\\";
		std::string finalSearchPath = "d:\\symbolslocal";
		if(EnumProcessModules(hProcess, hMod, sizeof(hMod), &cbNeeded))
		{
			for(int i = 0; i < cbNeeded / sizeof(HMODULE); ++i)
			{
				pdbSerchPath = "\\\\192.168.14.181\\public\\symbols\\";
				ZeroMemory(szModName, sizeof(szModName));
				if(GetModuleFileNameEx(hProcess, hMod[i], szModName, sizeof(szModName)))
				{
					CFileVersion fileVer;
					if(fileVer.Open(szModName))
					{
						CString strVer = fileVer.GetFixedProductVersion();
						std::wstring modName = szModName;
						DWORD index = modName.rfind(L'\\');
						DWORD suffixIndex = modName.rfind(L'.');
						if(index)
						{
							modName = modName.substr(index+1,suffixIndex - index -1);
						}
						modName += L"\\";
						modName += strVer.GetBuffer();
						strVer.ReleaseBuffer();

						char modPdbPath[MAX_PATH] = {0};
						WideCharToMultiByte(CP_ACP,0, modName.c_str(), -1, modPdbPath, MAX_PATH, NULL, FALSE);

						pdbSerchPath += modPdbPath;
						if(PathFileExistsA(pdbSerchPath.c_str()))
						{
							finalSearchPath = finalSearchPath + ";" + pdbSerchPath;
						}

					}
				}
			}
			finalSearchPath = finalSearchPath + ";" + "\\\\192.168.14.181\\public\\symbols\\Thunder\\7.9.19.4736";
			BOOL bRet = SymInitialize ( 
				hProcess, // Process handle
				finalSearchPath.c_str(),       // user-defined search path -> use default 
				TRUE                 // load symbols for modules in the current process 
				); 
			m_processHandle = hProcess;
		}

		//std::string pdbSerchPath = "\\\\192.168.14.181\\public\\symbols\\Thunder\\7.9.19.4736;D:\\develop\\thunder\\pdb\\Release";		
	}
	

	ULONG status = ProcessTrace(&hTrace, 1, 0, 0);
	if(ERROR_SUCCESS != status && ERROR_CANCELLED != status)
	{
		wprintf(L"ProcessTrace failed with %u\r\n", status);
	}
	else
	{
		OutputResult();
	}
	//CoUninitialize();
	return TRUE;
}
Example #9
0
File: main.cpp Project: Hadel/Orion
int main(int argc, char **argv)
{
	if( argc < 2)
	{
		std::cout << SYNTAX << std::endl;
		return 1;
	}

	std::vector<bool> FindLowest;
	ALGO SelectedAlgo = DEPTH;
	bool ComputeLastNode = true;
	bool HasLabels = false;

	long NumArg = 0;
	while( ++NumArg < argc - 1)
	{
		if( strcmp( argv[NumArg], "-s") == 0)
		{
			if( ++NumArg == argc - 1)
			{
				std::cout << SYNTAX << std::endl;
				return 1;
			}

			for( unsigned long j = 0; j < strlen( argv[NumArg]); j++)
				switch( argv[NumArg][j])
				{
					case 'l':	FindLowest.push_back(true);
								break;
					case 'u':	FindLowest.push_back(false);
								break;
					default :	std::cout << SYNTAX << std::endl;
								return 1;
				}
		}
		else if( strcmp( argv[NumArg], "-a") == 0)
		{
			if( ++NumArg == argc - 1)
			{
				std::cout << SYNTAX << std::endl;
				return 1;
			}

			if( strcmp( argv[NumArg], "depth") == 0)
				SelectedAlgo = DEPTH;
			else if( strcmp( argv[NumArg], "breadth") == 0)
				SelectedAlgo = BREADTH;
			else if( strcmp( argv[NumArg], "br_dom") == 0)
				SelectedAlgo = BR_DOM;
			else
			{
				std::cout << SYNTAX << std::endl;
				return 1;
			}
		}
		else if( strcmp( argv[NumArg], "-nolast") == 0)
		{
			ComputeLastNode = false;
		}
		else if( strcmp( argv[NumArg], "-label") == 0)
		{
			HasLabels = true;
		}
		else
		{
			std::cout << SYNTAX << std::endl;
			return 1;
		}
	}

	if( strcmp( argv[NumArg], "-h") == 0 || strcmp( argv[NumArg], "--help") == 0)
	{
		std::cout << SYNTAX << std::endl;
		return 1;
	}

	double* matrice = 0;
	long NombrePoints = 0;
	long NombreDimensions = 0;
	std::vector<std::string>* Labels = 0;
	if( HasLabels)
		Labels = new std::vector<std::string>;

	if( ! ParseFileIntoMatrix( argv[NumArg], FindLowest.size(), matrice, NombrePoints, NombreDimensions, Labels))
	{
		std::cout << "Error in data set parsing" << std::endl;
		return 1;
	}

	if( FindLowest.size() == 0)
		for( int j = 0; j < NombreDimensions; j++)
			FindLowest.push_back(true);

	ArbreCube bouleau( matrice, FindLowest, NombrePoints, NombreDimensions);

	// we start creating the result filename here to use the switch once
	std::string FichierResultat( argv[NumArg]);

	std::cout << "Selected algorithm ";
	switch( SelectedAlgo)
	{
		case DEPTH: 	if( ComputeLastNode)
						{
							std::cout << "Orion-Clos: Depth with last node first" << std::endl;
							FichierResultat += ".del.";
						}
						else
						{
							std::cout << "Depth" << std::endl;
							FichierResultat += ".dep.";
						}
						bouleau.DepthAlgo(ComputeLastNode);
						std::cout << "Processed nodes: " << bouleau.GetNbProcessedNodes() << std::endl;
						std::cout << "Closure nodes: " << bouleau.GetNbClos() << "/";
						std::cout <<  (1 << NombreDimensions) - 1 << std::endl;
						std::cout << "Skyline points found directly / by BNL: " << bouleau.GetNbSkylineFoundDirectly();
						std::cout << "/" << bouleau.GetNbSkylineFoundByBNL() << std::endl;
						break;
		case BREADTH:	std::cout << "Orion: Breadth" << std::endl;
						bouleau.BreadthAlgo(false);
						FichierResultat += ".bre.";
						break;
		case BR_DOM:	std::cout << "Orion-Tail: Breadth with domains" << std::endl;
						bouleau.BreadthAlgo(true);
						FichierResultat += ".brd.";
						break;
	}
	std::cout << "Type I nodes: " << bouleau.GetNbType1() << "/" <<  (1 << NombreDimensions) - 1 << std::endl;

	/////////////////////////////////////////////////////////////////////////////////////////
	// Stat of the day

	std::cout << "Peak memory usage: " << GetMemInfo() << std::endl;

#ifndef BENCH
	/////////////////////////////////////////////////////////////////////////////////////////
	// Storing result somewhere

	OutputResult( bouleau, FindLowest, SelectedAlgo, FichierResultat, Labels);

#endif // BENCH

	delete[] matrice;

	return 0;
}
Example #10
0
/*--------------------------------*/
int main( int argc, char** argv )
{

   /* recognition object and error */
   Reco_t reco;
   RecoError_t recoError;

   // The recognition semaphores for TIesrSI Callbacks
#if defined (LINUX)
   sem_t start_semaphore;
   sem_t done_semaphore;
   int result;
#elif defined ( WIN32 )
#endif

#if defined (DEBUG)
   mtrace( );
#endif

   // The TIesrSI recognizer instance variable.  It will hold a
   // TIesrSI recognizer instance.
   TIesrSI_t tiesrSI;
   TIesrSI_Error_t siError;


   /* speech data input file list variables */

   /* Initialization of reco structure with command line arguments */
   if( argc != 6 && argc != 7 )
   {
      printf( "Invalid argument count\n" );
      return 1;
   }

   reco.memorySize = atoi( argv[1] );
   reco.grammarDir = argv[2];
   reco.jacFile = argv[3];
   reco.sbcFile = argv[4];
   reco.audioDevice = argv[5];

   if( argc == 7 )
      reco.captureFile = argv[6];
   else
      reco.captureFile = NULL;



   /* Initialize app recognizer state */
   reco.state = IDLE;
   reco.tiesrIsOpen = FALSE;


#if defined ( LINUX )
   /* Initialize the recognition TIesr callback semaphores */
   reco.start_semaphore = &start_semaphore;
   sem_init( reco.start_semaphore, 0, 0 );

   reco.done_semaphore = &done_semaphore;
   sem_init( reco.done_semaphore, 0, 0 );

#elif defined ( WIN32 )
   reco.start_event = CreateEvent( NULL, FALSE, FALSE, NULL );
   reco.done_event = CreateEvent( NULL, FALSE, FALSE, NULL );
#endif


   /* Create a TIesrSI recognizer instance */
   printf( "Creating TIesrSI recognizer\n" );
   siError = TIesrSI_create( &tiesrSI );
   if( siError != TIesrSIErrNone )
   {
      printf( "TIesrSI create error %d\n", siError );
      return 1;
   }
   reco.tiesrSI = tiesrSI;


   /* Open the recognizer instance */
   printf( "Opening TIesrSI recognizer\n" );
   recoError = OpenTIesr( &reco );
   if( recoError != RecoErrNone )
   {
      printf( "Could not open TIesr\n" );
      TIesrSI_destroy( tiesrSI );
      exit( recoError );
   }

int i;
for (i=0;i<10;i++)
{
printf( "Loop%d\n",i );


   /* Start TIesr recognition.  TIesrSI will start recognition in a
   new thread. */
   printf( "Starting TIesrSI recognizer\n" );
   recoError = StartTIesr( &reco );
   if( recoError != RecoErrNone )
   {
      printf( "Could not start TIesr\n" );
      CloseTIesr( &reco );
      TIesrSI_destroy( tiesrSI );
      exit( recoError );
   }

   /* Wait for recognizer to be ready to receive speech.  The TIesrSI
    recognizer will call the SpeakCallback function to signal this
    semaphore when ready. Normally you would do other processing during this
    time and the callback would signal an event when the recognizer is ready. */
#if defined ( LINUX )
   do
   {
      result = sem_wait( reco.start_semaphore );
   }
   while( result && errno == EINTR );
#elif defined ( WIN32 )
   WaitForSingleObject( reco.start_event, INFINITE );
#endif
   if( reco.speakResult != TIesrSIErrNone )
   {
      printf( "Recognizer not ready - spoke too early?\n" );
      StopTIesr( &reco );
      CloseTIesr( &reco );
      TIesrSI_destroy( tiesrSI );
      exit( reco.speakResult );
   }

   /* Prompt user for speech */
   printf( "Speak now...\n" );


   /* Wait for recognition to complete.  TIesrSI will call DoneCallback to
    set the semaphore when recognition is complete.  Normally you would do
    processing at this time, and the callback would signal an event
    when complete. */
#if defined ( LINUX )
   do
   {
      result = sem_wait( reco.done_semaphore );
   }
   while( result && errno == EINTR );
#elif defined ( WIN32 )
   WaitForSingleObject( reco.done_event, INFINITE );
#endif





   /* Stop the recognizer (this also formalizes recognition results
   // within TIesrSI ) */
   printf( "Stopping TIesrSI recognizer...\n" );
   recoError = StopTIesr( &reco );
	 printf( "Stopped TIesrSI recognizer\n" );
   if( recoError != RecoErrNone )
   {
      printf( "Recognizer stop failure\n" );
      CloseTIesr( &reco );
      TIesrSI_destroy( tiesrSI );
      exit( recoError );
   }


   // Check recognition result, and if a recognition result is available
   // output the result.
   if( reco.doneResult != TIesrSIErrNone )
   {
      printf( "Recognition failed with error %d\n", reco.doneResult );

      int recoStatus, audioStatus, jacStatus;
      TIesrSI_status( reco.tiesrSI, &recoStatus, &audioStatus, &jacStatus );
      printf( "Reco: %d  Audio: %d JAC: %d\n", recoStatus, audioStatus, jacStatus );

   }
   else
   {
			printf( "Calling OutputResult\n" );
      OutputResult( reco.tiesrSI );
   }
}


   /* Close the recognizer on this file */
   printf( "Closing TIesrSI recognizer\n" );
   recoError = CloseTIesr( &reco );
   if( recoError != RecoErrNone )
   {
      printf( "Failed to close TIesr recognizer\n" );
      exit( recoError );
   }

   /* Destroy the recognizer instance */
   printf( "Destroying TIesrSI recognizer\n" );
   siError = TIesrSI_destroy( reco.tiesrSI );

   /* destroy the semaphore */
#if defined ( LINUX )
   sem_destroy( reco.start_semaphore );
   sem_destroy( reco.done_semaphore );
#elif defined ( WIN32 )
   CloseHandle( reco.start_event );
   CloseHandle( reco.done_event );
#endif

   if( siError != TIesrSIErrNone )
      return siError;

   return TIesrSIErrNone;
}