diff options
Diffstat (limited to 'extractor/mocks')
| -rw-r--r-- | extractor/mocks/mock_alignment.h | 10 | ||||
| -rw-r--r-- | extractor/mocks/mock_binary_search_merger.h | 15 | ||||
| -rw-r--r-- | extractor/mocks/mock_data_array.h | 19 | ||||
| -rw-r--r-- | extractor/mocks/mock_fast_intersector.h | 11 | ||||
| -rw-r--r-- | extractor/mocks/mock_feature.h | 9 | ||||
| -rw-r--r-- | extractor/mocks/mock_intersector.h | 11 | ||||
| -rw-r--r-- | extractor/mocks/mock_linear_merger.h | 15 | ||||
| -rw-r--r-- | extractor/mocks/mock_matchings_finder.h | 9 | ||||
| -rw-r--r-- | extractor/mocks/mock_precomputation.h | 9 | ||||
| -rw-r--r-- | extractor/mocks/mock_rule_extractor.h | 12 | ||||
| -rw-r--r-- | extractor/mocks/mock_rule_extractor_helper.h | 78 | ||||
| -rw-r--r-- | extractor/mocks/mock_rule_factory.h | 9 | ||||
| -rw-r--r-- | extractor/mocks/mock_sampler.h | 9 | ||||
| -rw-r--r-- | extractor/mocks/mock_scorer.h | 10 | ||||
| -rw-r--r-- | extractor/mocks/mock_suffix_array.h | 19 | ||||
| -rw-r--r-- | extractor/mocks/mock_target_phrase_extractor.h | 12 | ||||
| -rw-r--r-- | extractor/mocks/mock_translation_table.h | 9 | ||||
| -rw-r--r-- | extractor/mocks/mock_vocabulary.h | 9 | 
18 files changed, 275 insertions, 0 deletions
| diff --git a/extractor/mocks/mock_alignment.h b/extractor/mocks/mock_alignment.h new file mode 100644 index 00000000..4a5077ad --- /dev/null +++ b/extractor/mocks/mock_alignment.h @@ -0,0 +1,10 @@ +#include <gmock/gmock.h> + +#include "../alignment.h" + +typedef vector<pair<int, int> > SentenceLinks; + +class MockAlignment : public Alignment { + public: +  MOCK_CONST_METHOD1(GetLinks, SentenceLinks(int sentence_id)); +}; diff --git a/extractor/mocks/mock_binary_search_merger.h b/extractor/mocks/mock_binary_search_merger.h new file mode 100644 index 00000000..e23386f0 --- /dev/null +++ b/extractor/mocks/mock_binary_search_merger.h @@ -0,0 +1,15 @@ +#include <gmock/gmock.h> + +#include <vector> + +#include "../binary_search_merger.h" +#include "../phrase.h" + +using namespace std; + +class MockBinarySearchMerger: public BinarySearchMerger { + public: +  MOCK_CONST_METHOD9(Merge, void(vector<int>&, const Phrase&, const Phrase&, +      const vector<int>::iterator&, const vector<int>::iterator&, +      const vector<int>::iterator&, const vector<int>::iterator&, int, int)); +}; diff --git a/extractor/mocks/mock_data_array.h b/extractor/mocks/mock_data_array.h new file mode 100644 index 00000000..004e8906 --- /dev/null +++ b/extractor/mocks/mock_data_array.h @@ -0,0 +1,19 @@ +#include <gmock/gmock.h> + +#include "../data_array.h" + +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)); +}; diff --git a/extractor/mocks/mock_fast_intersector.h b/extractor/mocks/mock_fast_intersector.h new file mode 100644 index 00000000..201386f2 --- /dev/null +++ b/extractor/mocks/mock_fast_intersector.h @@ -0,0 +1,11 @@ +#include <gmock/gmock.h> + +#include "../fast_intersector.h" +#include "../phrase.h" +#include "../phrase_location.h" + +class MockFastIntersector : public FastIntersector { + public: +  MOCK_METHOD3(Intersect, PhraseLocation(PhraseLocation&, PhraseLocation&, +                                         const Phrase&)); +}; diff --git a/extractor/mocks/mock_feature.h b/extractor/mocks/mock_feature.h new file mode 100644 index 00000000..d2137629 --- /dev/null +++ b/extractor/mocks/mock_feature.h @@ -0,0 +1,9 @@ +#include <gmock/gmock.h> + +#include "../features/feature.h" + +class MockFeature : public Feature { + public: +  MOCK_CONST_METHOD1(Score, double(const FeatureContext& context)); +  MOCK_CONST_METHOD0(GetName, string()); +}; diff --git a/extractor/mocks/mock_intersector.h b/extractor/mocks/mock_intersector.h new file mode 100644 index 00000000..372fa7ea --- /dev/null +++ b/extractor/mocks/mock_intersector.h @@ -0,0 +1,11 @@ +#include <gmock/gmock.h> + +#include "../intersector.h" +#include "../phrase.h" +#include "../phrase_location.h" + +class MockIntersector : public Intersector { + public: +  MOCK_METHOD5(Intersect, PhraseLocation(const Phrase&, PhraseLocation&, +      const Phrase&, PhraseLocation&, const Phrase&)); +}; diff --git a/extractor/mocks/mock_linear_merger.h b/extractor/mocks/mock_linear_merger.h new file mode 100644 index 00000000..522c1f31 --- /dev/null +++ b/extractor/mocks/mock_linear_merger.h @@ -0,0 +1,15 @@ +#include <gmock/gmock.h> + +#include <vector> + +#include "../linear_merger.h" +#include "../phrase.h" + +using namespace std; + +class MockLinearMerger: public LinearMerger { + public: +  MOCK_METHOD9(Merge, void(vector<int>&, const Phrase&, const Phrase&, +      vector<int>::iterator, vector<int>::iterator, vector<int>::iterator, +      vector<int>::iterator, int, int)); +}; diff --git a/extractor/mocks/mock_matchings_finder.h b/extractor/mocks/mock_matchings_finder.h new file mode 100644 index 00000000..3e80d266 --- /dev/null +++ b/extractor/mocks/mock_matchings_finder.h @@ -0,0 +1,9 @@ +#include <gmock/gmock.h> + +#include "../matchings_finder.h" +#include "../phrase_location.h" + +class MockMatchingsFinder : public MatchingsFinder { + public: +  MOCK_METHOD3(Find, PhraseLocation(PhraseLocation&, const string&, int)); +}; diff --git a/extractor/mocks/mock_precomputation.h b/extractor/mocks/mock_precomputation.h new file mode 100644 index 00000000..987bdb2f --- /dev/null +++ b/extractor/mocks/mock_precomputation.h @@ -0,0 +1,9 @@ +#include <gmock/gmock.h> + +#include "../precomputation.h" + +class MockPrecomputation : public Precomputation { + public: +  MOCK_CONST_METHOD0(GetInvertedIndex, const Index&()); +  MOCK_CONST_METHOD0(GetCollocations, const Index&()); +}; diff --git a/extractor/mocks/mock_rule_extractor.h b/extractor/mocks/mock_rule_extractor.h new file mode 100644 index 00000000..f18e009a --- /dev/null +++ b/extractor/mocks/mock_rule_extractor.h @@ -0,0 +1,12 @@ +#include <gmock/gmock.h> + +#include "../phrase.h" +#include "../phrase_builder.h" +#include "../rule.h" +#include "../rule_extractor.h" + +class MockRuleExtractor : public RuleExtractor { + public: +  MOCK_CONST_METHOD2(ExtractRules, vector<Rule>(const Phrase&, +      const PhraseLocation&)); +}; diff --git a/extractor/mocks/mock_rule_extractor_helper.h b/extractor/mocks/mock_rule_extractor_helper.h new file mode 100644 index 00000000..63ff1048 --- /dev/null +++ b/extractor/mocks/mock_rule_extractor_helper.h @@ -0,0 +1,78 @@ +#include <gmock/gmock.h> + +#include <vector> + +#include "../rule_extractor_helper.h" + +using namespace std; + +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_METHOD3(CheckAlignedTerminals, bool(const vector<int>&, +      const vector<int>&, const vector<int>&)); +  MOCK_CONST_METHOD3(CheckTightPhrases, bool(const vector<int>&, +      const vector<int>&, const vector<int>&)); +  MOCK_CONST_METHOD1(GetGapOrder, vector<int>(const vector<pair<int, int> >&)); +  MOCK_CONST_METHOD3(GetSourceIndexes, Indexes(const vector<int>&, +      const vector<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& 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; +}; diff --git a/extractor/mocks/mock_rule_factory.h b/extractor/mocks/mock_rule_factory.h new file mode 100644 index 00000000..2a96be93 --- /dev/null +++ b/extractor/mocks/mock_rule_factory.h @@ -0,0 +1,9 @@ +#include <gmock/gmock.h> + +#include "../grammar.h" +#include "../rule_factory.h" + +class MockHieroCachingRuleFactory : public HieroCachingRuleFactory { + public: +  MOCK_METHOD1(GetGrammar, Grammar(const vector<int>& word_ids)); +}; diff --git a/extractor/mocks/mock_sampler.h b/extractor/mocks/mock_sampler.h new file mode 100644 index 00000000..b2306109 --- /dev/null +++ b/extractor/mocks/mock_sampler.h @@ -0,0 +1,9 @@ +#include <gmock/gmock.h> + +#include "../phrase_location.h" +#include "../sampler.h" + +class MockSampler : public Sampler { + public: +  MOCK_CONST_METHOD1(Sample, PhraseLocation(const PhraseLocation& location)); +}; diff --git a/extractor/mocks/mock_scorer.h b/extractor/mocks/mock_scorer.h new file mode 100644 index 00000000..48115ef4 --- /dev/null +++ b/extractor/mocks/mock_scorer.h @@ -0,0 +1,10 @@ +#include <gmock/gmock.h> + +#include "../scorer.h" +#include "../features/feature.h" + +class MockScorer : public Scorer { + public: +  MOCK_CONST_METHOD1(Score, vector<double>(const FeatureContext& context)); +  MOCK_CONST_METHOD0(GetFeatureNames, vector<string>()); +}; diff --git a/extractor/mocks/mock_suffix_array.h b/extractor/mocks/mock_suffix_array.h new file mode 100644 index 00000000..11a3a443 --- /dev/null +++ b/extractor/mocks/mock_suffix_array.h @@ -0,0 +1,19 @@ +#include <gmock/gmock.h> + +#include <memory> +#include <string> + +#include "../data_array.h" +#include "../phrase_location.h" +#include "../suffix_array.h" + +using namespace std; + +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)); +}; diff --git a/extractor/mocks/mock_target_phrase_extractor.h b/extractor/mocks/mock_target_phrase_extractor.h new file mode 100644 index 00000000..6dc6bba6 --- /dev/null +++ b/extractor/mocks/mock_target_phrase_extractor.h @@ -0,0 +1,12 @@ +#include <gmock/gmock.h> + +#include "../target_phrase_extractor.h" + +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)); +}; diff --git a/extractor/mocks/mock_translation_table.h b/extractor/mocks/mock_translation_table.h new file mode 100644 index 00000000..a35c9327 --- /dev/null +++ b/extractor/mocks/mock_translation_table.h @@ -0,0 +1,9 @@ +#include <gmock/gmock.h> + +#include "../translation_table.h" + +class MockTranslationTable : public TranslationTable { + public: +  MOCK_METHOD2(GetSourceGivenTargetScore, double(const string&, const string&)); +  MOCK_METHOD2(GetTargetGivenSourceScore, double(const string&, const string&)); +}; diff --git a/extractor/mocks/mock_vocabulary.h b/extractor/mocks/mock_vocabulary.h new file mode 100644 index 00000000..e5c191f5 --- /dev/null +++ b/extractor/mocks/mock_vocabulary.h @@ -0,0 +1,9 @@ +#include <gmock/gmock.h> + +#include "../vocabulary.h" + +class MockVocabulary : public Vocabulary { + public: +  MOCK_METHOD1(GetTerminalValue, string(int word_id)); +  MOCK_METHOD1(GetTerminalIndex, int(const string& word)); +}; | 
