rule.cpp
来自「用data miming技术进行false prediction」· C++ 代码 · 共 53 行
CPP
53 行
#include "Rule.h"
Rule::Rule(string rule, float confidence) {
this->mRule = rule;
this->mConfidence = confidence;
this->populateVectors();
}
string Rule::getRule() const {
return mRule;
}
float Rule::getConfidence() const {
return mConfidence;
}
void Rule::populateVectors() {
int index = mRule.find(">", 0);
if (index != string::npos) {
string ifStr = mRule.substr(0, index);
string thenStr = mRule.substr(index+1);
string str;
tokenizer<> tok(ifStr);
for (tokenizer<>::iterator beg = tok.begin(); beg != tok.end(); ++beg) {
str = *beg;
ifVec.push_back(str);
}
tokenizer<> tok1(thenStr);
for (tokenizer<>::iterator beg = tok1.begin(); beg != tok1.end(); ++beg) {
str = *beg;
thenVec.push_back(str);
}
}
}
vector<string>& Rule::getIfVector() {
return ifVec;
}
vector<string>& Rule::getThenVector() {
return thenVec;
}
bool Rule::operator<(const Rule& anotherRule) const {
if (this->getConfidence() == anotherRule.getConfidence()) {
return (this->getRule() < anotherRule.getRule());
} else {
return (this->getConfidence() < anotherRule.getConfidence());
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?