From 49fe7283d6a3dd55e9bf999683a5b1c8268f5d77 Mon Sep 17 00:00:00 2001
From: Franck Dary <franck.dary@lis-lab.fr>
Date: Wed, 23 Oct 2019 16:11:37 +0200
Subject: [PATCH] Changed the way l_rules are computed

---
 maca_common/src/macaon_compute_l_rules.cpp | 27 ++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/maca_common/src/macaon_compute_l_rules.cpp b/maca_common/src/macaon_compute_l_rules.cpp
index d62c9c7..89ac095 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());
   }
 
-- 
GitLab