<commit_before>#include "core/eval/HierarchicalToString.hpp"
#include "loci/PopulationLocus.hpp"
#include <sstream>

HierarchicalToString::HierarchicalToString(
	HierarchicalToString::mode printMode
) {
	this->printMode = printMode;
}

HierarchicalToString::~HierarchicalToString() {}

std::string HierarchicalToString::toString(Genome* genome) {
	if (this->printMode == HierarchicalToString::flatten)
		return this->stringifySegment(
			genome->flattenGenome().getGenome()
		);

	std::vector<Gene*> genes = genome->getGenome();
	std::stringstream ss;

	std::vector<Gene*> segment;
	for (unsigned int i = 0; i < genes.size(); i++) {
		if (!genes[i]->isConstructive()) {
			segment.push_back(genes[i]);
		} else {
			ss << this->stringifySegment(segment);
			segment.clear();
			if (
				this->printMode ==
					HierarchicalToString::printPlaceholders
			) {
				ss << " ["
					<< ((PopulationLocus*)genes[i]
						->getLocus()
					)->nodeName()
					<< ":"
					<< genes[i]->getIndex()
					<< "] ";
			}
		}
	}

	return ss.str();
}
<commit_msg>[HierarchicalToString]: Fixed fencepost bug<commit_after>#include "core/eval/HierarchicalToString.hpp"
#include "loci/PopulationLocus.hpp"
#include <sstream>

HierarchicalToString::HierarchicalToString(
	HierarchicalToString::mode printMode
) {
	this->printMode = printMode;
}

HierarchicalToString::~HierarchicalToString() {}

std::string HierarchicalToString::toString(Genome* genome) {
	if (this->printMode == HierarchicalToString::flatten)
		return this->stringifySegment(
			genome->flattenGenome().getGenome()
		);

	std::vector<Gene*> genes = genome->getGenome();
	std::stringstream ss;

	std::vector<Gene*> segment;
	for (unsigned int i = 0; i < genes.size(); i++) {
		if (!genes[i]->isConstructive()) {
			segment.push_back(genes[i]);
		} else {
			ss << this->stringifySegment(segment);
			segment.clear();
			if (
				this->printMode ==
					HierarchicalToString::printPlaceholders
			) {
				ss << " ["
					<< ((PopulationLocus*)genes[i]
						->getLocus()
					)->nodeName()
					<< ":"
					<< genes[i]->getIndex()
					<< "] ";
			}
		}
	}

	ss << this->stringifySegment(segment);

	return ss.str();
}

{'fraction_non_alphanumeric': 0.17367205542725173, 'fraction_numerical': 0.0009237875288683603, 'mean_word_length': 4.334975369458128, 'pattern_counts': {'":': 2, '<': 37, '<?xml version=': 0, '>': 32, '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': '5310328', 'n_tokens_mistral': 868, 'n_tokens_neox': 730, 'n_words': 111}