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

MatchInfo.hpp

Go to the documentation of this file.
00001 /*==========================================================================
00002  * Copyright (c) 2002-2003 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  * author: dmf
00013  * 
00014 */
00015 #ifndef _MATCHINFO_HPP_
00016 #define _MATCHINFO_HPP_
00017 #include <vector>
00018 #include <algorithm>
00019 
00020 #include "RetrievalMethod.hpp"
00021 
00023 class TMatch {
00024 public:
00025   TMatch(TERMID_T t, int s, int e, int p): tid(t), start(s), end(e), 
00026                                       position(p) { }
00028   TERMID_T tid;
00030   int start;
00032   int end;
00034   int position;
00035 };
00036 
00042 class MatchInfo : public vector<TMatch> {
00043 public: 
00045   virtual ~MatchInfo() {}
00046 
00048   int count() const {return size();}
00049 
00051   // void startIteration() const {iter = matchList.begin();}
00053   //bool hasMore() const {return(iter != matchList.end());}
00054 
00056   //TMatch nextMatch() const {TMatch ret = *iter; iter++; return ret;}
00057 
00062   static MatchInfo *getMatches(const Index &ind, const Query &qry, DOCID_T docID);
00063 
00064 private:
00066   MatchInfo() {}
00067 
00069   void add(TERMID_T tid, int position, int start=-1, int end=-1) {
00070     TMatch t(tid, start, end, position);
00071     //matchList.push_back(t);
00072     push_back(t);
00073   }
00074 
00076   class TMatchAscending {
00077   public:
00078     bool operator()(const TMatch & a, const TMatch & b) {
00079       return a.position < b.position;
00080     }
00081   };
00082 
00084   void sort() {
00085     TMatchAscending tma;
00086     //    std::sort(matchList.begin(), matchList.end(), tma);
00087     std::sort(this->begin(), this->end(), tma);
00088   }
00089 
00091   //  vector<TMatch> matchList;
00093   //mutable vector<TMatch>::iterator iter;
00094 };
00095 #endif

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