File size: 1,101 Bytes
158b61b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#pragma once

#include <string>

#include <boost/shared_ptr.hpp>

#include "moses/Phrase.h"
#include "moses/Syntax/RuleTableFF.h"
#include "moses/TargetPhrase.h"
#include "moses/Word.h"

#include "RuleTrieCreator.h"

namespace Moses
{
namespace Syntax
{
namespace S2T
{

template<typename RuleTrie>
class OovHandler : public RuleTrieCreator
{
public:
  OovHandler(const RuleTableFF &ff) : m_ruleTableFF(ff) {}

  // Synthesize a RuleTrie given a sequence of OOV words.  The sequence is
  // specified by a pair of iterators (indicating the beginning and end).  It
  // is assumed not to contain duplicates.
  template<typename InputIterator>
  boost::shared_ptr<RuleTrie> SynthesizeRuleTrie(InputIterator, InputIterator);

private:
  const RuleTableFF &m_ruleTableFF;

  bool ShouldDrop(const Word &);

  Phrase *SynthesizeSourcePhrase(const Word &);

  Word *SynthesizeTargetLhs(const std::string &);

  TargetPhrase *SynthesizeTargetPhrase(const Word &, const Phrase &,
                                       const Word &, float);
};

}  // S2T
}  // Syntax
}  // Moses

#include "OovHandler-inl.h"