summaryrefslogtreecommitdiff
path: root/extractor/mocks
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2013-05-02 09:09:59 +0200
committerPatrick Simianer <p@simianer.de>2013-05-02 09:09:59 +0200
commit9e50f0237413180fba11b500c9dce5c600e3c157 (patch)
tree556fc31d231353c853a864afffddd43dc525549a /extractor/mocks
parentd18024a41cbc1b54db88d499571349a6234b6db8 (diff)
parent14ed53426726202813a8e82d706b44266f015fe1 (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'extractor/mocks')
-rw-r--r--extractor/mocks/mock_alignment.h14
-rw-r--r--extractor/mocks/mock_data_array.h23
-rw-r--r--extractor/mocks/mock_fast_intersector.h15
-rw-r--r--extractor/mocks/mock_feature.h15
-rw-r--r--extractor/mocks/mock_matchings_finder.h13
-rw-r--r--extractor/mocks/mock_precomputation.h12
-rw-r--r--extractor/mocks/mock_rule_extractor.h16
-rw-r--r--extractor/mocks/mock_rule_extractor_helper.h82
-rw-r--r--extractor/mocks/mock_rule_factory.h13
-rw-r--r--extractor/mocks/mock_sampler.h13
-rw-r--r--extractor/mocks/mock_scorer.h15
-rw-r--r--extractor/mocks/mock_suffix_array.h23
-rw-r--r--extractor/mocks/mock_target_phrase_extractor.h16
-rw-r--r--extractor/mocks/mock_translation_table.h13
-rw-r--r--extractor/mocks/mock_vocabulary.h13
15 files changed, 296 insertions, 0 deletions
diff --git a/extractor/mocks/mock_alignment.h b/extractor/mocks/mock_alignment.h
new file mode 100644
index 00000000..299c3d1c
--- /dev/null
+++ b/extractor/mocks/mock_alignment.h
@@ -0,0 +1,14 @@
+#include <gmock/gmock.h>
+
+#include "alignment.h"
+
+namespace extractor {
+
+typedef vector<pair<int, int> > SentenceLinks;
+
+class MockAlignment : public Alignment {
+ public:
+ MOCK_CONST_METHOD1(GetLinks, SentenceLinks(int sentence_id));
+};
+
+} // namespace extractor
diff --git a/extractor/mocks/mock_data_array.h b/extractor/mocks/mock_data_array.h
new file mode 100644
index 00000000..6f85abb4
--- /dev/null
+++ b/extractor/mocks/mock_data_array.h
@@ -0,0 +1,23 @@
+#include <gmock/gmock.h>
+
+#include "data_array.h"
+
+namespace extractor {
+
+class MockDataArray : public DataArray {
+ public:
+ MOCK_CONST_METHOD0(GetData, const vector<int>&());
+ MOCK_CONST_METHOD1(AtIndex, int(int index));
+ MOCK_CONST_METHOD1(GetWordAtIndex, string(int index));
+ MOCK_CONST_METHOD0(GetSize, int());
+ MOCK_CONST_METHOD0(GetVocabularySize, int());
+ MOCK_CONST_METHOD1(HasWord, bool(const string& word));
+ MOCK_CONST_METHOD1(GetWordId, int(const string& word));
+ MOCK_CONST_METHOD1(GetWord, string(int word_id));
+ MOCK_CONST_METHOD1(GetSentenceLength, int(int sentence_id));
+ MOCK_CONST_METHOD0(GetNumSentences, int());
+ MOCK_CONST_METHOD1(GetSentenceStart, int(int sentence_id));
+ MOCK_CONST_METHOD1(GetSentenceId, int(int position));
+};
+
+} // namespace extractor
diff --git a/extractor/mocks/mock_fast_intersector.h b/extractor/mocks/mock_fast_intersector.h
new file mode 100644
index 00000000..f0b628d7
--- /dev/null
+++ b/extractor/mocks/mock_fast_intersector.h
@@ -0,0 +1,15 @@
+#include <gmock/gmock.h>
+
+#include "fast_intersector.h"
+#include "phrase.h"
+#include "phrase_location.h"
+
+namespace extractor {
+
+class MockFastIntersector : public FastIntersector {
+ public:
+ MOCK_METHOD3(Intersect, PhraseLocation(PhraseLocation&, PhraseLocation&,
+ const Phrase&));
+};
+
+} // namespace extractor
diff --git a/extractor/mocks/mock_feature.h b/extractor/mocks/mock_feature.h
new file mode 100644
index 00000000..0b0f0ead
--- /dev/null
+++ b/extractor/mocks/mock_feature.h
@@ -0,0 +1,15 @@
+#include <gmock/gmock.h>
+
+#include "features/feature.h"
+
+namespace extractor {
+namespace features {
+
+class MockFeature : public Feature {
+ public:
+ MOCK_CONST_METHOD1(Score, double(const FeatureContext& context));
+ MOCK_CONST_METHOD0(GetName, string());
+};
+
+} // namespace features
+} // namespace extractor
diff --git a/extractor/mocks/mock_matchings_finder.h b/extractor/mocks/mock_matchings_finder.h
new file mode 100644
index 00000000..827526fd
--- /dev/null
+++ b/extractor/mocks/mock_matchings_finder.h
@@ -0,0 +1,13 @@
+#include <gmock/gmock.h>
+
+#include "matchings_finder.h"
+#include "phrase_location.h"
+
+namespace extractor {
+
+class MockMatchingsFinder : public MatchingsFinder {
+ public:
+ MOCK_METHOD3(Find, PhraseLocation(PhraseLocation&, const string&, int));
+};
+
+} // namespace extractor
diff --git a/extractor/mocks/mock_precomputation.h b/extractor/mocks/mock_precomputation.h
new file mode 100644
index 00000000..8753343e
--- /dev/null
+++ b/extractor/mocks/mock_precomputation.h
@@ -0,0 +1,12 @@
+#include <gmock/gmock.h>
+
+#include "precomputation.h"
+
+namespace extractor {
+
+class MockPrecomputation : public Precomputation {
+ public:
+ MOCK_CONST_METHOD0(GetCollocations, const Index&());
+};
+
+} // namespace extractor
diff --git a/extractor/mocks/mock_rule_extractor.h b/extractor/mocks/mock_rule_extractor.h
new file mode 100644
index 00000000..aad11651
--- /dev/null
+++ b/extractor/mocks/mock_rule_extractor.h
@@ -0,0 +1,16 @@
+#include <gmock/gmock.h>
+
+#include "phrase.h"
+#include "phrase_builder.h"
+#include "rule.h"
+#include "rule_extractor.h"
+
+namespace extractor {
+
+class MockRuleExtractor : public RuleExtractor {
+ public:
+ MOCK_CONST_METHOD2(ExtractRules, vector<Rule>(const Phrase&,
+ const PhraseLocation&));
+};
+
+} // namespace extractor
diff --git a/extractor/mocks/mock_rule_extractor_helper.h b/extractor/mocks/mock_rule_extractor_helper.h
new file mode 100644
index 00000000..468468f6
--- /dev/null
+++ b/extractor/mocks/mock_rule_extractor_helper.h
@@ -0,0 +1,82 @@
+#include <gmock/gmock.h>
+
+#include <vector>
+
+#include "rule_extractor_helper.h"
+
+using namespace std;
+
+namespace extractor {
+
+typedef unordered_map<int, int> Indexes;
+
+class MockRuleExtractorHelper : public RuleExtractorHelper {
+ public:
+ MOCK_CONST_METHOD5(GetLinksSpans, void(vector<int>&, vector<int>&,
+ vector<int>&, vector<int>&, int));
+ MOCK_CONST_METHOD4(CheckAlignedTerminals, bool(const vector<int>&,
+ const vector<int>&, const vector<int>&, int));
+ MOCK_CONST_METHOD4(CheckTightPhrases, bool(const vector<int>&,
+ const vector<int>&, const vector<int>&, int));
+ MOCK_CONST_METHOD1(GetGapOrder, vector<int>(const vector<pair<int, int> >&));
+ MOCK_CONST_METHOD4(GetSourceIndexes, Indexes(const vector<int>&,
+ const vector<int>&, int, int));
+
+ // We need to implement these methods, because Google Mock doesn't support
+ // methods with more than 10 arguments.
+ bool FindFixPoint(
+ int, int, const vector<int>&, const vector<int>&, int& target_phrase_low,
+ int& target_phrase_high, const vector<int>&, const vector<int>&,
+ int& source_back_low, int& source_back_high, int, int, int, int, bool,
+ bool, bool) const {
+ target_phrase_low = this->target_phrase_low;
+ target_phrase_high = this->target_phrase_high;
+ source_back_low = this->source_back_low;
+ source_back_high = this->source_back_high;
+ return find_fix_point;
+ }
+
+ bool GetGaps(vector<pair<int, int> >& source_gaps,
+ vector<pair<int, int> >& target_gaps,
+ const vector<int>&, const vector<int>&, const vector<int>&,
+ const vector<int>&, const vector<int>&, const vector<int>&,
+ int, int, int, int, int, int, int& num_symbols,
+ bool& met_constraints) const {
+ source_gaps = this->source_gaps;
+ target_gaps = this->target_gaps;
+ num_symbols = this->num_symbols;
+ met_constraints = this->met_constraints;
+ return get_gaps;
+ }
+
+ void SetUp(
+ int target_phrase_low, int target_phrase_high, int source_back_low,
+ int source_back_high, bool find_fix_point,
+ vector<pair<int, int> > source_gaps, vector<pair<int, int> > target_gaps,
+ int num_symbols, bool met_constraints, bool get_gaps) {
+ this->target_phrase_low = target_phrase_low;
+ this->target_phrase_high = target_phrase_high;
+ this->source_back_low = source_back_low;
+ this->source_back_high = source_back_high;
+ this->find_fix_point = find_fix_point;
+ this->source_gaps = source_gaps;
+ this->target_gaps = target_gaps;
+ this->num_symbols = num_symbols;
+ this->met_constraints = met_constraints;
+ this->get_gaps = get_gaps;
+ }
+
+ private:
+ int target_phrase_low;
+ int target_phrase_high;
+ int source_back_low;
+ int source_back_high;
+ bool find_fix_point;
+ vector<pair<int, int> > source_gaps;
+ vector<pair<int, int> > target_gaps;
+ int num_symbols;
+ bool met_constraints;
+ bool get_gaps;
+};
+
+} // namespace extractor
diff --git a/extractor/mocks/mock_rule_factory.h b/extractor/mocks/mock_rule_factory.h
new file mode 100644
index 00000000..7389b396
--- /dev/null
+++ b/extractor/mocks/mock_rule_factory.h
@@ -0,0 +1,13 @@
+#include <gmock/gmock.h>
+
+#include "grammar.h"
+#include "rule_factory.h"
+
+namespace extractor {
+
+class MockHieroCachingRuleFactory : public HieroCachingRuleFactory {
+ public:
+ MOCK_METHOD1(GetGrammar, Grammar(const vector<int>& word_ids));
+};
+
+} // namespace extractor
diff --git a/extractor/mocks/mock_sampler.h b/extractor/mocks/mock_sampler.h
new file mode 100644
index 00000000..75c43c27
--- /dev/null
+++ b/extractor/mocks/mock_sampler.h
@@ -0,0 +1,13 @@
+#include <gmock/gmock.h>
+
+#include "phrase_location.h"
+#include "sampler.h"
+
+namespace extractor {
+
+class MockSampler : public Sampler {
+ public:
+ MOCK_CONST_METHOD1(Sample, PhraseLocation(const PhraseLocation& location));
+};
+
+} // namespace extractor
diff --git a/extractor/mocks/mock_scorer.h b/extractor/mocks/mock_scorer.h
new file mode 100644
index 00000000..cc0c444d
--- /dev/null
+++ b/extractor/mocks/mock_scorer.h
@@ -0,0 +1,15 @@
+#include <gmock/gmock.h>
+
+#include "scorer.h"
+#include "features/feature.h"
+
+namespace extractor {
+
+class MockScorer : public Scorer {
+ public:
+ MOCK_CONST_METHOD1(Score, vector<double>(
+ const features::FeatureContext& context));
+ MOCK_CONST_METHOD0(GetFeatureNames, vector<string>());
+};
+
+} // namespace extractor
diff --git a/extractor/mocks/mock_suffix_array.h b/extractor/mocks/mock_suffix_array.h
new file mode 100644
index 00000000..7018acc7
--- /dev/null
+++ b/extractor/mocks/mock_suffix_array.h
@@ -0,0 +1,23 @@
+#include <gmock/gmock.h>
+
+#include <memory>
+#include <string>
+
+#include "data_array.h"
+#include "phrase_location.h"
+#include "suffix_array.h"
+
+using namespace std;
+
+namespace extractor {
+
+class MockSuffixArray : public SuffixArray {
+ public:
+ MOCK_CONST_METHOD0(GetSize, int());
+ MOCK_CONST_METHOD0(GetData, shared_ptr<DataArray>());
+ MOCK_CONST_METHOD0(BuildLCPArray, vector<int>());
+ MOCK_CONST_METHOD1(GetSuffix, int(int));
+ MOCK_CONST_METHOD4(Lookup, PhraseLocation(int, int, const string& word, int));
+};
+
+} // namespace extractor
diff --git a/extractor/mocks/mock_target_phrase_extractor.h b/extractor/mocks/mock_target_phrase_extractor.h
new file mode 100644
index 00000000..6aad853c
--- /dev/null
+++ b/extractor/mocks/mock_target_phrase_extractor.h
@@ -0,0 +1,16 @@
+#include <gmock/gmock.h>
+
+#include "target_phrase_extractor.h"
+
+namespace extractor {
+
+typedef pair<Phrase, PhraseAlignment> PhraseExtract;
+
+class MockTargetPhraseExtractor : public TargetPhraseExtractor {
+ public:
+ MOCK_CONST_METHOD6(ExtractPhrases, vector<PhraseExtract>(
+ const vector<pair<int, int> > &, const vector<int>&, int, int,
+ const unordered_map<int, int>&, int));
+};
+
+} // namespace extractor
diff --git a/extractor/mocks/mock_translation_table.h b/extractor/mocks/mock_translation_table.h
new file mode 100644
index 00000000..307e4282
--- /dev/null
+++ b/extractor/mocks/mock_translation_table.h
@@ -0,0 +1,13 @@
+#include <gmock/gmock.h>
+
+#include "translation_table.h"
+
+namespace extractor {
+
+class MockTranslationTable : public TranslationTable {
+ public:
+ MOCK_METHOD2(GetSourceGivenTargetScore, double(const string&, const string&));
+ MOCK_METHOD2(GetTargetGivenSourceScore, double(const string&, const string&));
+};
+
+} // namespace extractor
diff --git a/extractor/mocks/mock_vocabulary.h b/extractor/mocks/mock_vocabulary.h
new file mode 100644
index 00000000..042c9ce2
--- /dev/null
+++ b/extractor/mocks/mock_vocabulary.h
@@ -0,0 +1,13 @@
+#include <gmock/gmock.h>
+
+#include "vocabulary.h"
+
+namespace extractor {
+
+class MockVocabulary : public Vocabulary {
+ public:
+ MOCK_METHOD1(GetTerminalValue, string(int word_id));
+ MOCK_METHOD1(GetTerminalIndex, int(const string& word));
+};
+
+} // namespace extractor