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 // 00014 // IndriTermInfoList.hpp 00015 // 00016 // 13 August 2004 -- tds 00017 // 00018 00019 #ifndef INDRI_TERMINFOLIST_HPP 00020 #define INDRI_TERMINFOLIST_HPP 00021 00022 #include "InvFPTypes.hpp" 00023 #include "TermInfoList.hpp" 00024 00025 00026 namespace indri { 00027 namespace index { 00028 class BagList : public lemur::api::TermInfoList { 00029 private: 00030 const class TermList* _list; 00031 std::vector< std::pair<lemur::api::TERMID_T, int> > _termCounts; 00032 lemur::api::TermInfo _info; 00033 int _position; 00034 00035 public: 00036 BagList( const class TermList *list ) ; 00037 00038 ~BagList() ; 00039 00040 void startIteration() const ; 00041 bool hasMore() const ; 00042 lemur::api::TermInfo* nextEntry() const ; 00043 00045 virtual int size(); 00046 00049 virtual lemur::api::TermInfo* operator[](int index) const; 00050 00051 // Note: even though we have position information here, I'm not returning it 00052 // if you really really want it, put in a feature request or something 00053 lemur::api::TermInfo* getElement( lemur::api::TermInfo* elem, lemur::api::POS_T position ) const ; 00054 00055 lemur::api::POS_T beginPosition() const ; 00056 00057 lemur::api::POS_T endPosition() const ; 00058 00059 lemur::api::POS_T nextPosition( lemur::api::POS_T position ) const ; 00060 }; 00061 00062 class PositionInfo : public lemur::api::TermInfo { 00063 private: 00064 int _position; 00065 00066 public: 00067 void position( int p ) { 00068 _position = p; 00069 } 00070 00071 int position() { 00072 return _position; 00073 } 00074 }; 00075 00076 class PositionList : public lemur::api::TermInfoList { 00077 private: 00078 const class TermList* _list; 00079 PositionInfo _info; 00080 int _position; 00081 00082 public: 00083 PositionList( const class TermList* list ) ; 00084 ~PositionList() ; 00085 00086 lemur::api::TermInfo* newElement() ; 00087 00088 void assignElement( lemur::api::TermInfo* to, lemur::api::TermInfo* from ) ; 00089 00090 lemur::api::TermInfo* getElement( lemur::api::TermInfo* elem, lemur::api::POS_T position ) const ; 00091 00092 lemur::api::POS_T beginPosition() const ; 00093 00094 lemur::api::POS_T endPosition() const ; 00095 00096 lemur::api::POS_T nextPosition( lemur::api::POS_T position ) const ; 00097 00098 void startIteration() const ; 00099 00100 bool hasMore() const ; 00101 00102 lemur::api::TermInfo* nextEntry() const ; 00103 00105 virtual int size(); 00106 00109 virtual lemur::api::TermInfo* operator[](int index) const; 00110 00111 }; 00112 } 00113 } 00114 00115 #endif // INDRI_TERMINFOLIST_HPP 00116