#include #include #include #include #include "grammar.h" #include "grammar_extractor.h" #include "mocks/mock_rule_factory.h" #include "mocks/mock_vocabulary.h" #include "rule.h" using namespace std; using namespace ::testing; namespace extractor { namespace { TEST(GrammarExtractorTest, TestAnnotatingWords) { shared_ptr vocabulary = make_shared(); EXPECT_CALL(*vocabulary, GetTerminalIndex("")) .WillRepeatedly(Return(0)); EXPECT_CALL(*vocabulary, GetTerminalIndex("Anna")) .WillRepeatedly(Return(1)); EXPECT_CALL(*vocabulary, GetTerminalIndex("has")) .WillRepeatedly(Return(2)); EXPECT_CALL(*vocabulary, GetTerminalIndex("many")) .WillRepeatedly(Return(3)); EXPECT_CALL(*vocabulary, GetTerminalIndex("apples")) .WillRepeatedly(Return(4)); EXPECT_CALL(*vocabulary, GetTerminalIndex(".")) .WillRepeatedly(Return(5)); EXPECT_CALL(*vocabulary, GetTerminalIndex("")) .WillRepeatedly(Return(6)); shared_ptr factory = make_shared(); vector word_ids = {0, 1, 2, 3, 3, 4, 5, 6}; vector rules; vector feature_names; Grammar grammar(rules, feature_names); unordered_set blacklisted_sentence_ids; shared_ptr source_data_array; EXPECT_CALL(*factory, GetGrammar(word_ids, blacklisted_sentence_ids)) .WillOnce(Return(grammar)); GrammarExtractor extractor(vocabulary, factory); string sentence = "Anna has many many apples ."; extractor.GetGrammar(sentence, blacklisted_sentence_ids); } } // namespace } // namespace extractor