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
path: root/vw
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 /vw
parent53afe08da7dd2b8edb8c0c2fcc500814d806e4fc (diff)
Using boost for prefix/suffix checks /Jeroen Vermeulen
Diffstat (limited to 'vw')
-rw-r--r--vw/ClassifierFactory.cpp5
-rw-r--r--vw/VWTrainer.cpp4
2 files changed, 7 insertions, 2 deletions
diff --git a/vw/ClassifierFactory.cpp b/vw/ClassifierFactory.cpp
index 286bf84a6..4d8ee4e54 100644
--- a/vw/ClassifierFactory.cpp
+++ b/vw/ClassifierFactory.cpp
@@ -2,6 +2,9 @@
#include "vw.h"
#include "../moses/Util.h"
#include <iostream>
+#include <boost/algorithm/string/predicate.hpp>
+
+using namespace boost::algorithm;
namespace Discriminative
{
@@ -15,7 +18,7 @@ ClassifierFactory::ClassifierFactory(const std::string &modelFile, const std::st
ClassifierFactory::ClassifierFactory(const std::string &modelFilePrefix)
: m_lastId(0), m_train(true)
{
- if (modelFilePrefix.size() > 3 && modelFilePrefix.substr(modelFilePrefix.size() - 3, 3) == ".gz") {
+ if (ends_with(modelFilePrefix, ".gz")) {
m_modelFilePrefix = modelFilePrefix.substr(0, modelFilePrefix.size() - 3);
m_gzip = true;
} else {
diff --git a/vw/VWTrainer.cpp b/vw/VWTrainer.cpp
index dff58a1de..e513de3d2 100644
--- a/vw/VWTrainer.cpp
+++ b/vw/VWTrainer.cpp
@@ -1,8 +1,10 @@
#include "Util.h"
#include "Classifier.h"
+#include <boost/algorithm/string/predicate.hpp>
#include <boost/iostreams/device/file.hpp>
using namespace std;
+using namespace boost::algorithm;
using namespace Moses;
namespace Discriminative
@@ -10,7 +12,7 @@ namespace Discriminative
VWTrainer::VWTrainer(const std::string &outputFile)
{
- if (outputFile.size() > 3 && outputFile.substr(outputFile.size() - 3, 3) == ".gz") {
+ if (ends_with(outputFile, ".gz")) {
m_bfos.push(boost::iostreams::gzip_compressor());
}
m_bfos.push(boost::iostreams::file_sink(outputFile));