00001 // -*- c++ -*- 00002 // $Id$ 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 #pragma once 00024 00025 #include <vector> 00026 #include <string> 00027 #include <cstdlib> 00028 #include "Sentence.h" 00029 00030 namespace Moses 00031 { 00032 00049 typedef std::vector<std::string> TabbedColumns; 00050 00051 class TranslationTask; 00052 class TabbedSentence : public Sentence 00053 { 00054 00055 public: 00056 TabbedSentence(AllOptions::ptr const& opts) : Sentence(opts) {} 00057 ~TabbedSentence() {} 00058 00059 InputTypeEnum GetType() const { 00060 return TabbedSentenceInput; 00061 } 00062 00063 // Splits off the first tab-separated column and passes it to 00064 // Sentence::CreateFromString(...), the remaining columns are stored in 00065 // m_columns . 00066 00067 virtual void CreateFromString(const std::vector<FactorType> &factorOrder 00068 , const std::string &tabbedString); 00069 00070 virtual int 00071 Read(std::istream& in); 00072 00073 const TabbedColumns& GetColumns() const { 00074 return m_columns; 00075 } 00076 00077 const std::string& GetColumn(size_t i) const { 00078 UTIL_THROW_IF2(m_columns.size() <= i, 00079 "There is no column with index " << i); 00080 return m_columns[i]; 00081 } 00082 00083 private: 00084 TabbedColumns m_columns; 00085 00086 }; 00087 00088 00089 } 00090