summaryrefslogtreecommitdiff
path: root/extractor/backoff_sampler.h
blob: 5c244105af5bf0a1e795a2ee5fa6be9cd12a460e (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
#ifndef _BACKOFF_SAMPLER_H_
#define _BACKOFF_SAMPLER_H_

#include <vector>

#include "sampler.h"

namespace extractor {

class DataArray;
class PhraseLocation;

class BackoffSampler : public Sampler {
 public:
  BackoffSampler(shared_ptr<DataArray> source_data_array, int max_samples);

  BackoffSampler();

  PhraseLocation Sample(
      const PhraseLocation& location,
      const unordered_set<int>& blacklisted_sentence_ids) const;

 private:
  virtual int GetNumSubpatterns(const PhraseLocation& location) const = 0;

  virtual int GetRangeLow(const PhraseLocation& location) const = 0;

  virtual int GetRangeHigh(const PhraseLocation& location) const = 0;

  virtual int GetPosition(const PhraseLocation& location, int index) const = 0;

  virtual void AppendMatching(vector<int>& samples, int index,
                              const PhraseLocation& location) const = 0;

  shared_ptr<DataArray> source_data_array;
  int max_samples;
};

} // namespace extractor

#endif