Menu

[r12]: / trunk / libtop_engine / rule_utils.cpp  Maximize  Restore  History

Download this file

50 lines (39 with data), 1.7 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "rule_session.h"
#include "rule_term_base.h"
#include "rule_term.h"
#include "knowledge_base.h"
namespace rule {
void print_beta_relation(std::string const& message, internal::rule_vertex const v, rule_session const* session_p)
{
internal::beta_relation const& relation = session_p->get_beta_relation(v);
knowledge_term const& kterm = session_p->get_knowledge_base().get_knowledge_term(v);
std::cout << std::endl << message << kterm.get_name() << std::endl;
internal::beta_relation::const_iterator r_itor = relation.beta_relation_iterator_all();
std::string labels = kterm.get_rule_term()->label_to_string();
std::cout << "\n\t" << labels << " row status\n\t";
unsigned int sz = labels.size() + 11;
for(unsigned int i=0; i<sz; ++i) std::cout << "-";
std::cout << std::endl;
while(!r_itor.is_end()) {
print_relation_row(session_p, r_itor);
r_itor.next();
};
};
void print_relation_row(rule_session const* session_p, internal::beta_relation::const_iterator const& r_itor)
{
std::cout << "\t[";
internal::relation_row_map::const_iterator row_itor;
internal::relation_row_map::const_iterator row_end;
boost::tie(row_itor, row_end) = r_itor.get_relation_row_const_iterator();
while(row_itor != row_end) {
try {
std::cout << rdf::internal::to_resource_base(*row_itor).get_name();
++row_itor;
if(row_itor != row_end) std::cout << ", ";
else std::cout << "] "<<r_itor.get_relation_row().get_row_status_str()<<"\n";
} catch(rdf::rdf_exception const& e) {
std::cout << "rule::print_beta_relation: Exception caught with message: " << e.what() << std::endl;
}
}
};
}; /*namespace rule */
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.