diff options
Diffstat (limited to 'phrase-extract')
-rw-r--r-- | phrase-extract/extract-ghkm/Alignment.cpp | 4 | ||||
-rw-r--r-- | phrase-extract/extract-ghkm/Exception.h | 46 | ||||
-rw-r--r-- | phrase-extract/extract-ghkm/ExtractGHKM.cpp | 18 |
3 files changed, 11 insertions, 57 deletions
diff --git a/phrase-extract/extract-ghkm/Alignment.cpp b/phrase-extract/extract-ghkm/Alignment.cpp index 6f946fe5a..ba89a1594 100644 --- a/phrase-extract/extract-ghkm/Alignment.cpp +++ b/phrase-extract/extract-ghkm/Alignment.cpp @@ -19,7 +19,7 @@ #include "Alignment.h" -#include "Exception.h" +#include "syntax-common/exception.h" #include <algorithm> #include <cassert> @@ -44,7 +44,7 @@ void ReadAlignment(const std::string &s, Alignment &a) } int src = std::atoi(s.substr(begin, end-begin).c_str()); if (end+1 == s.size()) { - throw Exception("Target index missing"); + throw Syntax::Exception("Target index missing"); } begin = end+1; diff --git a/phrase-extract/extract-ghkm/Exception.h b/phrase-extract/extract-ghkm/Exception.h deleted file mode 100644 index 99e1067f4..000000000 --- a/phrase-extract/extract-ghkm/Exception.h +++ /dev/null @@ -1,46 +0,0 @@ -/*********************************************************************** - Moses - statistical machine translation system - Copyright (C) 2006-2011 University of Edinburgh - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -***********************************************************************/ - -#pragma once -#ifndef EXTRACT_GHKM_EXCEPTION_H_ -#define EXTRACT_GHKM_EXCEPTION_H_ - -#include <string> - -namespace MosesTraining -{ -namespace GHKM -{ - -class Exception -{ -public: - Exception(const char *msg) : m_msg(msg) {} - Exception(const std::string &msg) : m_msg(msg) {} - const std::string &GetMsg() const { - return m_msg; - } -private: - std::string m_msg; -}; - -} // namespace GHKM -} // namespace MosesTraining - -#endif diff --git a/phrase-extract/extract-ghkm/ExtractGHKM.cpp b/phrase-extract/extract-ghkm/ExtractGHKM.cpp index c2ee43767..a4e8afcd3 100644 --- a/phrase-extract/extract-ghkm/ExtractGHKM.cpp +++ b/phrase-extract/extract-ghkm/ExtractGHKM.cpp @@ -30,6 +30,7 @@ #include <boost/program_options.hpp> +#include "syntax-common/exception.h" #include "syntax-common/xml_tree_parser.h" #include "InputFileStream.h" @@ -43,7 +44,6 @@ #include "Alignment.h" #include "AlignmentGraph.h" -#include "Exception.h" #include "Node.h" #include "Options.h" #include "PhraseOrientation.h" @@ -160,11 +160,11 @@ int ExtractGHKM::Main(int argc, char *argv[]) try { targetParseTree = targetXmlTreeParser.Parse(targetLine); assert(targetParseTree.get()); - } catch (const Exception &e) { + } catch (const Syntax::Exception &e) { std::ostringstream oss; oss << "Failed to parse target XML tree at line " << lineNum; - if (!e.GetMsg().empty()) { - oss << ": " << e.GetMsg(); + if (!e.msg().empty()) { + oss << ": " << e.msg(); } Error(oss.str()); } @@ -178,11 +178,11 @@ int ExtractGHKM::Main(int argc, char *argv[]) try { sourceParseTree = sourceXmlTreeParser.Parse(sourceLine); assert(sourceParseTree.get()); - } catch (const Exception &e) { + } catch (const Syntax::Exception &e) { std::ostringstream oss; oss << "Failed to parse source XML tree at line " << lineNum; - if (!e.GetMsg().empty()) { - oss << ": " << e.GetMsg(); + if (!e.msg().empty()) { + oss << ": " << e.msg(); } Error(oss.str()); } @@ -192,10 +192,10 @@ int ExtractGHKM::Main(int argc, char *argv[]) // Read word alignments. try { ReadAlignment(alignmentLine, alignment); - } catch (const Exception &e) { + } catch (const Syntax::Exception &e) { std::ostringstream oss; oss << "Failed to read alignment at line " << lineNum << ": "; - oss << e.GetMsg(); + oss << e.msg(); Error(oss.str()); } if (alignment.size() == 0) { |