#ifndef _FAST_INTERSECTOR_H_ #define _FAST_INTERSECTOR_H_ #include #include #include #include using namespace std; namespace extractor { typedef boost::hash > VectorHash; typedef unordered_map, vector, VectorHash> Index; class Phrase; class PhraseLocation; class Precomputation; class SuffixArray; class Vocabulary; class FastIntersector { public: FastIntersector(shared_ptr suffix_array, shared_ptr precomputation, shared_ptr vocabulary, int max_rule_span, int min_gap_size); virtual ~FastIntersector(); virtual PhraseLocation Intersect(PhraseLocation& prefix_location, PhraseLocation& suffix_location, const Phrase& phrase); protected: FastIntersector(); private: vector ConvertPhrase(const vector& old_phrase); int EstimateNumOperations(const PhraseLocation& phrase_location, bool has_margin_x) const; PhraseLocation ExtendPrefixPhraseLocation(PhraseLocation& prefix_location, const Phrase& phrase, bool prefix_ends_with_x, int next_symbol) const; PhraseLocation ExtendSuffixPhraseLocation(PhraseLocation& suffix_location, const Phrase& phrase, bool suffix_starts_with_x, int prev_symbol) const; void ExtendPhraseLocation(PhraseLocation& location) const; pair GetSearchRange(bool has_marginal_x) const; shared_ptr suffix_array; shared_ptr vocabulary; int max_rule_span; int min_gap_size; Index collocations; }; } // namespace extractor #endif