<commit_before>/*
 * Copyright 2010-2011 DIMA Research Group, TU Berlin
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * @author: <NAME> <<EMAIL>>
 */

#ifndef ABSTRACTGENERATORCONFIG_H_
#define ABSTRACTGENERATORCONFIG_H_

#include "core/types.h"
#include "config/ObjectBuilder.h"
#include "config/FunctionPool.h"
#include "math/probability/Probability.h"
#include "math/random/RandomStream.h"

#include <string>
#include <Poco/AutoPtr.h>
#include <Poco/Exception.h>
#include <Poco/Logger.h>
#include <Poco/Path.h>
#include <Poco/Util/LayeredConfiguration.h>
#include <Poco/SAX/XMLReader.h>
#include <Poco/DOM/Document.h>
#include <Poco/DOM/NodeList.h>
#include <Poco/DOM/Element.h>
#include <Poco/DOM/Node.h>

using namespace std;
using namespace Poco;
using namespace Poco::Util;

namespace Myriad {

/**
 * A layered configuration used by the generator objects both as storage
 * v as well as an access point to some relevant sections from the
 * common application configuration.
 */
class AbstractGeneratorConfig: public LayeredConfiguration
{
public:

	AbstractGeneratorConfig() :
		_masterPRNG("master_prng"),
		_logger(Logger::get("generator.config"))
	{
	}

	void initialize(AbstractConfiguration& appConfig);

	void addFunction(AbstractFunction* functionPtr)
	{
		_functionPool.addFunction(functionPtr);
	}

	template<class C> C& func(const string& name) const
	{
		return _functionPool.func<C>(name);
	}

	ID cardinality(string name)
	{
		return fromString<I64u>(getString("generator." + name + ".sequence.cardinality"));
	}

	ID genIDBegin(string name)
	{
		return fromString<I64u>(getString("generator." + name + ".partition.begin"));
	}

	ID genIDEnd(string name)
	{
		return fromString<I64u>(getString("generator." + name + ".partition.end"));
	}

	Decimal scalingFactor()
	{
		return getInt("application.scaling-factor");
	}

	I16u numberOfChunks()
	{
		return getInt("common.partitioning.number-of-chunks");
	}

	I16u chunkID()
	{
		return getInt("common.partitioning.chunks-id");
	}<commit_msg>* fixed a bug in the getScalingFactor() method in AbstractGeneratorConfig.h<commit_after>/*
 * Copyright 2010-2011 DIMA Research Group, TU Berlin
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * @author: <NAME> <<EMAIL>>
 */

#ifndef ABSTRACTGENERATORCONFIG_H_
#define ABSTRACTGENERATORCONFIG_H_

#include "core/types.h"
#include "config/ObjectBuilder.h"
#include "config/FunctionPool.h"
#include "math/probability/Probability.h"
#include "math/random/RandomStream.h"

#include <string>
#include <Poco/AutoPtr.h>
#include <Poco/Exception.h>
#include <Poco/Logger.h>
#include <Poco/Path.h>
#include <Poco/Util/LayeredConfiguration.h>
#include <Poco/SAX/XMLReader.h>
#include <Poco/DOM/Document.h>
#include <Poco/DOM/NodeList.h>
#include <Poco/DOM/Element.h>
#include <Poco/DOM/Node.h>

using namespace std;
using namespace Poco;
using namespace Poco::Util;

namespace Myriad {

/**
 * A layered configuration used by the generator objects both as storage
 * v as well as an access point to some relevant sections from the
 * common application configuration.
 */
class AbstractGeneratorConfig: public LayeredConfiguration
{
public:

	AbstractGeneratorConfig() :
		_masterPRNG("master_prng"),
		_logger(Logger::get("generator.config"))
	{
	}

	void initialize(AbstractConfiguration& appConfig);

	void addFunction(AbstractFunction* functionPtr)
	{
		_functionPool.addFunction(functionPtr);
	}

	template<class C> C& func(const string& name) const
	{
		return _functionPool.func<C>(name);
	}

	ID cardinality(string name)
	{
		return fromString<I64u>(getString("generator." + name + ".sequence.cardinality"));
	}

	ID genIDBegin(string name)
	{
		return fromString<I64u>(getString("generator." + name + ".partition.begin"));
	}

	ID genIDEnd(string name)
	{
		return fromString<I64u>(getString("generator." + name + ".partition.end"));
	}

	Decimal scalingFactor()
	{
		return getDouble("application.scaling-factor");
	}

	I16u numberOfChunks()
	{
		return getInt("common.partitioning.number-of-chunks");
	}

	I16u chunkID()
	{
		return getInt("common.partitioning.chunks-id");
	}
{'fraction_non_alphanumeric': 0.11936805149210064, 'fraction_numerical': 0.008582016773941877, 'mean_word_length': 4.807474518686297, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7576382', 'n_tokens_mistral': 1680, 'n_tokens_neox': 1594, 'n_words': 449}