Exemple #1
0
void CreateIndexes(){
	// open file, assign DocID
	// CreateRecords(cleaned_str, docid);  understand how you'll receive an array of records
	// create the index
	std::ifstream fptr;
	fptr.open("example.txt", std::ios::in);
	int len = 0;
	char* buffer;
	if(fptr.is_open()){
		fptr.seekg(0, fptr.end);
		len = fptr.tellg();
		fptr.seekg(0, fptr.beg);
		buffer = new char[len];
		fptr.read(buffer, len);
		fptr.close();
	}
	std::string file_str (buffer, len);
	std::string cleaned_str = FilterStopwords(file_str);
	std::cout << "No stopwords -- " << cleaned_str << std::endl;
	std::vector<Record*> records;
	CreateRecords(cleaned_str, 1, records);
	std::map<const std::string, int> iindex;
	for(std::vector<Record*>::iterator i = records.begin(); i != records.end(); i++){
		iindex[(*i)->term] = (*i)->docid;
	}
	for(std::map<const std::string, int>::iterator i = iindex.begin(); i != iindex.end(); i++){
		std::cout << i->first << "\t" << i->second << std::endl;
	}
}
OpenCLProgram* OpenCLContext::loadProgramFromFiles(std::vector<std::string> filenames) {
    std::vector<std::string> file_strs;
    for (int i = 0; i < filenames.size(); i++) {
        std::ifstream file (filenames[i].c_str());
        std::string file_str((std::istreambuf_iterator<char>(file)),
                             std::istreambuf_iterator<char>());
        file_strs.push_back(file_str);
    }
    return loadProgramFromStrings(file_strs);
}
Exemple #3
0
Surface *ResourceManager::get_image(const char *filename)
{
	string file_str(filename);
	if (m_images.find(file_str) == m_images.end())
	{
		char fullname[80];
		snprintf(fullname, 80, "images/%s", filename);
		m_images[file_str] = new Surface(fullname);
	}
	return m_images[file_str];
}
Exemple #4
0
void parse (const char * filename, BatchInfo * batch, size_t batch_size)
{
  std::ostringstream temp;
  std::ifstream infile (filename);
  temp << infile.rdbuf();
  std::string file_str (temp.str());
  char * fileptr  = (char *) file_str.c_str();

  for (size_t count = 0; count < batch_size; ++count)
  {
    fileptr = search_flank_5(fileptr, batch[count]);
    fileptr = search_flank_3(fileptr, batch[count]);
    fileptr = search_start(fileptr, batch[count]);
    fileptr = search_stop(fileptr, batch[count]);
  }
  
}
Exemple #5
0
bool eos::TextEditor::Logic::OpenFile(const std::string& file_path)
{
    _file_path = file_path;
    
    std::ifstream t(file_path);
    
    std::string file_str((std::istreambuf_iterator<char>(t)),
                         std::istreambuf_iterator<char>());

	// Remove all tab for string.
	ax::Utils::String::ReplaceCharWithString(file_str, '\t', "    ");	

    _file_data = ax::Utils::String::Split(file_str, "\n");
    
    _cursor_pos = ax::Point(0, 0);
    
    return true;
}
Exemple #6
0
void ResourceManager::play_music(const char *filename)
{
	string file_str(filename);
	if (m_music.find(file_str) == m_music.end())
	{
		char fullname[80];
		snprintf(fullname, 80, "music/%s", filename);
		m_music[file_str] = Mix_LoadMUS(fullname);
		if (m_music[file_str] == NULL)
			fprintf(stderr, "Mix_LoadMUS failed: %s\n", SDL_GetError());
	}
	if (m_cur_music == file_str)
		return;
	else
	{
		m_cur_music = file_str;
		Mix_PlayMusic(m_music[file_str], -1);
	}
}
Exemple #7
0
void ResourceManager::play_sound(const char *filename)
{
	string file_str(filename);
	if (m_chunk.find(file_str) == m_chunk.end())
	{
		char fullname[80];
		snprintf(fullname, 80, "sfx/%s", filename);
		m_chunk[file_str] = Mix_LoadWAV(fullname);
		if (m_chunk[file_str] == NULL)
			fprintf(stderr, "Mix_LoadChunk failed: %s\n",
			        SDL_GetError());
	}
	Mix_Chunk *chunk = m_chunk[file_str];
	if (Mix_PlayChannel(-1, chunk, 0) == -1)
	{
		fprintf(stderr, "Mix_PlayChannel failed: %s\n",
		        SDL_GetError());
		fprintf(stderr, "For file %s\n", filename);
	}
}
bool HeeksPyPostProcess(const CProgram* program, const wxString &filepath, const bool include_backplot_processing)
{
	try{
		theApp.m_output_canvas->m_textCtrl->Clear(); // clear the output window

		// write the python file
		wxStandardPaths standard_paths;
		wxFileName file_str( standard_paths.GetTempDir().c_str(), _T("post.py"));

		if(!write_python_file(file_str.GetFullPath()))
		{
		    wxString error;
		    error << _T("couldn't write ") << file_str.GetFullPath();
		    wxMessageBox(error.c_str());
		}
		else
		{
#ifdef WIN32
			// Set the working directory to the area that contains the DLL so that
			// the system can find the post.bat file correctly.
			::wxSetWorkingDirectory(theApp.GetDllFolder());
#else
			::wxSetWorkingDirectory(standard_paths.GetTempDir());
#endif

			// call the python file
			(new CPyPostProcess(program, filepath, include_backplot_processing))->Do();

			return true;
		}
	}
	catch(...)
	{
		wxMessageBox(_T("Error while post-processing the program!"));
	}
	return false;
}