org.terrier.structures
Class Lexicon<KEY>

java.lang.Object
  extended by org.terrier.structures.Lexicon<KEY>
Type Parameters:
KEY - the type of the key. Usually String to denote a term.
All Implemented Interfaces:
java.io.Closeable, java.lang.Iterable<java.util.Map.Entry<KEY,LexiconEntry>>
Direct Known Subclasses:
MapLexicon

public abstract class Lexicon<KEY>
extends java.lang.Object
implements java.io.Closeable, java.lang.Iterable<java.util.Map.Entry<KEY,LexiconEntry>>

Abstract Lexicon implementation. The Lexicon class typically represents the list of terms (dictionary) in the index, together with their statistics (see EntryStatistics) and the pointer (Pointer) to the offset of that term's postings in the InvertedIndex. The EntryStatistics and Pointer are combined in a single LexiconEntry object.

Since:
1.0.0
Author:
Craig Macdonald
See Also:
EntryStatistics, Pointer

Constructor Summary
Lexicon()
           
 
Method Summary
abstract  java.util.Map.Entry<KEY,LexiconEntry> getIthLexiconEntry(int index)
          Get the term and LexiconEntry (contains statistics and a pointer) for the entry in the lexicon with the specified index.
abstract  java.util.Map.Entry<KEY,LexiconEntry> getLexiconEntry(int termid)
          Get the term and LexiconEntry (contains statistics and a pointer) for a given term id.
abstract  LexiconEntry getLexiconEntry(KEY term)
          Get the LexiconEntry (contains statistics and a pointer) for the given term.
abstract  int numberOfEntries()
          Return the number of entries in the lexicon
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.io.Closeable
close
 
Methods inherited from interface java.lang.Iterable
iterator
 

Constructor Detail

Lexicon

public Lexicon()
Method Detail

numberOfEntries

public abstract int numberOfEntries()
Return the number of entries in the lexicon


getLexiconEntry

public abstract LexiconEntry getLexiconEntry(KEY term)
Get the LexiconEntry (contains statistics and a pointer) for the given term. Returns null if the term is not found in the lexicon.

Parameters:
term - key to lookup the lexicon with
Returns:
LexiconEntry for that term, or null if not found

getLexiconEntry

public abstract java.util.Map.Entry<KEY,LexiconEntry> getLexiconEntry(int termid)
Get the term and LexiconEntry (contains statistics and a pointer) for a given term id. Throws NoSuchElementException is the termid is not found.

Parameters:
termid - the term id to lookup in the lexicon
Returns:
Map.Entry tuple containing the term and the LexiconEntry

getIthLexiconEntry

public abstract java.util.Map.Entry<KEY,LexiconEntry> getIthLexiconEntry(int index)
Get the term and LexiconEntry (contains statistics and a pointer) for the entry in the lexicon with the specified index. Throws NoSuchElementException is the termid is not found.

Parameters:
index - the entry number to lookup in the lexicon
Returns:
Map.Entry tuple containing the term and the LexiconEntry


Terrier 3.5. Copyright © 2004-2011 University of Glasgow