| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectir.vsr.InvertedIndex
public class InvertedIndex
An inverted index for vector-space information retrieval. Contains methods for creating an inverted index from a set of documents and retrieving ranked matches to queries using standard TF/IDF weighting and cosine similarity.
| Field Summary | |
|---|---|
|  java.io.File | dirFileThe directory from which the indexed documents come. | 
|  java.util.List<DocumentReference> | docRefsA list of all indexed documents. | 
|  short | docTypeThe type of Documents (text, HTML). | 
|  boolean | feedbackWhether relevance feedback using the Ide_regular algorithm is used | 
| static int | MAX_RETRIEVALSThe maximum number of retrieved documents for a query to present to the user at a time | 
|  boolean | stemWhether tokens should be stemmed with Porter stemmer | 
|  java.util.Map<java.lang.String,TokenInfo> | tokenHashA HashMap where tokens are indexed. | 
| Constructor Summary | |
|---|---|
| InvertedIndex(java.io.File dirFile,
              short docType,
              boolean stem,
              boolean feedback)Create an inverted index of the documents in a directory. | |
| InvertedIndex(java.util.List<Example> examples)Create an inverted index of the documents in a List of Example objects of documents for text categorization. | |
| Method Summary | |
|---|---|
|  void | clear()Clear all documents from the inverted index | 
| protected  void | computeIDFandDocumentLengths()Compute the IDF factor for every token in the index and the length of the document vector for every document referenced in the index. | 
| protected  Retrieval | getRetrieval(double queryLength,
             DocumentReference docRef,
             double score)Calculate the final score for a retrieval and return a Retrieval object representing the retrieval with its final score. | 
|  double | incorporateToken(java.lang.String token,
                 double count,
                 java.util.Map<DocumentReference,DoubleValue> retrievalHash)Retrieve the documents indexed by this token in the inverted index, add it to the retrievalHash if needed, and update its running total score. | 
| protected  void | indexDocument(FileDocument doc,
              HashMapVector vector)Index the given document using its corresponding vector | 
| protected  void | indexDocuments()Index the documents in dirFile. | 
|  void | indexDocuments(java.util.List<Example> examples)Index the documents in the List of Examples for text categorization. | 
| protected  void | indexToken(java.lang.String token,
           int count,
           DocumentReference docRef)Add a token occurrence to the index. | 
| static void | main(java.lang.String[] args)Index a directory of files and then interactively accept retrieval queries. | 
|  void | presentRetrievals(HashMapVector queryVector,
                  Retrieval[] retrievals)Print out a ranked set of retrievals. | 
|  void | print()Print out an inverted index by listing each token and the documents it occurs in. | 
|  void | printRetrievals(Retrieval[] retrievals,
                int start)Print out at most MAX_RETRIEVALS ranked retrievals starting at given starting rank number. | 
|  void | processQueries()Enter an interactive user-query loop, accepting queries and showing the retrieved documents in ranked order. | 
|  Retrieval[] | retrieve(Document doc)Perform ranked retrieval on this input query Document. | 
|  Retrieval[] | retrieve(HashMapVector vector)Perform ranked retrieval on this input query Document vector. | 
|  Retrieval[] | retrieve(java.lang.String input)Perform ranked retrieval on this input query. | 
|  boolean | showRetrievals(Retrieval[] retrievals)Show the top retrievals to the user if there are any. | 
|  int | size()Return the number of tokens indexed. | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
public static final int MAX_RETRIEVALS
public java.util.Map<java.lang.String,TokenInfo> tokenHash
public java.util.List<DocumentReference> docRefs
public java.io.File dirFile
public short docType
public boolean stem
public boolean feedback
| Constructor Detail | 
|---|
public InvertedIndex(java.io.File dirFile,
                     short docType,
                     boolean stem,
                     boolean feedback)
dirFile - The directory of files to index.docType - The type of documents to index (See docType in DocumentIterator)stem - Whether tokens should be stemmed with Porter stemmer.feedback - Whether relevance feedback should be used.public InvertedIndex(java.util.List<Example> examples)
examples - A List containing the Example objects for text categorization to index| Method Detail | 
|---|
protected void indexDocuments()
public void indexDocuments(java.util.List<Example> examples)
protected void indexDocument(FileDocument doc,
                             HashMapVector vector)
protected void indexToken(java.lang.String token,
                          int count,
                          DocumentReference docRef)
token - The token to index.count - The number of times it occurs in the document.docRef - A reference to the Document it occurs in.protected void computeIDFandDocumentLengths()
public void print()
public int size()
public void clear()
public Retrieval[] retrieve(java.lang.String input)
public Retrieval[] retrieve(Document doc)
public Retrieval[] retrieve(HashMapVector vector)
protected Retrieval getRetrieval(double queryLength,
                                 DocumentReference docRef,
                                 double score)
queryLength - The length of the query vector, incorporated into the final scoredocRef - The document reference for the document concernedscore - The partially computed score
public double incorporateToken(java.lang.String token,
                               double count,
                               java.util.Map<DocumentReference,DoubleValue> retrievalHash)
token - The token in the query to incorporate.count - The count of this token in the query.retrievalHash - The hash table of retrieved DocumentReferences and current
                      scores.
public void processQueries()
public void presentRetrievals(HashMapVector queryVector,
                              Retrieval[] retrievals)
public boolean showRetrievals(Retrieval[] retrievals)
public void printRetrievals(Retrieval[] retrievals,
                            int start)
public static void main(java.lang.String[] args)
| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||