From e9e816f5d7675389b87dfd84d0f9c4bf109fceba Mon Sep 17 00:00:00 2001
From: Franck Dary <franck.dary@lis-lab.fr>
Date: Sun, 17 Jan 2021 20:49:19 +0100
Subject: [PATCH] Added -x (extra columns) option when invoking eval script

---
 decoder/include/Decoder.hpp | 2 +-
 decoder/src/Decoder.cpp     | 4 ++--
 trainer/src/MacaonTrain.cpp | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/decoder/include/Decoder.hpp b/decoder/include/Decoder.hpp
index ab0153e..bdec405 100644
--- a/decoder/include/Decoder.hpp
+++ b/decoder/include/Decoder.hpp
@@ -26,7 +26,7 @@ class Decoder
 
   Decoder(ReadingMachine & machine);
   void decode(BaseConfig & config, std::size_t beamSize, float beamThreshold, bool debug, bool printAdvancement);
-  void evaluate(const Config & config, std::filesystem::path modelPath, const std::string goldTSV);
+  void evaluate(const Config & config, std::filesystem::path modelPath, const std::string goldTSV, const std::set<std::string> & predicted);
   std::vector<std::pair<float,std::string>> getF1Scores(const std::set<std::string> & colNames) const;
   std::vector<std::pair<float,std::string>> getAlignedAccs(const std::set<std::string> & colNames) const;
   std::vector<std::pair<float,std::string>> getRecalls(const std::set<std::string> & colNames) const;
diff --git a/decoder/src/Decoder.cpp b/decoder/src/Decoder.cpp
index a663564..73d8984 100644
--- a/decoder/src/Decoder.cpp
+++ b/decoder/src/Decoder.cpp
@@ -135,7 +135,7 @@ std::string Decoder::getMetricOfColName(const std::string & colName) const
   return colName;
 }
 
-void Decoder::evaluate(const Config & config, std::filesystem::path modelPath, const std::string goldTSV)
+void Decoder::evaluate(const Config & config, std::filesystem::path modelPath, const std::string goldTSV, const std::set<std::string> & predicted)
 {
   evaluation.clear();
   auto predictedTSV = (modelPath/"predicted_dev.tsv").string();
@@ -143,7 +143,7 @@ void Decoder::evaluate(const Config & config, std::filesystem::path modelPath, c
   config.print(predictedTSVFile);
   std::fclose(predictedTSVFile);
 
-  std::FILE * evalFromUD = popen(fmt::format("{} {} {}", "../scripts/conll18_ud_eval.py", goldTSV, predictedTSV).c_str(), "r");
+  std::FILE * evalFromUD = popen(fmt::format("{} {} {} -x {}", "../scripts/conll18_ud_eval.py", goldTSV, predictedTSV, util::join(",", std::vector<std::string>(predicted.begin(), predicted.end()))).c_str(), "r");
 
   char buffer[1024];
   while (!std::feof(evalFromUD))
diff --git a/trainer/src/MacaonTrain.cpp b/trainer/src/MacaonTrain.cpp
index bc14ee5..6d7266e 100644
--- a/trainer/src/MacaonTrain.cpp
+++ b/trainer/src/MacaonTrain.cpp
@@ -253,7 +253,7 @@ int MacaonTrain::main()
     {
       BaseConfig devConfig(mcd, computeDevScore ? (devRawFile.empty() ? devTsvFile : "") : devTsvFile, devRawFile);
       decoder.decode(devConfig, 1, 0.0, debug, printAdvancement);
-      decoder.evaluate(devConfig, modelPath, devTsvFile);
+      decoder.evaluate(devConfig, modelPath, devTsvFile, machine.getPredicted());
       devScores = decoder.getF1Scores(machine.getPredicted());
     }
     else
-- 
GitLab