<commit_before>#ifndef SOPNET_INFERENCE_PROBLEM_CONFIGURATION_H__
#define SOPNET_INFERENCE_PROBLEM_CONFIGURATION_H__

#include <boost/lexical_cast.hpp>

#include <pipeline/all.h>
#include <sopnet/exceptions.h>

class ProblemConfiguration : public pipeline::Data {

public:

	void setVariable(unsigned int segmentId, unsigned int variable) {

		_variables[segmentId] = variable;
	}

	unsigned int getVariable(unsigned int segmentId) {

		if (!_variables.count(segmentId))
			BOOST_THROW_EXCEPTION(
					NoSuchSegment()
					<< error_message(
							std::string("variable map does not contain an entry for segment id ") +
							boost::lexical_cast<std::string>(segmentId))
					<< STACK_TRACE);

		return _variables[segmentId];
	}

	void clear() {

		_variables.clear();
	}

private:

	// mapping of segment ids to a continous range of variable numbers
	std::map<unsigned int, unsigned int> _variables;
};

#endif // SOPNET_INFERENCE_PROBLEM_CONFIGURATION_H__
<commit_msg>Added reverse mapping to ProblemConfiguration<commit_after>#ifndef SOPNET_INFERENCE_PROBLEM_CONFIGURATION_H__
#define SOPNET_INFERENCE_PROBLEM_CONFIGURATION_H__

#include <boost/lexical_cast.hpp>

#include <pipeline/all.h>
#include <sopnet/exceptions.h>

class ProblemConfiguration : public pipeline::Data {

public:

	void setVariable(unsigned int segmentId, unsigned int variable) {

		_variables[segmentId] = variable;
		_segmentIds[variable] = segmentId;
	}

	unsigned int getVariable(unsigned int segmentId) {

		if (!_variables.count(segmentId))
			BOOST_THROW_EXCEPTION(
					NoSuchSegment()
					<< error_message(
							std::string("variable map does not contain an entry for segment id ") +
							boost::lexical_cast<std::string>(segmentId))
					<< STACK_TRACE);

		return _variables[segmentId];
	}

	unsigned int getSegmentId(unsigned int variable) {

		if (!_segmentIds.count(variable))
			BOOST_THROW_EXCEPTION(
					NoSuchSegment()
					<< error_message(
							std::string("segment id map does not contain an entry for variable ") +
							boost::lexical_cast<std::string>(variable))
					<< STACK_TRACE);

		return _segmentIds[variable];
	}

	void clear() {

		_variables.clear();
		_segmentIds.clear();
	}

private:

	// mapping of segment ids to a continous range of variable numbers
	std::map<unsigned int, unsigned int> _variables;

	// reverse mapping
	std::map<unsigned int, unsigned int> _segmentIds;
};

#endif // SOPNET_INFERENCE_PROBLEM_CONFIGURATION_H__

{'fraction_non_alphanumeric': 0.09983700081499593, 'fraction_numerical': 0.0, 'mean_word_length': 4.859188544152745, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 15, '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': '4028002', 'n_tokens_mistral': 890, 'n_tokens_neox': 775, 'n_words': 178}