Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

QueryExpander.hpp

Go to the documentation of this file.
00001 /*==========================================================================
00002  * Copyright (c) 2004 University of Massachusetts.  All Rights Reserved.
00003  *
00004  * Use of the Lemur Toolkit for Language Modeling and Information Retrieval
00005  * is subject to the terms of the software license set forth in the LICENSE
00006  * file included with this software, and also available at
00007  * http://www.lemurproject.org/license.html
00008  *
00009  *==========================================================================
00010 */
00011 
00012 //
00013 // QueryExpander
00014 //
00015 // 18 Aug 2004 -- dam
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   // runs original query, expands query based on results ( via expand( .. ) ), then runs expanded query
00053   std::vector<ScoredExtentResult> runExpandedQuery( std::string originalQuery , int resultsRequested , bool verbose = false );
00054   
00055   // creates expanded query from an original query and a ranked list of documents
00056   virtual std::string expand( std::string originalQuery , std::vector<ScoredExtentResult>& results ) = 0;
00057 };
00058 
00059 #endif

Generated on Wed Nov 3 12:59:02 2004 for Lemur Toolkit by doxygen1.2.18