00001 #pragma once 00002 00003 #include <string> 00004 00005 #include <boost/shared_ptr.hpp> 00006 00007 #include "moses/Phrase.h" 00008 #include "moses/Syntax/RuleTableFF.h" 00009 #include "moses/TargetPhrase.h" 00010 #include "moses/Word.h" 00011 00012 #include "RuleTrieCreator.h" 00013 00014 namespace Moses 00015 { 00016 namespace Syntax 00017 { 00018 namespace S2T 00019 { 00020 00021 template<typename RuleTrie> 00022 class OovHandler : public RuleTrieCreator 00023 { 00024 public: 00025 OovHandler(const RuleTableFF &ff) : m_ruleTableFF(ff) {} 00026 00027 // Synthesize a RuleTrie given a sequence of OOV words. The sequence is 00028 // specified by a pair of iterators (indicating the beginning and end). It 00029 // is assumed not to contain duplicates. 00030 template<typename InputIterator> 00031 boost::shared_ptr<RuleTrie> SynthesizeRuleTrie(InputIterator, InputIterator); 00032 00033 private: 00034 const RuleTableFF &m_ruleTableFF; 00035 00036 bool ShouldDrop(const Word &); 00037 00038 Phrase *SynthesizeSourcePhrase(const Word &); 00039 00040 Word *SynthesizeTargetLhs(const std::string &); 00041 00042 TargetPhrase *SynthesizeTargetPhrase(const Word &, const Phrase &, 00043 const Word &, float); 00044 }; 00045 00046 } // S2T 00047 } // Syntax 00048 } // Moses 00049 00050 #include "OovHandler-inl.h"