Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class 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 namespace lemur 
00022 {
00023   namespace api 
00024   {
00025     
00027     class TMatch {
00028     public:
00029                 TMatch() : tid(-1), start(0), end(0), position(0)  {};
00030       TMatch(TERMID_T t, int s, int e, int p): tid(t), start(s), end(e), 
00031                                                position(p) { }
00033       TERMID_T tid;
00035       int start;
00037       int end;
00039       int position;
00040     };
00041 
00043 
00049     class MatchInfo : public vector<TMatch> {
00050     public: 
00052       virtual ~MatchInfo() {}
00053 
00055       int count() const {return size();}
00056 
00058       // void startIteration() const {iter = matchList.begin();}
00060       //bool hasMore() const {return(iter != matchList.end());}
00061 
00063       //TMatch nextMatch() const {TMatch ret = *iter; iter++; return ret;}
00064 
00069       static MatchInfo *getMatches(const Index &ind, const Query &qry, DOCID_T docID);
00070 
00071     private:
00073       MatchInfo() {}
00074 
00076       void add(TERMID_T tid, int position, int start=-1, int end=-1) {
00077         TMatch t(tid, start, end, position);
00078         //matchList.push_back(t);
00079         push_back(t);
00080       }
00081 
00083       class TMatchAscending {
00084       public:
00085         bool operator()(const TMatch & a, const TMatch & b) {
00086           return a.position < b.position;
00087         }
00088       };
00089 
00091       void sort() {
00092         TMatchAscending tma;
00093         //    std::sort(matchList.begin(), matchList.end(), tma);
00094         std::sort(this->begin(), this->end(), tma);
00095       }
00096 
00098       //  vector<TMatch> matchList;
00100       //mutable vector<TMatch>::iterator iter;
00101     };
00102   }
00103 }
00104 
00105 #endif

Generated on Tue Jun 15 11:02:54 2010 for Lemur by doxygen 1.3.4