summaryrefslogtreecommitdiff
path: root/extractor/target_phrase_extractor.h
blob: a4b54145ae68eef0fb46aee69ab739b734d4f6c9 (plain)
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
52
53
54
55
56
57
58
59
60
#ifndef _TARGET_PHRASE_EXTRACTOR_H_
#define _TARGET_PHRASE_EXTRACTOR_H_

#include <memory>
#include <unordered_map>
#include <vector>

using namespace std;

namespace extractor {

typedef vector<pair<int, int> > PhraseAlignment;

class Alignment;
class DataArray;
class Phrase;
class PhraseBuilder;
class RuleExtractorHelper;
class Vocabulary;

class TargetPhraseExtractor {
 public:
  TargetPhraseExtractor(shared_ptr<DataArray> target_data_array,
                        shared_ptr<Alignment> alignment,
                        shared_ptr<PhraseBuilder> phrase_builder,
                        shared_ptr<RuleExtractorHelper> helper,
                        shared_ptr<Vocabulary> vocabulary,
                        int max_rule_span,
                        bool require_tight_phrases);

  virtual ~TargetPhraseExtractor();

  virtual vector<pair<Phrase, PhraseAlignment> > ExtractPhrases(
      const vector<pair<int, int> >& target_gaps, const vector<int>& target_low,
      int target_phrase_low, int target_phrase_high,
      const unordered_map<int, int>& source_indexes, int sentence_id) const;

 protected:
  TargetPhraseExtractor();

 private:
  void GeneratePhrases(
      vector<pair<Phrase, PhraseAlignment> >& target_phrases,
      const vector<pair<int, int> >& ranges, int index,
      vector<int>& subpatterns, const vector<int>& target_gap_order,
      int target_phrase_low, int target_phrase_high,
      const unordered_map<int, int>& source_indexes, int sentence_id) const;

  shared_ptr<DataArray> target_data_array;
  shared_ptr<Alignment> alignment;
  shared_ptr<PhraseBuilder> phrase_builder;
  shared_ptr<RuleExtractorHelper> helper;
  shared_ptr<Vocabulary> vocabulary;
  int max_rule_span;
  bool require_tight_phrases;
};

} // namespace extractor

#endif