Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHieu Hoang <hieuhoang@gmail.com>2015-02-05 19:23:47 +0300
committerHieu Hoang <hieuhoang@gmail.com>2015-02-05 19:23:47 +0300
commit70e8eb54ce75feb0a7d4ed00d275e56652c0a914 (patch)
tree12c24aa2bb927729d109e24fe6c4da12cabec172 /moses/ScoreComponentCollection.cpp
parent53afe08da7dd2b8edb8c0c2fcc500814d806e4fc (diff)
Using boost for prefix/suffix checks /Jeroen Vermeulen
Diffstat (limited to 'moses/ScoreComponentCollection.cpp')
-rw-r--r--moses/ScoreComponentCollection.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/moses/ScoreComponentCollection.cpp b/moses/ScoreComponentCollection.cpp
index b8c93c193..a1c864692 100644
--- a/moses/ScoreComponentCollection.cpp
+++ b/moses/ScoreComponentCollection.cpp
@@ -1,5 +1,6 @@
// $Id$
#include <vector>
+#include <boost/algorithm/string/predicate.hpp>
#include "util/exception.hh"
#include "ScoreComponentCollection.h"
#include "StaticData.h"
@@ -7,6 +8,7 @@
#include "moses/FF/StatefulFeatureFunction.h"
using namespace std;
+using namespace boost::algorithm;
namespace Moses
{
@@ -87,7 +89,7 @@ void ScoreComponentCollection::MultiplyEquals(const FeatureFunction* sp, float s
for(FVector::FNVmap::const_iterator i = m_scores.cbegin(); i != m_scores.cend(); i++) {
std::stringstream name;
name << i->first;
- if (name.str().substr( 0, prefix.length() ).compare( prefix ) == 0)
+ if (starts_with(name.str(), prefix))
m_scores[i->first] = i->second * scalar;
}
}
@@ -100,7 +102,7 @@ size_t ScoreComponentCollection::GetNumberWeights(const FeatureFunction* sp)
for(FVector::FNVmap::const_iterator i = m_scores.cbegin(); i != m_scores.cend(); i++) {
std::stringstream name;
name << i->first;
- if (name.str().substr( 0, prefix.length() ).compare( prefix ) == 0)
+ if (starts_with(name.str(), prefix))
weights++;
}
return weights;
@@ -285,7 +287,7 @@ FVector ScoreComponentCollection::GetVectorForProducer(const FeatureFunction* sp
for(FVector::FNVmap::const_iterator i = m_scores.cbegin(); i != m_scores.cend(); i++) {
std::stringstream name;
name << i->first;
- if (name.str().substr( 0, prefix.length() ).compare( prefix ) == 0)
+ if (starts_with(name.str(), prefix))
fv[i->first] = i->second;
}
return fv;