Concordia
concordia_search_result.hpp
1 #ifndef CONCORDIA_SEARCH_RESULT_HDR
2 #define CONCORDIA_SEARCH_RESULT_HDR
3 
4 #include "concordia/common/config.hpp"
5 #include "concordia/matched_pattern_fragment.hpp"
6 #include "concordia/tokenized_sentence.hpp"
7 
8 #include <boost/shared_ptr.hpp>
9 #include <vector>
10 #include <string>
11 
25 public:
29  explicit ConcordiaSearchResult(TokenizedSentence tokenizedPattern);
30 
33  virtual ~ConcordiaSearchResult();
34 
38  void addFragment(const MatchedPatternFragment & fragment);
39 
43  void sortFragments();
44 
48  void computeBestOverlay();
49 
54  return _tokenizedPattern;
55  }
56 
60  std::vector<MatchedPatternFragment> getFragments() const {
61  return _matchedPatternFragments;
62  }
63 
67  std::vector<MatchedPatternFragment> getBestOverlay() const {
68  return _bestOverlay;
69  }
70 
74  double getBestOverlayScore() const {
75  return _bestOverlayScore;
76  }
77 
78  friend std::ostream & operator << (std::ostream & o,
79  const ConcordiaSearchResult & result) {
80  o << "Best overlay {" << std::endl;
81  BOOST_FOREACH(MatchedPatternFragment fragment,
82  result.getBestOverlay()) {
83  o << fragment << std::endl;
84  }
85  o << "}" << std::endl;
86  o << "All fragments {" << std::endl;
87  BOOST_FOREACH(MatchedPatternFragment fragment,
88  result.getFragments()) {
89  o << fragment << std::endl;
90  }
91  o << "}";
92  return o;
93  }
94 
95 
96 private:
97  void _checkPossibleOverlays(
98  std::vector<MatchedPatternFragment> currentOverlay,
99  SUFFIX_MARKER_TYPE lastAddedPos,
100  SUFFIX_MARKER_TYPE patternSize);
101 
102  TokenizedSentence _tokenizedPattern;
103 
104  std::vector<MatchedPatternFragment> _matchedPatternFragments;
105 
106  std::vector<MatchedPatternFragment> _bestOverlay;
107 
108  double _bestOverlayScore;
109 };
110 
111 #endif
virtual ~ConcordiaSearchResult()
Definition: concordia_search_result.cpp:12
ConcordiaSearchResult(TokenizedSentence tokenizedPattern)
Definition: concordia_search_result.cpp:6
void addFragment(const MatchedPatternFragment &fragment)
Definition: concordia_search_result.cpp:15
void computeBestOverlay()
Definition: concordia_search_result.cpp:26
void sortFragments()
Definition: concordia_search_result.cpp:20
Definition: tokenized_sentence.hpp:26
std::vector< MatchedPatternFragment > getBestOverlay() const
Definition: concordia_search_result.hpp:67
double getBestOverlayScore() const
Definition: concordia_search_result.hpp:74
Definition: matched_pattern_fragment.hpp:21
std::vector< MatchedPatternFragment > getFragments() const
Definition: concordia_search_result.hpp:60
Definition: concordia_search_result.hpp:24
TokenizedSentence getTokenizedPattern() const
Definition: concordia_search_result.hpp:53