From 0b478e991c95f838da41bfcbf11f1e2b80ac17eb Mon Sep 17 00:00:00 2001 From: caoying03 Date: Mon, 4 Sep 2017 15:12:56 +0800 Subject: [PATCH] follow comments. --- paddle/gserver/evaluators/CTCErrorEvaluator.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/paddle/gserver/evaluators/CTCErrorEvaluator.cpp b/paddle/gserver/evaluators/CTCErrorEvaluator.cpp index 8e2dc020cd8..928c77a088f 100644 --- a/paddle/gserver/evaluators/CTCErrorEvaluator.cpp +++ b/paddle/gserver/evaluators/CTCErrorEvaluator.cpp @@ -14,6 +14,7 @@ limitations under the License. */ #include "Evaluator.h" #include "paddle/gserver/gradientmachines/NeuralNetwork.h" +#include "paddle/utils/StringUtil.h" namespace paddle { @@ -259,7 +260,7 @@ public: virtual void printStats(std::ostream& os) const { storeLocalValues(); - os << config_.name() << "=" << evalResults_["error"]; + os << config_.name() << " error = " << evalResults_["error"]; os << " deletions error = " << evalResults_["deletion_error"]; os << " insertions error = " << evalResults_["insertion_error"]; os << " substitution error = " << evalResults_["substitution_error"]; @@ -293,12 +294,10 @@ public: real getValue(const std::string& name, Error* err) const { storeLocalValues(); - const std::string delimiter("."); - std::string::size_type foundPos = name.find(delimiter, 0); - CHECK(foundPos != std::string::npos); + std::vector buffers; + paddle::str::split(name, '.', &buffers); + auto it = evalResults_.find(buffers[buffers.size() - 1]); - auto it = evalResults_.find( - name.substr(foundPos + delimiter.size(), name.length())); if (it == evalResults_.end()) { *err = Error("Evaluator does not have the key %s", name.c_str()); return 0.0f; @@ -307,7 +306,11 @@ public: return it->second; } - std::string getTypeImpl() const { return "ctc_edit_distance"; } + std::string getType(const std::string& name, Error* err) const { + getValue(name, err); + if (!err->isOK()) return ""; + return "ctc_edit_distance"; + } }; REGISTER_EVALUATOR(ctc_edit_distance, CTCErrorEvaluator); -- GitLab