From 4ce19f6f30c1ed7e161443e62f60a12bde62fa09 Mon Sep 17 00:00:00 2001
From: Franck Dary <franck.dary@etu.univ-amu.fr>
Date: Mon, 17 Dec 2018 15:08:56 +0100
Subject: [PATCH] added an option for error analysis

---
 decoder/src/macaon_decode.cpp             | 2 ++
 error_correction/src/Error.cpp            | 2 ++
 maca_common/include/ProgramParameters.hpp | 1 +
 maca_common/src/ProgramParameters.cpp     | 1 +
 4 files changed, 6 insertions(+)

diff --git a/decoder/src/macaon_decode.cpp b/decoder/src/macaon_decode.cpp
index d0e1e36..4dd6959 100644
--- a/decoder/src/macaon_decode.cpp
+++ b/decoder/src/macaon_decode.cpp
@@ -56,6 +56,7 @@ po::options_description getOptionsDescription()
   analysis.add_options()
     ("errorAnalysis", "Print an analysis of errors")
     ("meanEntropy", "Print the mean entropy for error types")
+    ("onlyPrefixes", "Only uses the prefixes of error categories")
     ("classifier", po::value<std::string>()->default_value(""),
       "Name of the monitored classifier, if not specified monitor everyone");
 
@@ -120,6 +121,7 @@ int main(int argc, char * argv[])
   ProgramParameters::debug = vm.count("debug") == 0 ? false : true;
   ProgramParameters::errorAnalysis = vm.count("errorAnalysis") == 0 ? false : true;
   ProgramParameters::meanEntropy = vm.count("meanEntropy") == 0 ? false : true;
+  ProgramParameters::onlyPrefixes = vm.count("onlyPrefixes") == 0 ? false : true;
   ProgramParameters::dicts = vm["dicts"].as<std::string>();
   ProgramParameters::printEntropy = vm.count("printEntropy") == 0 ? false : true;
   ProgramParameters::lang = vm["lang"].as<std::string>();
diff --git a/error_correction/src/Error.cpp b/error_correction/src/Error.cpp
index c2f94cc..93fabe9 100644
--- a/error_correction/src/Error.cpp
+++ b/error_correction/src/Error.cpp
@@ -4,6 +4,8 @@ Error::Error(std::string & prediction, std::string & gold, Classifier::WeightedA
 prediction(prediction), gold(gold), weightedActions(weightedActions)
 {
   type = prediction + "->" + gold;
+  if (ProgramParameters::onlyPrefixes)
+    type = split(prediction,' ')[0] + "->" + split(gold,' ')[0];
   indexOfPrediction = -1;
   indexOfGold = -1;
   distanceWithGold = 0;
diff --git a/maca_common/include/ProgramParameters.hpp b/maca_common/include/ProgramParameters.hpp
index ddd9dfa..ce26f3a 100644
--- a/maca_common/include/ProgramParameters.hpp
+++ b/maca_common/include/ProgramParameters.hpp
@@ -57,6 +57,7 @@ struct ProgramParameters
   static std::string dicts;
   static bool errorAnalysis;
   static bool meanEntropy;
+  static bool onlyPrefixes;
   static std::map<std::string,std::string> featureModelByClassifier;
 
   private :
diff --git a/maca_common/src/ProgramParameters.cpp b/maca_common/src/ProgramParameters.cpp
index eb32e68..c5fe5ea 100644
--- a/maca_common/src/ProgramParameters.cpp
+++ b/maca_common/src/ProgramParameters.cpp
@@ -44,6 +44,7 @@ bool ProgramParameters::printEntropy;
 bool ProgramParameters::printTime;
 bool ProgramParameters::errorAnalysis;
 bool ProgramParameters::meanEntropy;
+bool ProgramParameters::onlyPrefixes;
 int ProgramParameters::iterationSize;
 int ProgramParameters::nbTrain;
 std::string ProgramParameters::sequenceDelimiterTape;
-- 
GitLab