00001 // $Id: LanguageModelMultiFactor.cpp 4168 2011-08-30 12:25:50Z nicolabertoldi $ 00002 00003 /*********************************************************************** 00004 Moses - factored phrase-based language decoder 00005 Copyright (C) 2006 University of Edinburgh 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Lesser General Public 00009 License as published by the Free Software Foundation; either 00010 version 2.1 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public 00018 License along with this library; if not, write to the Free Software 00019 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00020 ***********************************************************************/ 00021 00022 #include "LanguageModelMultiFactor.h" 00023 #include "Phrase.h" 00024 00025 namespace Moses 00026 { 00027 std::string LanguageModelMultiFactor::GetScoreProducerDescription(unsigned) const 00028 { 00029 std::ostringstream oss; 00030 // what about LMs that are over multiple factors at once, POS + stem, for example? 00031 oss << GetNGramOrder() << "-gram LM score, factor-type= ??? " << ", file=" << m_filePath; 00032 return oss.str(); 00033 } 00034 00035 bool LanguageModelMultiFactor::Useable(const Phrase &phrase) const 00036 { 00037 if (phrase.GetSize()==0) 00038 return false; 00039 00040 // whether phrase contains all factors in this LM 00041 const Word &word = phrase.GetWord(0); 00042 for (size_t currFactor = 0 ; currFactor < MAX_NUM_FACTORS ; ++currFactor) { 00043 if (m_factorTypes[currFactor] && word[currFactor] == NULL) 00044 return false; 00045 } 00046 return true; 00047 00048 } 00049 00050 } 00051
1.5.9