#ifndef _RULE_FACTORY_H_ #define _RULE_FACTORY_H_ #include #include #include "matchings_trie.h" #include "phrase_builder.h" using namespace std; class Alignment; class DataArray; class Grammar; class MatchingsFinder; class FastIntersector; class Precomputation; class Rule; class RuleExtractor; class Sampler; class Scorer; class State; class SuffixArray; class Vocabulary; class HieroCachingRuleFactory { public: HieroCachingRuleFactory( shared_ptr source_suffix_array, shared_ptr target_data_array, shared_ptr alignment, const shared_ptr& vocabulary, shared_ptr precomputation, shared_ptr scorer, int min_gap_size, int max_rule_span, int max_nonterminals, int max_rule_symbols, int max_samples, bool require_tight_phrases); // For testing only. HieroCachingRuleFactory( shared_ptr finder, shared_ptr fast_intersector, shared_ptr phrase_builder, shared_ptr rule_extractor, shared_ptr vocabulary, shared_ptr sampler, shared_ptr scorer, int min_gap_size, int max_rule_span, int max_nonterminals, int max_chunks, int max_rule_symbols); virtual ~HieroCachingRuleFactory(); virtual Grammar GetGrammar(const vector& word_ids); protected: HieroCachingRuleFactory(); private: bool CannotHaveMatchings(shared_ptr node, int word_id); bool RequiresLookup(shared_ptr node, int word_id); void AddTrailingNonterminal(vector symbols, const Phrase& prefix, const shared_ptr& prefix_node, bool starts_with_x); vector ExtendState(const vector& word_ids, const State& state, vector symbols, const Phrase& phrase, const shared_ptr& node); shared_ptr matchings_finder; shared_ptr fast_intersector; MatchingsTrie trie; shared_ptr phrase_builder; shared_ptr rule_extractor; shared_ptr vocabulary; shared_ptr sampler; shared_ptr scorer; int min_gap_size; int max_rule_span; int max_nonterminals; int max_chunks; int max_rule_symbols; }; #endif