diff --git a/maca_common/src/macaon_compute_l_rules.cpp b/maca_common/src/macaon_compute_l_rules.cpp index d62c9c79d0908f47c727ee9af49c6342d7788aa8..89ac095c480b66acb66fc41f9132791c2e176b30 100644 --- a/maca_common/src/macaon_compute_l_rules.cpp +++ b/maca_common/src/macaon_compute_l_rules.cpp @@ -150,6 +150,8 @@ int main(int argc, char * argv[]) char buffer[100000]; std::map<std::string, std::vector<FPLM> > rules; + std::map<std::string, std::vector<FPLM> > acceptedRules; + while (fscanf(fplm.getDescriptor(), "%[^\n]\n", buffer) == 1) { auto splited = util::split(buffer, '\t'); @@ -180,7 +182,7 @@ int main(int argc, char * argv[]) { if ((int)it.second.size() >= threshold) { - fprintf(rulesFile.getDescriptor(), "%s\n", it.first.c_str()); + acceptedRules[it.first] = it.second; for (auto & fplm : it.second) fpInRules[fplm.getFp()] = true; } @@ -189,11 +191,11 @@ int main(int argc, char * argv[]) exceptions[line.getFp()].emplace_back(line); } + for (auto & it : acceptedRules) + fprintf(rulesFile.getDescriptor(), "%s\n", it.first.c_str()); + for (auto it : exceptions) { - if (fpInRules.count(it.first)) - continue; - int indexMax = 0; int knownMax = 0; @@ -204,6 +206,23 @@ int main(int argc, char * argv[]) knownMax = it.second[i].getNbKnown(); } + if (fpInRules.count(it.first)) + { + + int otherIndexMax = 0; + int otherKnownMax = 0; + + for (unsigned int i = 0; i < acceptedRules[it.first].size(); i++) + if (acceptedRules[it.first][i].getNbKnown() > otherKnownMax) + { + otherIndexMax = i; + otherKnownMax = acceptedRules[it.first][i].getNbKnown(); + } + + if (otherKnownMax >= knownMax) + continue; + } + exceptionsToPrint.emplace_back(it.second[indexMax].toString()); }