00001 #ifndef SimpleAssocRuleWriter_HPP 00002 #define SimpleAssocRuleWriter_HPP 00003 00008 #include <iterator> 00009 #include "io/StreamRepr.hpp" 00010 #include "io/codec/decoder/df/SimpleDFDecoder.hpp" 00011 00012 00013 00014 class SimpleAssocRuleWriter : public SimpleDFDecoder< BufferedNormalOutput<StreamRepr> > 00015 { 00016 protected: 00017 typedef SimpleDFDecoder< BufferedNormalOutput<StreamRepr> > PARENT; 00018 public: 00019 typedef PARENT::params_t params_t; 00020 00021 SimpleAssocRuleWriter(const params_t* par) : 00022 PARENT(par) {} 00023 00024 template <typename ANTECIterator, typename CONSEQIterator> void 00025 writeAssocRule( 00026 ANTECIterator antec_first, ANTECIterator antec_last, 00027 CONSEQIterator conseq_first, CONSEQIterator conseq_last, 00028 counter_t union_support, float confidence, float lift ) 00029 { 00030 while( antec_first != antec_last) 00031 { 00032 PARENT::output_stream << PARENT::code_inverse[*antec_first] << ' '; 00033 ++antec_first; 00034 } 00035 PARENT::output_stream<<"-> "; 00036 while( conseq_first != conseq_last) 00037 { 00038 PARENT::output_stream << PARENT::code_inverse[*conseq_first] << ' '; 00039 ++conseq_first; 00040 } 00041 PARENT::output_stream<<'(' << union_support <<' '<< confidence << ' '<<lift<<")\n"; 00042 } 00043 }; 00044 00045 #endif 00046