diff --git a/decoder/src/Decoder.cpp b/decoder/src/Decoder.cpp index 86e8044780b021c4d9c93240d9f1f7d178799862..51e3ce16de2de78edde719eeb201a0a1ccc35f83 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)); + } + } })){} }