00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef INDRI_QUERYEXPANDER_HPP
00019 #define INDRI_QUERYEXPANDER_HPP
00020
00021 #include <string>
00022 #include <vector>
00023 #include <map>
00024
00025 #include "indri/QueryEnvironment.hpp"
00026 #include "indri/Parameters.hpp"
00027
00028 struct QueryExpanderSort {
00029 public:
00030 bool operator() ( const std::pair<std::string, double>& one, const std::pair<std::string, double>& two ) const {
00031 return one.second > two.second;
00032 }
00033 };
00034
00035 class QueryExpander {
00036 private:
00037 std::map<std::string, int> _cf_cache;
00038
00039 protected:
00040 QueryEnvironment * _env;
00041 Parameters _param;
00042
00043 std::vector<DocumentVector*> getDocumentVectors( std::vector<ScoredExtentResult>& results, int rmDocs );
00044 std::vector<std::string> * getVocabulary( std::vector<ScoredExtentResult>& results, int rmDocs );
00045 std::vector<std::string> * getVocabulary( std::vector<DocumentVector*>& docVectors );
00046 int getCF( std::string term );
00047
00048 public:
00049 QueryExpander( QueryEnvironment * env , Parameters& param );
00050 virtual ~QueryExpander() {};
00051
00052
00053 std::vector<ScoredExtentResult> runExpandedQuery( std::string originalQuery , int resultsRequested , bool verbose = false );
00054
00055
00056 virtual std::string expand( std::string originalQuery , std::vector<ScoredExtentResult>& results ) = 0;
00057 };
00058
00059 #endif