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