Textractor API textractor-720 (20091120123250)

textractor.mg4j
Class HashTermMap

java.lang.Object
  extended by textractor.mg4j.HashTermMap
All Implemented Interfaces:
TermMap, Serializable

public final class HashTermMap
extends Object
implements TermMap, Serializable

A term map implementation that should allow fast retrieval. The speed comes at the price of a large amount of memory.

See Also:
Serialized Form

Field Summary
static long serialVersionUID
          Used during deserialization to verify that objects are compatible.
 
Constructor Summary
HashTermMap()
           
HashTermMap(String termFilename)
          Construct and populate this term map.
HashTermMap(TermIterator termIterator, int startingIndex)
          Construct and populate this term map.
 
Method Summary
 int getIndex(CharSequence term)
          Deprecated. As of MG4J 1.2, replaced by getNumber(CharSequence).
 int getNumber(CharSequence term)
          Returns the ordinal number corresponding to the given term, or possibly (but not necessarily) -1 if the term was not indexed.
 CharSequence getTerm(int index)
          Returns the term corresponding to the given index (optional operation).
 MutableString getTerm(int i, MutableString mutableString)
           
 boolean hasTerms()
          Returns true if this prefix map supports term retrieval.
 int size()
          Returns the number of terms in this term map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

public static final long serialVersionUID
Used during deserialization to verify that objects are compatible.

See Also:
Constant Field Values
Constructor Detail

HashTermMap

public HashTermMap(String termFilename)
            throws IOException
Construct and populate this term map. Each term in the file provided as input is entered in the map with an index that reflects the order of the term in the input file.

Parameters:
termFilename - Name of the file that contains the terms to initialize this map with.
Throws:
IOException

HashTermMap

public HashTermMap(TermIterator termIterator,
                   int startingIndex)
            throws IOException
Construct and populate this term map. Each term in the termIterator entered in the map with an index that reflects the order of the term in the iterator.

Parameters:
termIterator - Iterator over the termIterator that must be added to this term map.
Throws:
IOException

HashTermMap

public HashTermMap()
Method Detail

getIndex

@Deprecated
public int getIndex(CharSequence term)
Deprecated. As of MG4J 1.2, replaced by getNumber(CharSequence).

Returns the ordinal number corresponding to the given term, or possibly (but not necessarily) -1 if the term was not indexed.

Parameters:
term - a term.
Returns:
its ordinal number, or possibly (but not necessarily) -1 if the term was not indexed.

getNumber

public int getNumber(CharSequence term)
Returns the ordinal number corresponding to the given term, or possibly (but not necessarily) -1 if the term was not indexed.

Specified by:
getNumber in interface TermMap
Parameters:
term - a term.
Returns:
its ordinal number, or possibly (but not necessarily) -1 if the term was not indexed.

hasTerms

public boolean hasTerms()
Returns true if this prefix map supports term retrieval.

Specified by:
hasTerms in interface TermMap
Returns:
true if this prefix map supports term retrieval.

getTerm

public CharSequence getTerm(int index)
Returns the term corresponding to the given index (optional operation).

Specified by:
getTerm in interface TermMap
Parameters:
index - a term index.
Returns:
the corresponding term, or possibly (but not necessarily) null if the term was not indexed.

getTerm

public MutableString getTerm(int i,
                             MutableString mutableString)
Specified by:
getTerm in interface TermMap

size

public int size()
Returns the number of terms in this term map.

Specified by:
size in interface TermMap
Returns:
the number of terms in this term map.

Textractor API textractor-720 (20091120123250)

Copyright © 2003-2008 Institute for Computational Biomedicine, All Rights Reserved.