From 5cd7a36fe640aa06f13409c9d99aac6ca36b2d40 Mon Sep 17 00:00:00 2001
From: Franck Dary <franck.dary@lis-lab.fr>
Date: Thu, 6 Feb 2020 12:57:19 +0100
Subject: [PATCH] Changed regexp

---
 decoder/src/Decoder.cpp | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/decoder/src/Decoder.cpp b/decoder/src/Decoder.cpp
index 86e8044..51e3ce1 100644
--- a/decoder/src/Decoder.cpp
+++ b/decoder/src/Decoder.cpp
@@ -90,10 +90,26 @@ void Decoder::evaluate(const Config & config, std::filesystem::path modelPath, c
   {
     if (buffer != std::fgets(buffer, 1024, evalFromUD))
       break;
-    if (util::doIfNameMatch(std::regex("(.*)\\|(.*)\\|(.*)\\|(.*)\\|(.*)"), buffer, [this](auto sm)
+    if (buffer[std::strlen(buffer)-1] == '\n')
+      buffer[std::strlen(buffer)-1] = '\0';
+    if (util::doIfNameMatch(std::regex("(.*)Metric(.*)"), buffer, [this, buffer](auto sm){}))
+      continue;
+
+    if (util::doIfNameMatch(std::regex("(.*)\\|(.*)\\|(.*)\\|(.*)\\|(.*)"), buffer, [this, buffer](auto sm)
     {
       for (unsigned int i = 0; i < this->evaluation[sm[1]].size(); i++)
-        this->evaluation[sm[1]][i] = std::stof(sm[1+i]);
+      {
+        if (std::string(sm[i+2]).empty())
+        {
+          this->evaluation[sm[1]][i] = 0.0;
+          continue;
+        }
+        try {this->evaluation[sm[1]][i] = std::stof(sm[i+2]);}
+        catch (std::exception &) 
+        {
+          util::myThrow(fmt::format("score '{}' is not a number in line '{}'", std::string(sm[i+2]), buffer));
+        }
+      }
     })){}
   }
 
-- 
GitLab