00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef _INVFPINDEX_HPP
00014 #define _INVFPINDEX_HPP
00015
00017 #include "common_headers.hpp"
00018 #include "Index.hpp"
00019 #include "InvFPDocList.hpp"
00020 #include "InvFPTermList.hpp"
00021 #include "InvFPTypes.hpp"
00022
00023
00024
00025 #define UNIQUE_TERMS 0
00026 #define TOTAL_TERMS 1
00027 #define DOCS 2
00028 #define DT_FILES 3
00029 #define INV_FILES 4
00030
00031
00032 #define DOC_INDEX 0
00033 #define DOC_LOOKUP 1
00034 #define TERM_INDEX 2
00035 #define TERM_LOOKUP 3
00036 #define TERM_IDS 4
00037 #define DOC_IDS 5
00038
00039 class InvFPIndex : public Index {
00040 public:
00041 InvFPIndex();
00042 InvFPIndex(const char* indexName);
00043 ~InvFPIndex();
00044
00046
00047
00049 bool open(const char* indexName);
00051
00053 bool openName(char* filename);
00054
00056
00057
00059 int term(const char* word);
00060
00062 const char* term(int termID);
00063
00065 int document(const char* docIDStr);
00066
00068 const char* document(int docID);
00069
00071
00073
00074
00076 int docCount() { return counts[DOCS]; };
00077
00079 int termCountUnique() { return counts[UNIQUE_TERMS]; };
00080
00082 int termCount(int termID) const;
00083
00085 int termCount() const { return counts[TOTAL_TERMS]; };
00086
00088 float docLengthAvg();
00089
00091 int docCount(int termID);
00092
00094 int docLength(DOCID_T docID) const;
00095
00097 int docLengthCounted(int docID);
00098
00100
00102
00103
00104 DocInfoList* docInfoList(int termID);
00105
00107 TermInfoList* termInfoList(int docID);
00108
00110 TermInfoList* termInfoListSeq(int docID);
00111
00113 private:
00115 bool fullToc(const char* fileName);
00117 bool mainToc(char* fileName);
00119 bool indexLookup();
00121 bool invFileIDs();
00123 bool dtLookup();
00125 bool dtFileIDs();
00127 bool termIDs();
00129 bool docIDs();
00130
00131 int* counts;
00132 char** names;
00133 float aveDocLen;
00134 inv_entry* lookup;
00135 dt_entry* dtlookup;
00136 TERM_T* terms;
00137 EXDOCID_T* docnames;
00138 char** dtfiles;
00139 char** invfiles;
00140 map<TERM_T, TERMID_T, ltstr> termtable;
00141 map<EXDOCID_T, DOCID_T, ltstr> doctable;
00142 };
00143
00144 #endif