<commit_before>/* bzflag
 * Copyright (c) 1993 - 2003 <NAME>
 *
 * This package is free software;  you can redistribute it and/or
 * modify it under the terms of the license found in the file
 * named COPYING that should have accompanied this file.
 *
 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 */

#include "TextChunkManager.h"

bool TextChunkManager::parseFile(const std::string &fileName, const std::string &chunkName)
{
	char buffer[MessageLen];
	ifstream in(fileName.c_str());
	if (!in) return false;
	
	StringVector strings;
	for(int i = 0; i < 20 && in.good(); i++) {
		in.getline(buffer,MessageLen);
		if(!in.fail()){ // really read something
			strings.push_back(buffer);
		}
	}
	
	if (strings.size() != 0) {
		theChunks.insert(std::map<std::string, StringVector>::value_type(chunkName,strings));
		chunkNames.push_back(chunkName);
	}
	return true;
}

const std::vector<std::string>* TextChunkManager::getTextChunk(const std::string chunkName)
{
	std::map<std::string, StringVector>::const_iterator it;<commit_msg>always use std: namespace explicitly<commit_after>/* bzflag
 * Copyright (c) 1993 - 2003 <NAME>
 *
 * This package is free software;  you can redistribute it and/or
 * modify it under the terms of the license found in the file
 * named COPYING that should have accompanied this file.
 *
 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 */

#ifdef WIN32
#pragma warning( 4: 4786)
#endif

#include "TextChunkManager.h"

bool TextChunkManager::parseFile(const std::string &fileName, const std::string &chunkName)
{
	char buffer[MessageLen];
	std::ifstream in(fileName.c_str());
	if (!in) return false;
	
	StringVector strings;
	for(int i = 0; i < 20 && in.good(); i++) {
		in.getline(buffer,MessageLen);
		if(!in.fail()){ // really read something
			strings.push_back(buffer);
		}
	}
	
	if (strings.size() != 0) {
		theChunks.insert(std::map<std::string, StringVector>::value_type(chunkName,strings));
		chunkNames.push_back(chunkName);
	}
	return true;
}

const std::vector<std::string>* TextChunkManager::getTextChunk(const std::string chunkName)
{
	std::map<std::string, StringVector>::const_iterator it;
{'fraction_non_alphanumeric': 0.1274068004916018, 'fraction_numerical': 0.012699713232281851, 'mean_word_length': 5.120300751879699, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '336026', 'n_tokens_mistral': 800, 'n_tokens_neox': 747, 'n_words': 234}