<commit_before>/*!
  \copyright (c) RDO-Team, 2011
  \file      rdo_fuzzy.cpp
  \author      (<EMAIL>)
  \date      24.07.2008
  \brief      
  \indent    4T
*/

// ---------------------------------------------------------------------------- PCH
#include "simulator/runtime/pch/stdpch.h"
// ----------------------------------------------------------------------- INCLUDES
// ----------------------------------------------------------------------- SYNOPSIS
#include "simulator/runtime/rdo_fuzzy.h"
// --------------------------------------------------------------------------------

OPEN_RDO_RUNTIME_NAMESPACE

// --------------------------------------------------------------------------------
// -------------------- MemberFunctionProperties
// --------------------------------------------------------------------------------
LPFuzzySet FuzzySet::operator&& (CREF(LPFuzzySet) pSet) const
{
	LPFuzzySet pFuzzySetResult = rdo::Factory<FuzzySet>::create();
	ASSERT(pFuzzySetResult);
	//         
	FuzzySetDefinition::const_iterator it1 = begin();
	while (it1 != end())
	{
		FuzzySet::FuzzySetDefinition::const_iterator it2 = pSet->find(it1->first);
		if (it2 != pSet->end())
		{
			pFuzzySetResult->operator[](it1->first) = (std::min)(it1->second, it2->second);
		}
		++it1;
	}
	return pFuzzySetResult;
}

LPFuzzySet FuzzySet::operator|| (CREF(LPFuzzySet) pSet)const
{
	LPFuzzySet pFuzzySetResult = rdo::Factory<FuzzySet>::create();
	ASSERT(pFuzzySetResult);
	//    
	//      ,     
	FuzzySetDefinition::const_iterator it1 = begin();
	while (it1 != end())
	{
		FuzzySet::FuzzySetDefinition::const_iterator it2 = pSet->find(it1->first);
		if (it2 != pSet->end())
		{
			pFuzzySetResult->operator[](it1->first) = std::max(it1->second, it2->second);
		}
		else
		{
			//   
			pFuzzySetResult->operator[](it1->first) = it1->second;
		}
		++it1;
	}
	FuzzySet::FuzzySetDefinition::const_iterator it2 = pSet->begin();
	while (it2 != pSet->end())
	{
		FuzzySetDefinition::const_iterator it1 = find(it2->first);
		if (it1 == end())
		{
			//   
			pFuzzySetResult->operator[](it2->first) = it2->second;
		}
		++it2;
	}
	return pFuzzySetResult;
}
/// @todo   *.h
//!   ()        fun
LPFuzzySet MemberFunctionProperties::ext_binary(ExtBinaryFun fun, CREF(LPFuzzySet) pSet1, CREF(LPFuzzySet) pSet2)
{
	FuzzySet::FuzzySetDefinition values;
	FuzzySet::FuzzySetDefinition::const_iterator it1 = pSet1->begin();
	while (it1 != pSet1->end())
	{
		FuzzySet::FuzzySetDefinition::const_iterator it2 = pSet2->begin();
		while (it2 != pSet2->end())
		{
			RDOValue rdo_value = fun(it1->first, it2->first);
			FuzzySet::FuzzySetDefinition::iterator val = values.find(rdo_value);
			if (val == values.end())
			{
				values[rdo_value] = (std::min)(it1->second, it2->second);
			}
			else
			{
				values[rdo_value] = (std::max)(val->second, (std::min)(it1->second, it2->second));
			}
			++it2;
		}
		++it1;
	}

	if (!values.empty())
	{
		LPFuzzySet pFuzzySetResult = rdo::Factory<FuzzySet>::create();
		ASSERT(pFuzzySetResult);
		pFuzzySetResult->setValues(values);

		return pFuzzySetResult;
	}

	return LPFuzzySet();
}

//!      fun
LPFuzzySet MemberFunctionProperties::ext_unary(ExtUnaryFun fun, CREF(LPFuzzySet) pSet)
{
	FuzzySet::FuzzySetDefinition values;
	FuzzySet::FuzzySetDefinition::const_iterator it = pSet->begin();
	while (it != pSet->end())
	{
		RDOValue rdo_value = fun(it->first);
		FuzzySet::FuzzySetDefinition::iterator val = values.find(rdo_value);
		if (val == values.end())
		{
			values[rdo_value] = it->second;
		}
		else
		{
			values[rdo_value] = std::max(val->second, it->second);
		}
		++it;
	}

	if (!values.empty())
	{

		LPFuzzySet pFuzzySetResult = rdo::Factory<FuzzySet>::create();
		ASSERT(pFuzzySetResult);
		pFuzzySetResult->setValues(values);

		return pFuzzySetResult;
	}

	return LPFuzzySet();
}

LPFuzzySet MemberFunctionProperties::ext_unary(ExtUnaryFunP fun, PTR(void) pParam, CREF(LPFuzzySet) pSet)
{
	FuzzySet::FuzzySetDefinition values;
	FuzzySet::FuzzySetDefinition::const_iterator it = pSet->begin();
	while (it != pSet->end())
	{
		RDOValue rdo_value = fun(it->first, pParam);
		FuzzySet::FuzzySetDefinition::iterator val = values.find(rdo_value);
		if (val == values.end())
		{
			values[rdo_value] = it->second;
		}
		else
		{
			values[rdo_value] = std::max(val->second, it->second);
		}
		++it;
	}

	if (!values.empty())
	{

		LPFuzzySet pFuzzySetResult = rdo::Factory<FuzzySet>::create();
		ASSERT(pFuzzySetResult);
		pFuzzySetResult->setValues(values);<commit_msg> - как будто не работает NOMINMAX<commit_after>/*!
  \copyright (c) RDO-Team, 2011
  \file      rdo_fuzzy.cpp
  \author      (<EMAIL>)
  \date      24.07.2008
  \brief      
  \indent    4T
*/

// ---------------------------------------------------------------------------- PCH
#include "simulator/runtime/pch/stdpch.h"
// ----------------------------------------------------------------------- INCLUDES
// ----------------------------------------------------------------------- SYNOPSIS
#include "simulator/runtime/rdo_fuzzy.h"
// --------------------------------------------------------------------------------

OPEN_RDO_RUNTIME_NAMESPACE

// --------------------------------------------------------------------------------
// -------------------- MemberFunctionProperties
// --------------------------------------------------------------------------------
LPFuzzySet FuzzySet::operator&& (CREF(LPFuzzySet) pSet) const
{
	LPFuzzySet pFuzzySetResult = rdo::Factory<FuzzySet>::create();
	ASSERT(pFuzzySetResult);
	//         
	FuzzySetDefinition::const_iterator it1 = begin();
	while (it1 != end())
	{
		FuzzySet::FuzzySetDefinition::const_iterator it2 = pSet->find(it1->first);
		if (it2 != pSet->end())
		{
			pFuzzySetResult->operator[](it1->first) = (std::min)(it1->second, it2->second);
		}
		++it1;
	}
	return pFuzzySetResult;
}

LPFuzzySet FuzzySet::operator|| (CREF(LPFuzzySet) pSet)const
{
	LPFuzzySet pFuzzySetResult = rdo::Factory<FuzzySet>::create();
	ASSERT(pFuzzySetResult);
	//    
	//      ,     
	FuzzySetDefinition::const_iterator it1 = begin();
	while (it1 != end())
	{
		FuzzySet::FuzzySetDefinition::const_iterator it2 = pSet->find(it1->first);
		if (it2 != pSet->end())
		{
			pFuzzySetResult->operator[](it1->first) = (std::max)(it1->second, it2->second);
		}
		else
		{
			//   
			pFuzzySetResult->operator[](it1->first) = it1->second;
		}
		++it1;
	}
	FuzzySet::FuzzySetDefinition::const_iterator it2 = pSet->begin();
	while (it2 != pSet->end())
	{
		FuzzySetDefinition::const_iterator it1 = find(it2->first);
		if (it1 == end())
		{
			//   
			pFuzzySetResult->operator[](it2->first) = it2->second;
		}
		++it2;
	}
	return pFuzzySetResult;
}
/// @todo   *.h
//!   ()        fun
LPFuzzySet MemberFunctionProperties::ext_binary(ExtBinaryFun fun, CREF(LPFuzzySet) pSet1, CREF(LPFuzzySet) pSet2)
{
	FuzzySet::FuzzySetDefinition values;
	FuzzySet::FuzzySetDefinition::const_iterator it1 = pSet1->begin();
	while (it1 != pSet1->end())
	{
		FuzzySet::FuzzySetDefinition::const_iterator it2 = pSet2->begin();
		while (it2 != pSet2->end())
		{
			RDOValue rdo_value = fun(it1->first, it2->first);
			FuzzySet::FuzzySetDefinition::iterator val = values.find(rdo_value);
			if (val == values.end())
			{
				values[rdo_value] = (std::min)(it1->second, it2->second);
			}
			else
			{
				values[rdo_value] = (std::max)(val->second, (std::min)(it1->second, it2->second));
			}
			++it2;
		}
		++it1;
	}

	if (!values.empty())
	{
		LPFuzzySet pFuzzySetResult = rdo::Factory<FuzzySet>::create();
		ASSERT(pFuzzySetResult);
		pFuzzySetResult->setValues(values);

		return pFuzzySetResult;
	}

	return LPFuzzySet();
}

//!      fun
LPFuzzySet MemberFunctionProperties::ext_unary(ExtUnaryFun fun, CREF(LPFuzzySet) pSet)
{
	FuzzySet::FuzzySetDefinition values;
	FuzzySet::FuzzySetDefinition::const_iterator it = pSet->begin();
	while (it != pSet->end())
	{
		RDOValue rdo_value = fun(it->first);
		FuzzySet::FuzzySetDefinition::iterator val = values.find(rdo_value);
		if (val == values.end())
		{
			values[rdo_value] = it->second;
		}
		else
		{
			values[rdo_value] = (std::max)(val->second, it->second);
		}
		++it;
	}

	if (!values.empty())
	{

		LPFuzzySet pFuzzySetResult = rdo::Factory<FuzzySet>::create();
		ASSERT(pFuzzySetResult);
		pFuzzySetResult->setValues(values);

		return pFuzzySetResult;
	}

	return LPFuzzySet();
}

LPFuzzySet MemberFunctionProperties::ext_unary(ExtUnaryFunP fun, PTR(void) pParam, CREF(LPFuzzySet) pSet)
{
	FuzzySet::FuzzySetDefinition values;
	FuzzySet::FuzzySetDefinition::const_iterator it = pSet->begin();
	while (it != pSet->end())
	{
		RDOValue rdo_value = fun(it->first, pParam);
		FuzzySet::FuzzySetDefinition::iterator val = values.find(rdo_value);
		if (val == values.end())
		{
			values[rdo_value] = it->second;
		}
		else
		{
			values[rdo_value] = (std::max)(val->second, it->second);
		}
		++it;
	}

	if (!values.empty())
	{

		LPFuzzySet pFuzzySetResult = rdo::Factory<FuzzySet>::create();
		ASSERT(pFuzzySetResult);
		pFuzzySetResult->setValues(values);
{'fraction_non_alphanumeric': 0.2589345172031077, 'fraction_numerical': 0.013096559378468368, 'mean_word_length': 2.6130713712910985, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 113, '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': '3420125', 'n_tokens_mistral': 3553, 'n_tokens_neox': 3165, 'n_words': 462}