summaryrefslogtreecommitdiff
path: root/extractor/rule_factory_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'extractor/rule_factory_test.cc')
-rw-r--r--extractor/rule_factory_test.cc57
1 files changed, 6 insertions, 51 deletions
diff --git a/extractor/rule_factory_test.cc b/extractor/rule_factory_test.cc
index d329382a..fc709461 100644
--- a/extractor/rule_factory_test.cc
+++ b/extractor/rule_factory_test.cc
@@ -6,7 +6,6 @@
#include "grammar.h"
#include "mocks/mock_fast_intersector.h"
-#include "mocks/mock_intersector.h"
#include "mocks/mock_matchings_finder.h"
#include "mocks/mock_rule_extractor.h"
#include "mocks/mock_sampler.h"
@@ -25,7 +24,6 @@ class RuleFactoryTest : public Test {
protected:
virtual void SetUp() {
finder = make_shared<MockMatchingsFinder>();
- intersector = make_shared<MockIntersector>();
fast_intersector = make_shared<MockFastIntersector>();
vocabulary = make_shared<MockVocabulary>();
@@ -55,7 +53,6 @@ class RuleFactoryTest : public Test {
vector<string> feature_names;
shared_ptr<MockMatchingsFinder> finder;
- shared_ptr<MockIntersector> intersector;
shared_ptr<MockFastIntersector> fast_intersector;
shared_ptr<MockVocabulary> vocabulary;
shared_ptr<PhraseBuilder> phrase_builder;
@@ -66,81 +63,39 @@ class RuleFactoryTest : public Test {
};
TEST_F(RuleFactoryTest, TestGetGrammarDifferentWords) {
- factory = make_shared<HieroCachingRuleFactory>(finder, intersector,
- fast_intersector, phrase_builder, extractor, vocabulary, sampler,
- scorer, 1, 10, 2, 3, 5, false);
+ factory = make_shared<HieroCachingRuleFactory>(finder, fast_intersector,
+ phrase_builder, extractor, vocabulary, sampler, scorer, 1, 10, 2, 3, 5);
EXPECT_CALL(*finder, Find(_, _, _))
.Times(6)
.WillRepeatedly(Return(PhraseLocation(0, 1)));
- EXPECT_CALL(*intersector, Intersect(_, _, _, _, _))
+ EXPECT_CALL(*fast_intersector, Intersect(_, _, _))
.Times(1)
.WillRepeatedly(Return(PhraseLocation(0, 1)));
- EXPECT_CALL(*fast_intersector, Intersect(_, _, _)).Times(0);
vector<int> word_ids = {2, 3, 4};
Grammar grammar = factory->GetGrammar(word_ids);
EXPECT_EQ(feature_names, grammar.GetFeatureNames());
EXPECT_EQ(7, grammar.GetRules().size());
-
- // Test for fast intersector.
- factory = make_shared<HieroCachingRuleFactory>(finder, intersector,
- fast_intersector, phrase_builder, extractor, vocabulary, sampler,
- scorer, 1, 10, 2, 3, 5, true);
-
- EXPECT_CALL(*finder, Find(_, _, _))
- .Times(6)
- .WillRepeatedly(Return(PhraseLocation(0, 1)));
-
- EXPECT_CALL(*fast_intersector, Intersect(_, _, _))
- .Times(1)
- .WillRepeatedly(Return(PhraseLocation(0, 1)));
- EXPECT_CALL(*intersector, Intersect(_, _, _, _, _)).Times(0);
-
- grammar = factory->GetGrammar(word_ids);
- EXPECT_EQ(feature_names, grammar.GetFeatureNames());
- EXPECT_EQ(7, grammar.GetRules().size());
}
TEST_F(RuleFactoryTest, TestGetGrammarRepeatingWords) {
- factory = make_shared<HieroCachingRuleFactory>(finder, intersector,
- fast_intersector, phrase_builder, extractor, vocabulary, sampler,
- scorer, 1, 10, 2, 3, 5, false);
+ factory = make_shared<HieroCachingRuleFactory>(finder, fast_intersector,
+ phrase_builder, extractor, vocabulary, sampler, scorer, 1, 10, 2, 3, 5);
EXPECT_CALL(*finder, Find(_, _, _))
.Times(12)
.WillRepeatedly(Return(PhraseLocation(0, 1)));
- EXPECT_CALL(*intersector, Intersect(_, _, _, _, _))
+ EXPECT_CALL(*fast_intersector, Intersect(_, _, _))
.Times(16)
.WillRepeatedly(Return(PhraseLocation(0, 1)));
- EXPECT_CALL(*fast_intersector, Intersect(_, _, _)).Times(0);
-
vector<int> word_ids = {2, 3, 4, 2, 3};
Grammar grammar = factory->GetGrammar(word_ids);
EXPECT_EQ(feature_names, grammar.GetFeatureNames());
EXPECT_EQ(28, grammar.GetRules().size());
-
- // Test for fast intersector.
- factory = make_shared<HieroCachingRuleFactory>(finder, intersector,
- fast_intersector, phrase_builder, extractor, vocabulary, sampler,
- scorer, 1, 10, 2, 3, 5, true);
-
- EXPECT_CALL(*finder, Find(_, _, _))
- .Times(12)
- .WillRepeatedly(Return(PhraseLocation(0, 1)));
-
- EXPECT_CALL(*fast_intersector, Intersect(_, _, _))
- .Times(16)
- .WillRepeatedly(Return(PhraseLocation(0, 1)));
-
- EXPECT_CALL(*intersector, Intersect(_, _, _, _, _)).Times(0);
-
- grammar = factory->GetGrammar(word_ids);
- EXPECT_EQ(feature_names, grammar.GetFeatureNames());
- EXPECT_EQ(28, grammar.GetRules().size());
}
} // namespace