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/moses
diff options
context:
space:
mode:
authorHieu Hoang <hieuhoang@gmail.com>2015-02-06 18:52:25 +0300
committerHieu Hoang <hieuhoang@gmail.com>2015-02-06 18:52:25 +0300
commit755bd609f506fa6ce68a935f72499e055a6a4b6c (patch)
tree188ac45b2f1089c3df7ac5434fa87eeaeb925df0 /moses
parent4145999e3335592576bf2d4154834dcfe16e0a56 (diff)
Using boost for prefix/suffix checks /Jeroen Vermeulen
Diffstat (limited to 'moses')
-rw-r--r--moses/TranslationModel/CompactPT/PhraseDictionaryCompact.cpp17
1 files changed, 5 insertions, 12 deletions
diff --git a/moses/TranslationModel/CompactPT/PhraseDictionaryCompact.cpp b/moses/TranslationModel/CompactPT/PhraseDictionaryCompact.cpp
index 90d5575a1..9c3f6b513 100644
--- a/moses/TranslationModel/CompactPT/PhraseDictionaryCompact.cpp
+++ b/moses/TranslationModel/CompactPT/PhraseDictionaryCompact.cpp
@@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include <queue>
#include <algorithm>
#include <sys/stat.h>
+#include <boost/algorithm/string/predicate.hpp>
#include "PhraseDictionaryCompact.h"
#include "moses/FactorCollection.h"
@@ -37,6 +38,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include "util/exception.hh"
using namespace std;
+using namespace boost::algorithm;
namespace Moses
{
@@ -63,18 +65,9 @@ void PhraseDictionaryCompact::Load()
std::string tFilePath = m_filePath;
std::string suffix = ".minphr";
- if(tFilePath.substr(tFilePath.length() - suffix.length(), suffix.length()) == suffix) {
- if(!FileExists(tFilePath)) {
- throw runtime_error("Error: File " + tFilePath + " does not exit.");
- exit(1);
- }
- } else {
- if(FileExists(tFilePath + suffix)) {
- tFilePath += suffix;
- } else {
- throw runtime_error("Error: File " + tFilePath + ".minphr does not exit.");
- }
- }
+ if (!ends_with(tFilePath, suffix)) tFilePath += suffix;
+ if (!FileExists(tFilePath))
+ throw runtime_error("Error: File " + tFilePath + " does not exist.");
m_phraseDecoder = new PhraseDecoder(*this, &m_input, &m_output,
m_numScoreComponents, &m_weight);