From a6e6a369f40d8fb6a191fd7f74fc5efa8bfae2a0 Mon Sep 17 00:00:00 2001
From: Paul Baltescu <pauldb89@gmail.com>
Date: Wed, 27 Nov 2013 14:33:36 +0000
Subject: Unify sampling backoff strategy.

---
 extractor/backoff_sampler.h | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 extractor/backoff_sampler.h

(limited to 'extractor/backoff_sampler.h')

diff --git a/extractor/backoff_sampler.h b/extractor/backoff_sampler.h
new file mode 100644
index 00000000..5c244105
--- /dev/null
+++ b/extractor/backoff_sampler.h
@@ -0,0 +1,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
-- 
cgit v1.2.3