From babc5acf70730bd9fd28d0d4deede8fe0fb23c29 Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Thu, 6 Oct 2016 13:48:06 +0100 Subject: check that pt exists --- contrib/moses2/TranslationModel/ProbingPT/quering.cpp | 7 ++++++- moses/TranslationModel/ProbingPT/quering.cpp | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/contrib/moses2/TranslationModel/ProbingPT/quering.cpp b/contrib/moses2/TranslationModel/ProbingPT/quering.cpp index f26439442..36e384e73 100644 --- a/contrib/moses2/TranslationModel/ProbingPT/quering.cpp +++ b/contrib/moses2/TranslationModel/ProbingPT/quering.cpp @@ -12,10 +12,15 @@ QueryEngine::QueryEngine(const char * filepath) //Create filepaths std::string basepath(filepath); + std::string path_to_config = basepath + "/config"; std::string path_to_hashtable = basepath + "/probing_hash.dat"; std::string path_to_source_vocabid = basepath + "/source_vocabids"; std::string alignPath = basepath + "/Alignments.dat"; + if (!FileExists(path_to_config)) { + UTIL_THROW2("Binary table doesn't exist is didn't finish binarizing: " << path_to_config); + } + ///Source phrase vocabids read_map(source_vocabids, path_to_source_vocabid.c_str()); @@ -25,7 +30,7 @@ QueryEngine::QueryEngine(const char * filepath) //Read config file boost::unordered_map keyValue; - std::ifstream config((basepath + "/config").c_str()); + std::ifstream config(path_to_config.c_str()); std::string line; while (getline(config, line)) { std::vector toks = Moses2::Tokenize(line, "\t"); diff --git a/moses/TranslationModel/ProbingPT/quering.cpp b/moses/TranslationModel/ProbingPT/quering.cpp index d616e1f25..52cd7f516 100644 --- a/moses/TranslationModel/ProbingPT/quering.cpp +++ b/moses/TranslationModel/ProbingPT/quering.cpp @@ -11,10 +11,15 @@ QueryEngine::QueryEngine(const char * filepath) //Create filepaths std::string basepath(filepath); + std::string path_to_config = basepath + "/config"; std::string path_to_hashtable = basepath + "/probing_hash.dat"; std::string path_to_source_vocabid = basepath + "/source_vocabids"; std::string alignPath = basepath + "/Alignments.dat"; + if (!FileExists(path_to_config)) { + UTIL_THROW2("Binary table doesn't exist is didn't finish binarizing: " << path_to_config); + } + ///Source phrase vocabids read_map(source_vocabids, path_to_source_vocabid.c_str()); @@ -24,7 +29,7 @@ QueryEngine::QueryEngine(const char * filepath) //Read config file boost::unordered_map keyValue; - std::ifstream config((basepath + "/config").c_str()); + std::ifstream config(path_to_config.c_str()); std::string line; while (getline(config, line)) { std::vector toks = Tokenize(line, "\t"); -- cgit v1.2.3