00001 // $Id$ 00002 // vim:tabstop=2 00003 00004 /*********************************************************************** 00005 Moses - factored phrase-based language decoder 00006 Copyright (C) 2006 University of Edinburgh 00007 00008 This library is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU Lesser General Public 00010 License as published by the Free Software Foundation; either 00011 version 2.1 of the License, or (at your option) any later version. 00012 00013 This library is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 Lesser General Public License for more details. 00017 00018 You should have received a copy of the GNU Lesser General Public 00019 License along with this library; if not, write to the Free Software 00020 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00021 ***********************************************************************/ 00022 00023 #include <cstdlib> 00024 00025 #include "InputType.h" 00026 #include "ChartTranslationOptions.h" 00027 #include "StaticData.h" 00028 00029 namespace Moses 00030 { 00031 00032 InputType::InputType(AllOptions::ptr const& opts, long translationId) 00033 : m_options(opts) 00034 , m_translationId(translationId) 00035 , m_reorderingConstraint(opts->reordering.max_distortion) 00036 { 00037 m_frontSpanCoveredLength = 0; 00038 m_sourceCompleted.resize(0); 00039 } 00040 00041 InputType::~InputType() {} 00042 00043 TO_STRING_BODY(InputType); 00044 00045 std::ostream& operator<<(std::ostream& out,InputType const& x) 00046 { 00047 x.Print(out); 00048 return out; 00049 } 00050 00051 // default implementation is one column equals one word 00052 int InputType::ComputeDistortionDistance(const Range& prev, const Range& current) const 00053 { 00054 int dist = 0; 00055 if (prev.GetNumWordsCovered() == 0) { 00056 dist = current.GetStartPos(); 00057 } else { 00058 dist = (int)prev.GetEndPos() - (int)current.GetStartPos() + 1 ; 00059 } 00060 return abs(dist); 00061 } 00062 00063 bool InputType::CanIGetFromAToB(size_t /*start*/, size_t /*end*/) const 00064 { 00065 return true; 00066 } 00067 00068 std::vector <ChartTranslationOptions*> InputType::GetXmlChartTranslationOptions() const 00069 { 00070 // default. return nothing 00071 std::vector <ChartTranslationOptions*> ret; 00072 return ret; 00073 } 00074 00075 } 00076 00077