Skip to content

Commit

Permalink
follow comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
lcy-seso committed Sep 4, 2017
1 parent faa4da4 commit 0b478e9
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions paddle/gserver/evaluators/CTCErrorEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ limitations under the License. */

#include "Evaluator.h"
#include "paddle/gserver/gradientmachines/NeuralNetwork.h"
#include "paddle/utils/StringUtil.h"

namespace paddle {

Expand Down Expand Up @@ -259,7 +260,7 @@ class CTCErrorEvaluator : public NotGetableEvaluator {

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"];
Expand Down Expand Up @@ -293,12 +294,10 @@ class CTCErrorEvaluator : public NotGetableEvaluator {
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<std::string> 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;
Expand All @@ -307,7 +306,11 @@ class CTCErrorEvaluator : public NotGetableEvaluator {
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);
Expand Down

0 comments on commit 0b478e9

Please sign in to comment.