<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 CONTEXTFIELDRANGEPROVIDER_H_
#define CONTEXTFIELDRANGEPROVIDER_H_

#include "runtime/provider/range/RangeProvider.h"

using namespace Poco;

namespace Myriad {

// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
// range provider for constant ranges
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

template<typename RangeType, class CxtRecordType, class InvertibleFieldSetterType>
class ContextFieldRangeProvider: public RangeProvider<RangeType, CxtRecordType>
{
public:

    ContextFieldRangeProvider(InvertibleFieldSetterType& fieldSetter) :
        RangeProvider<RangeType, CxtRecordType>(0),
        _fieldSetter(fieldSetter)
    {
    	if (!_fieldSetter.invertible())
    	{
    		throw LogicException("Cannot use non-invertible FieldSetter in ContextFieldRangeProvider");
    	}
    }

    virtual ~ContextFieldRangeProvider()
    {
    }

    virtual const Interval<RangeType> operator()(const AutoPtr<CxtRecordType>& ctxRecordPtr, RandomStream& random)
    {
        return _fieldSetter.fieldValueRange(ctxRecordPtr);
    }

private:

    const InvertibleFieldSetterType& _fieldSetter;
};

} // namespace Myriad

#endif /* CONTEXTFIELDRANGEPROVIDER_H_ */
<commit_msg>Further progress on the new runtime components.<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 CONTEXTFIELDRANGEPROVIDER_H_
#define CONTEXTFIELDRANGEPROVIDER_H_

#include "runtime/provider/range/RangeProvider.h"

using namespace Poco;

namespace Myriad {

// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
// range provider for constant ranges
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

template<typename RangeType, class CxtRecordType, class InvertibleFieldSetterType>
class ContextFieldRangeProvider: public RangeProvider<RangeType, CxtRecordType>
{
public:

    ContextFieldRangeProvider(InvertibleFieldSetterType& fieldSetter) :
        RangeProvider<RangeType, CxtRecordType>(0),
        _fieldSetter(fieldSetter)
    {
    	if (!_fieldSetter.invertible())
    	{
    		throw LogicException("Cannot use non-invertible FieldSetter in ContextFieldRangeProvider");
    	}
    }

    virtual ~ContextFieldRangeProvider()
    {
    }

    virtual const Interval<RangeType> operator()(const AutoPtr<CxtRecordType>& ctxRecordPtr, RandomStream& random)
    {
        return _fieldSetter.fieldValueRange(ctxRecordPtr);
    }

private:

    InvertibleFieldSetterType& _fieldSetter;
};

} // namespace Myriad

#endif /* CONTEXTFIELDRANGEPROVIDER_H_ */

{'fraction_non_alphanumeric': 0.11644190871369295, 'fraction_numerical': 0.006742738589211619, 'mean_word_length': 3.6191616766467067, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5997918', 'n_tokens_mistral': 1206, 'n_tokens_neox': 1149, 'n_words': 307}