?? scaler.cpp
字號(hào):
//-------------------------------------------------------------------
// Author........: Aleksander 豩rn
// Date..........: 960307
// Description...:
// Revisions.....:
//===================================================================
#include <stdafx.h> // Precompiled headers.
#include <copyright.h>
#include <kernel/algorithms/scaler.h>
#include <kernel/algorithms/keyword.h>
#include <kernel/structures/decisiontable.h>
#include <kernel/structures/dictionary.h>
#include <kernel/structures/attribute.h>
#include <kernel/structures/floatattribute.h>
#include <kernel/structures/integerattribute.h>
#include <kernel/structures/stringattribute.h>
#include <kernel/basic/vector.h>
#include <kernel/basic/algorithm.h>
#include <kernel/utilities/creator.h>
#include <kernel/utilities/mathkit.h>
#include <kernel/system/fstream.h>
#include <kernel/system/math.h>
//-------------------------------------------------------------------
// Methods for class Scaler.
//===================================================================
//-------------------------------------------------------------------
// Constructors/destructor.
//===================================================================
Scaler::Scaler() {
SetMode(MODE_SAVE);
SetFilename(Undefined::String());
MaskSymbolic(true);
}
Scaler::~Scaler() {
}
//-------------------------------------------------------------------
// Methods inherited from Identifier.
//===================================================================
IMPLEMENTIDMETHODS(Scaler, SCALER, Algorithm)
//-------------------------------------------------------------------
// Methods inherited from Algorithm.
//===================================================================
//-------------------------------------------------------------------
// Method........: GetParameters
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================
String
Scaler::GetParameters() const {
String parameters;
parameters += Keyword::Mode();
parameters += Keyword::Assignment();
parameters += GetString(GetMode());
parameters += Keyword::Separator();
parameters += Keyword::Mask();
parameters += Keyword::Assignment();
parameters += String::Format(MaskSymbolic());
if (GetMode() == MODE_DISCARD)
return parameters;
parameters += Keyword::Separator();
parameters += Keyword::Filename();
parameters += Keyword::Assignment();
parameters += GetFilename();
return parameters;
}
//-------------------------------------------------------------------
// Method........: GetOutputFilenames
// Author........: Aleksander 豩rn
// Date..........:
// Description...: See Algorithm::GetOutputFilenames method.
// Comments......:
// Revisions.....:
//===================================================================
bool
Scaler::GetOutputFilenames(Vector(String) &filenames) const {
if (!Algorithm::GetOutputFilenames(filenames))
return false;
if (GetMode() == MODE_SAVE)
filenames.push_back(GetFilename());
return true;
}
//-------------------------------------------------------------------
// Method........: SetParameter
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================
bool
Scaler::SetParameter(const String &keyword, const String &value) {
// Set mode.
if (keyword == Keyword::Mode()) {
if (value == GetString(MODE_DISCARD))
return SetMode(MODE_DISCARD);
if (value == GetString(MODE_SAVE))
return SetMode(MODE_SAVE);
if (value == GetString(MODE_LOAD))
return SetMode(MODE_LOAD);
return false;
}
// Set filename.
if (keyword == Keyword::Filename())
return SetFilename(value);
// Set masking flag.
if (keyword == Keyword::Mask() && value.IsBoolean())
return MaskSymbolic(value.GetBoolean());
// Unknown keyword.
return false;
}
//-------------------------------------------------------------------
// Method........: IsApplicable
// Author........: Aleksander 豩rn
// Date..........:
// Description...: Returns true if the algorithm is applicable to the
// structure, false otherwise.
// Comments......:
// Revisions.....:
//===================================================================
bool
Scaler::IsApplicable(const Structure &structure, bool /*warn*/) const {
return structure.IsA(DECISIONTABLE);
}
//-------------------------------------------------------------------
// Masking methods.
//===================================================================
//-------------------------------------------------------------------
// Method........: GetTemporaryAttributeMasks
// Author........: Aleksander 豩rn
// Date..........:
// Description...: Returns (in-place) how the maskvector would be if all
// symbolic condition attributes were disabled.
// Comments......:
// Revisions.....:
//===================================================================
bool
Scaler::GetTemporaryAttributeMasks(const DecisionTable &table, Vector(DecisionTable::Mask) &masks) const {
// Clear current contents.
masks.erase(masks.begin(), masks.end());
// Operate on an unmasked table.
bool masked = false;
// Get table dimensions.
int no_attributes = table.GetNoAttributes(masked);
// Reserve space to avoid spurious allocations.
masks.reserve(no_attributes);
int i;
for (i = 0; i < no_attributes; i++) {
if (table.IsSymbolic(i, masked) && table.IsCondition(i, masked))
masks.push_back(DecisionTable::MASK_DISABLED);
else
masks.push_back(table.GetAttributeMask(i));
}
return true;
}
//-------------------------------------------------------------------
// Method........: GetAttributeMasks
// Author........: Aleksander 豩rn
// Date..........:
// Description...: Returns (in-place) the attribute masks of the
// given decision table.
// Comments......:
// Revisions.....: A
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -