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 ::TermInfoList { 00029 private: 00030 class TermListBuilder* _list; 00031 std::vector< std::pair<int, int> > _termCounts; 00032 TermInfo _info; 00033 int _position; 00034 00035 public: 00036 BagList( class TermListBuilder *list ) ; 00037 00038 ~BagList() ; 00039 00040 void startIteration() const ; 00041 bool hasMore() const ; 00042 TermInfo* nextEntry() const ; 00043 00044 // Note: even though we have position information here, I'm not returning it 00045 // if you really really want it, put in a feature request or something 00046 TermInfo* getElement( TermInfo* elem, POS_T position ) const ; 00047 00048 POS_T beginPosition() const ; 00049 00050 POS_T endPosition() const ; 00051 00052 POS_T nextPosition( POS_T position ) const ; 00053 }; 00054 00055 class PositionInfo : public ::TermInfo { 00056 private: 00057 int _position; 00058 00059 public: 00060 void position( int p ) { 00061 _position = p; 00062 } 00063 00064 int position() { 00065 return _position; 00066 } 00067 }; 00068 00069 class PositionList : public ::TermInfoList { 00070 private: 00071 class TermListBuilder* _list; 00072 PositionInfo _info; 00073 int _position; 00074 00075 public: 00076 PositionList( class TermListBuilder* list ) ; 00077 ~PositionList() ; 00078 00079 TermInfo* newElement() ; 00080 00081 void assignElement( TermInfo* to, TermInfo* from ) ; 00082 00083 TermInfo* getElement( TermInfo* elem, POS_T position ) const ; 00084 00085 POS_T beginPosition() const ; 00086 00087 POS_T endPosition() const ; 00088 00089 POS_T nextPosition( POS_T position ) const ; 00090 00091 void startIteration() const ; 00092 00093 bool hasMore() const ; 00094 00095 TermInfo* nextEntry() const ; 00096 }; 00097 }; 00098 } 00099 00100 #endif // INDRI_TERMINFOLIST_HPP 00101