00001 #include "PhraseBasedFeatureContext.h" 00002 #include "moses/Hypothesis.h" 00003 #include "moses/Manager.h" 00004 #include "moses/TranslationOption.h" 00005 00006 namespace Moses 00007 { 00008 PhraseBasedFeatureContext::PhraseBasedFeatureContext(const Hypothesis* hypothesis) : 00009 m_hypothesis(hypothesis), 00010 m_translationOption(m_hypothesis->GetTranslationOption()), 00011 m_source(m_hypothesis->GetManager().GetSource()) {} 00012 00013 PhraseBasedFeatureContext::PhraseBasedFeatureContext 00014 (const TranslationOption& translationOption, const InputType& source) : 00015 m_hypothesis(NULL), 00016 m_translationOption(translationOption), 00017 m_source(source) 00018 {} 00019 00020 const TargetPhrase& PhraseBasedFeatureContext::GetTargetPhrase() const 00021 { 00022 return m_translationOption.GetTargetPhrase(); 00023 } 00024 00025 const WordsBitmap& PhraseBasedFeatureContext::GetWordsBitmap() const 00026 { 00027 if (!m_hypothesis) { 00028 throw std::logic_error("Coverage vector not available during pre-calculation"); 00029 } 00030 return m_hypothesis->GetWordsBitmap(); 00031 } 00032 00033 }