00001 // $Id$ 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 "DecodeStep.h" 00023 #include "GenerationDictionary.h" 00024 #include "StaticData.h" 00025 00026 namespace Moses 00027 { 00028 DecodeStep::DecodeStep(const DecodeFeature *decodeFeature, const DecodeStep* prev) : 00029 m_decodeFeature(decodeFeature) 00030 { 00031 FactorMask prevOutputFactors; 00032 if (prev) prevOutputFactors = prev->m_outputFactors; 00033 m_outputFactors = prevOutputFactors; 00034 FactorMask conflictMask = (m_outputFactors & decodeFeature->GetOutputFactorMask()); 00035 m_outputFactors |= decodeFeature->GetOutputFactorMask(); 00036 FactorMask newOutputFactorMask = m_outputFactors ^ prevOutputFactors; //xor 00037 m_newOutputFactors.resize(newOutputFactorMask.count()); 00038 m_conflictFactors.resize(conflictMask.count()); 00039 size_t j=0, k=0; 00040 for (size_t i = 0; i < MAX_NUM_FACTORS; i++) { 00041 if (newOutputFactorMask[i]) m_newOutputFactors[j++] = i; 00042 if (conflictMask[i]) m_conflictFactors[k++] = i; 00043 } 00044 VERBOSE(2,"DecodeStep():\n\toutputFactors=" << m_outputFactors 00045 << "\n\tconflictFactors=" << conflictMask 00046 << "\n\tnewOutputFactors=" << newOutputFactorMask << std::endl); 00047 } 00048 00049 DecodeStep::~DecodeStep() {} 00050 00052 const PhraseDictionary* DecodeStep::GetPhraseDictionaryFeature() const 00053 { 00054 return dynamic_cast<const PhraseDictionary*>(m_decodeFeature); 00055 } 00056 00058 const GenerationDictionary* DecodeStep::GetGenerationDictionaryFeature() const 00059 { 00060 return dynamic_cast<const GenerationDictionary*>(m_decodeFeature); 00061 } 00062 00063 } 00064 00065
1.5.9