⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prologruleexporter.cpp

📁 The ROSETTA C++ library is a collection of C++ classes and routines that enable discernibility-based
💻 CPP
字号:
//-------------------------------------------------------------------// Author........: Aleksander 豩rn// Date..........:// Description...:// Revisions.....://===================================================================#include <stdafx.h> // Precompiled headers.#include <copyright.h>#include <kernel/algorithms/prologruleexporter.h>#include <kernel/structures/rules.h>#include <kernel/structures/rule.h>#include <kernel/utilities/systemkit.h>#include <kernel/system/fstream.h>//-------------------------------------------------------------------// Methods for class PrologRuleExporter.//===================================================================//-------------------------------------------------------------------// Constructors/destructor.//===================================================================PrologRuleExporter::PrologRuleExporter() {}PrologRuleExporter::~PrologRuleExporter() {}//-------------------------------------------------------------------// Methods inherited from Identifier.//===================================================================IMPLEMENTIDMETHODS(PrologRuleExporter, PROLOGRULEEXPORTER, RuleExporter)//-------------------------------------------------------------------// Methods inherited from Exporter.//===================================================================//-------------------------------------------------------------------// Method........: ExportPrologue// Author........: Aleksander 豩rn// Date..........:// Description...:// Comments......: Assumes non-deterministic rules are expanded into//                 several Prolog rules, for counting to be correct.//                 Cf. Rule::FormatProlog method.// Revisions.....://===================================================================boolPrologRuleExporter::ExportPrologue(ofstream &stream, const Structure &structure) const {	// Cast to already verified type (in Apply method).	Handle<Rules> rules = dynamic_cast(Rules *, const_cast(Structure *, &structure));	// Write some general information.	stream << "% Rules/patterns generated by ROSETTA." << endl;	stream << "% Exported " << SystemKit::GetTimestamp() << " by " << SystemKit::GetUser() << "." << endl;	stream << "%" << endl;	stream << "% " << rules->GetName() << endl;	stream << "%" << endl;	stream << "% Clause head arguments: (Object, Decision, Support, Accuracy, Stability)" << endl;	stream << "%" << endl;	int no_deterministic    = 0;	int no_nondeterministic = 0;	int no_total            = 0;	int no_rules            = rules->GetNoRules();	int i;	// Do some counting.	for (i = 0; i < no_rules; i++) {		Handle<Rule> rule = rules->GetRule(i);		if (rule->IsDeterministic()) {			no_deterministic++;			no_total++;		}		else {			no_nondeterministic++;			no_total += rule->GetNoDecisionValues();		}	}	// Write some dimensional information.	stream << "% " << no_deterministic    << " deterministic rules/patterns."                << endl;	stream << "% " << no_nondeterministic << " non-deterministic rules/patterns (expanded)." << endl;	stream << "% " << no_total            << " Prolog rules/patterns in total."              << endl;	stream << endl;	return true;}//-------------------------------------------------------------------// Methods inherited from RuleExporter.//===================================================================//-------------------------------------------------------------------// Method........: ExportRule// Author........: Aleksander 豩rn// Date..........:// Description...: Overloaded to deal with Prolog syntax.// Comments......:// Revisions.....://===================================================================boolPrologRuleExporter::ExportRule(ofstream &stream, int /*rule_no*/, const Rule &rule) const {	String formatted;	bool masked = true;	// Generate Prolog format.	if (!rule.FormatProlog(formatted, GetDecisionTable(), masked)) {		Message::Error("Error formatting rule.");		return false;	}	// Dump formatted rule to file stream.	stream << formatted << endl << endl;	return true;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -