diff options
author | Chris Dyer <cdyer@allegro.clab.cs.cmu.edu> | 2013-04-23 19:35:18 -0400 |
---|---|---|
committer | Chris Dyer <cdyer@allegro.clab.cs.cmu.edu> | 2013-04-23 19:35:18 -0400 |
commit | 6d347f1ce078dede3da0e1498f75e357351c6543 (patch) | |
tree | 8e872b8747c530e741e55e25e9917c1bd8b32c5b /extractor/mocks | |
parent | d11b76def6899790161c47a73018146311356d8b (diff) | |
parent | 5e9605b65202f4e5fc59843b197d88c4774f0ac8 (diff) |
merge paul's extractor code
Diffstat (limited to 'extractor/mocks')
-rw-r--r-- | extractor/mocks/mock_alignment.h | 14 | ||||
-rw-r--r-- | extractor/mocks/mock_data_array.h | 23 | ||||
-rw-r--r-- | extractor/mocks/mock_fast_intersector.h | 15 | ||||
-rw-r--r-- | extractor/mocks/mock_feature.h | 15 | ||||
-rw-r--r-- | extractor/mocks/mock_matchings_finder.h | 13 | ||||
-rw-r--r-- | extractor/mocks/mock_precomputation.h | 12 | ||||
-rw-r--r-- | extractor/mocks/mock_rule_extractor.h | 16 | ||||
-rw-r--r-- | extractor/mocks/mock_rule_extractor_helper.h | 82 | ||||
-rw-r--r-- | extractor/mocks/mock_rule_factory.h | 13 | ||||
-rw-r--r-- | extractor/mocks/mock_sampler.h | 13 | ||||
-rw-r--r-- | extractor/mocks/mock_scorer.h | 15 | ||||
-rw-r--r-- | extractor/mocks/mock_suffix_array.h | 23 | ||||
-rw-r--r-- | extractor/mocks/mock_target_phrase_extractor.h | 16 | ||||
-rw-r--r-- | extractor/mocks/mock_translation_table.h | 13 | ||||
-rw-r--r-- | extractor/mocks/mock_vocabulary.h | 13 |
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 |