📄 myreductshortener.cpp
字号:
//-------------------------------------------------------------------// Author........: Aleksander 豩rn// Date..........:// Description...:// Revisions.....://===================================================================#include <stdafx.h> // Precompiled headers.#include <copyright.h>#include <kernel/algorithms/myreductshortener.h>#include <kernel/algorithms/keyword.h>#include <kernel/structures/reduct.h>#include <kernel/structures/reducts.h>#include <kernel/utilities/mathkit.h>#include <kernel/basic/bits.h>#include <kernel/basic/message.h>//-------------------------------------------------------------------// Methods for class MyReductShortener.//===================================================================//-------------------------------------------------------------------// Constructors/destructor.//===================================================================MyReductShortener::MyReductShortener() { SetShorteningStrategy(0); SetLowerPercentage(0.0f); SetUpperPercentage(90.0f); SetAttribute(0); SetPrimaryAttribute(0); SetSecondaryAttribute(1);}MyReductShortener::~MyReductShortener() {}//-------------------------------------------------------------------// Methods inherited from Identifier.//===================================================================IMPLEMENTIDMETHODS(MyReductShortener, MYREDUCTSHORTENER, ReductShortener)//-------------------------------------------------------------------// Methods inherited from Algorithm.//===================================================================//-------------------------------------------------------------------// Method........: GetParameters// Author........: Aleksander 豩rn// Date..........:// Description...:// Comments......:// Revisions.....://===================================================================StringMyReductShortener::GetParameters() const { String parameters; // Shortening strategy (compound). parameters += Keyword::Shortening(); parameters += Keyword::Assignment(); parameters += String::Format(GetShorteningStrategy()); parameters += Keyword::Separator(); // Percentage parameters. if (GetShorteningStrategy() & SHORTENING_PERCENTAGE) { parameters += Keyword::Percentage() + Keyword::Dot() + Keyword::Lower(); parameters += Keyword::Assignment(); parameters += String::Format(GetLowerPercentage()); parameters += Keyword::Separator(); parameters += Keyword::Percentage() + Keyword::Dot() + Keyword::Upper(); parameters += Keyword::Assignment(); parameters += String::Format(GetUpperPercentage()); parameters += Keyword::Separator(); } // Occurrence parameters. if (GetShorteningStrategy() & SHORTENING_OCCURRENCE) { parameters += Keyword::Attribute(); parameters += Keyword::Assignment(); parameters += String::Format(GetAttribute()); parameters += Keyword::Separator(); } // Combined occurrence parameters. if (GetShorteningStrategy() & SHORTENING_COMBINEDOCCURRENCE) { parameters += Keyword::Primary(); parameters += Keyword::Assignment(); parameters += String::Format(GetPrimaryAttribute()); parameters += Keyword::Separator(); parameters += Keyword::Secondary(); parameters += Keyword::Assignment(); parameters += String::Format(GetSecondaryAttribute()); parameters += Keyword::Separator(); } return parameters + ReductFilter::GetParameters();}//-------------------------------------------------------------------// Method........: SetParameter// Author........: Aleksander 豩rn// Date..........:// Description...:// Comments......:// Revisions.....://===================================================================boolMyReductShortener::SetParameter(const String &keyword, const String &value) { // Shortening strategy. if (keyword == Keyword::Shortening() && value.IsInteger()) return SetShorteningStrategy(value.GetInteger()); if (keyword == Keyword::Shortening() && value == GetString(SHORTENING_PERCENTAGE)) return SetShorteningStrategy(GetShorteningStrategy() | SHORTENING_PERCENTAGE); if (keyword == Keyword::Shortening() && value == GetString(SHORTENING_OCCURRENCE)) return SetShorteningStrategy(GetShorteningStrategy() | SHORTENING_OCCURRENCE); if (keyword == Keyword::Shortening() && value == GetString(SHORTENING_COMBINEDOCCURRENCE)) return SetShorteningStrategy(GetShorteningStrategy() | SHORTENING_COMBINEDOCCURRENCE); // Lower percentage. if ((keyword == Keyword::Percentage() + Keyword::Dot() + Keyword::Lower()) && value.IsFloat()) return SetLowerPercentage(value.GetFloat()); // Lower percentage (backwards compatibility). if (keyword == Keyword::LPercentage() && value.IsFloat()) return SetLowerPercentage(value.GetFloat()); // Upper percentage. if ((keyword == Keyword::Percentage() + Keyword::Dot() + Keyword::Upper()) && value.IsFloat()) return SetUpperPercentage(value.GetFloat()); // Upper percentage (backwards compatibility). if (keyword == Keyword::UPercentage() && value.IsFloat()) return SetUpperPercentage(value.GetFloat()); // Attribute, absolute presence. if (keyword == Keyword::Attribute() && value.IsInteger()) return SetAttribute(value.GetInteger()); // Attribute, primary, relative presence. if (keyword == Keyword::Primary() && value.IsInteger()) return SetPrimaryAttribute(value.GetInteger()); // Attribute, secondary, relative presence. if (keyword == Keyword::Secondary() && value.IsInteger()) return SetSecondaryAttribute(value.GetInteger()); return ReductFilter::SetParameter(keyword, value);}//-------------------------------------------------------------------// Method........: Apply// Author........: Aleksander 豩rn// Date..........:// Description...: Takes a reduct set as input and shortens each reduct// according to some shortening scheme.//// Attribute indices are virtual, i.e. relative to the// masked table.//// Comments......: Assumes that library clients use handles.//// Compound criterion currently functions as an 'OR',// perhaps it should function as an 'AND'...?//// Revisions.....: A
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -