gov.nist.nlpir.irf.index
Class DualKeyContainer

java.lang.Object
  |
  +--gov.nist.nlpir.irf.index.DualKeyContainer

public class DualKeyContainer
extends java.lang.Object

This class is the "heart" of the Index. It mainly contains two hash tables of vectors. The first one, called valuesBySource, stores all indexing features found, classified by source. It will allow user to retrieve all the features of a given document, for example. The second one, called sourcesByValue, stores the different values whatever their source is. It will allow user to retrieve all the sources where a given feature appear.
Each entry in a table corresponds to a vector of features. For the first table, the vector contains all the features found for the source entry. In the second table, one vector contains all the sources in which the entry feature can be found.

An example of using the class is below

 setIndexingFeature = new DualKeyContainer(); 
 
 // Add an element to DualKeyContainer using two keys
 setIndexingFeature.put(source, key, value);
 // More precise example
 setIndexingFeature.put("doc1", "word1", "word1InDoc1");
 setIndexingFeature.put("doc1", "word2", "word2InDoc1");
 setIndexingFeature.put("doc2", "word1", "word1InDoc2");
 // We now have:
 // setIndexingFeatures.getSourceVector("word1") == {"word1InDoc1", "word1InDoc2"}
 // setIndexingFeatures.getValuesVector("doc1") == {"word1InDoc1", "word2InDoc1"}
 
 

Version:
$Revision: 1.2 $
Author:
This software was produced by NIST, an agency of the U.S. government, and by statute is not subject to copyright in the United States. Recipients of this software assume all responsibilities associated with its operation, modification and maintenance.
See Also:
Hashtable

Field Summary
private static int FEATURE_VECTOR_CAPACITY_INCREMENT
           
private static int FEATURE_VECTOR_INITIAL_CAPACITY
           
private static int SOURCE_VECTOR_CAPACITY_INCREMENT
           
private static int SOURCE_VECTOR_INITIAL_CAPACITY
           
private  IrfHashtable sourcesByValue
           
private  int sourcesNumber
           
private  int uniqueValuesNumber
           
private  IrfHashtable valuesBySource
           
private  int valuesNumber
           
 
Constructor Summary
DualKeyContainer()
          Initializes both tables.
 
Method Summary
 void clear()
          Clears both tables.
 java.util.Enumeration elements()
          Returns all the features stored.
 java.lang.Object getActualFeature(java.lang.Object feature)
          When a value is stored, it appears in a Vector corresponding to its feature (a key of a hashtable).
 java.lang.Object getActualSource(java.lang.Object source)
          When a value is stored, it appears in a Vector corresponding to its source (a key of a hashtable).
 ProxyFeatureList getAllValues()
          Returns a Vector containing all the values stored in the DualKeyContainer.
 ProxyFeatureList getFeatureVector(java.lang.Object source)
          Returns the vector of values associated to the given source.
 int getNumberOfSourcesFor(java.lang.Object feature)
          Gives the number of sources containing the given feature.
 int getNumberOfValuesFor(java.lang.Object source)
          Gives the number of features stored for the given source.
 java.util.Enumeration getSources()
          Returns the enumeration of Objects used as sources in this DualKeyContainer.
 int getSourcesNumber()
          Gives the number of sources in the DualKeyContainer.
 ProxyFeatureList getSourceVector(java.lang.Object feature)
          Returns the vector of sources that correspond to the given feature.
 int getUniqueValuesNumber()
          Returns the number of different values stored in the DualKeyContainer.
 java.util.Enumeration getValues()
          Returns the enumeration of Objects used as features for this DualKeyContainer.
 int getValuesNumber()
          Gives the total number of features stored in the table.
 boolean isEmpty()
           
 void put(java.lang.Object source, java.lang.Object feature, java.lang.Object value)
           
 void showStatistics(int depth, int maxLengthIfDepth3)
          Prints statistics about the DualKeyContainer, ie its size and the size of its elements.
private  void showStats(IrfHashtable table, int depth, int maxLengthIfDepth3)
          Prints statistics for ONE HVtable.
 java.lang.String toString()
          Creates massive string representation of the DualKeyContainer.
 int valuesBySourceSize()
          Gives the number of sources that appear in the DualKeyContainer.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

valuesBySource

private IrfHashtable valuesBySource

sourcesByValue

private IrfHashtable sourcesByValue

valuesNumber

private int valuesNumber

sourcesNumber

private int sourcesNumber

uniqueValuesNumber

private int uniqueValuesNumber

SOURCE_VECTOR_INITIAL_CAPACITY

private static int SOURCE_VECTOR_INITIAL_CAPACITY

SOURCE_VECTOR_CAPACITY_INCREMENT

private static int SOURCE_VECTOR_CAPACITY_INCREMENT

FEATURE_VECTOR_INITIAL_CAPACITY

private static int FEATURE_VECTOR_INITIAL_CAPACITY

FEATURE_VECTOR_CAPACITY_INCREMENT

private static int FEATURE_VECTOR_CAPACITY_INCREMENT
Constructor Detail

DualKeyContainer

public DualKeyContainer()
Initializes both tables.
Method Detail

valuesBySourceSize

public int valuesBySourceSize()
Gives the number of sources that appear in the DualKeyContainer.
Returns:
The number of keys in the valuesBySource table.

getValuesNumber

public int getValuesNumber()
Gives the total number of features stored in the table.
Returns:
The number of values in the table.

getNumberOfValuesFor

public int getNumberOfValuesFor(java.lang.Object source)
Gives the number of features stored for the given source.
Parameters:
source - the source for which the number of values will be computed.
Returns:
The number of values,
0 if the source doesn't appear.

getNumberOfSourcesFor

public int getNumberOfSourcesFor(java.lang.Object feature)
Gives the number of sources containing the given feature.
Parameters:
feature - the feature for which the number of sources will be computed.
Returns:
The number of sources,
0 if the feature doesn't appear.

isEmpty

public boolean isEmpty()
Returns:
True if no key table has been initialized.

elements

public java.util.Enumeration elements()
Returns all the features stored.
See Also:
put(java.lang.Object, java.lang.Object, java.lang.Object)

getAllValues

public ProxyFeatureList getAllValues()
Returns a Vector containing all the values stored in the DualKeyContainer.

getFeatureVector

public ProxyFeatureList getFeatureVector(java.lang.Object source)
Returns the vector of values associated to the given source. The Vector is empty if there is no value associated to source.
Parameters:
source - The source for which the values will be returned.
Returns:
A vector of values.

getSourceVector

public ProxyFeatureList getSourceVector(java.lang.Object feature)
Returns the vector of sources that correspond to the given feature. The Vector is empty if there is no value associated to source.
Parameters:
feature - The feature for which the sources will be returned.
Returns:
A vector of values.

put

public void put(java.lang.Object source,
                java.lang.Object feature,
                java.lang.Object value)
Parameters:
source - Where the value was found.
feature - The feature created with this value.
value - The object to be stored.

clear

public void clear()
Clears both tables.

toString

public java.lang.String toString()
Creates massive string representation of the DualKeyContainer.
Overrides:
toString in class java.lang.Object

showStatistics

public void showStatistics(int depth,
                           int maxLengthIfDepth3)
Prints statistics about the DualKeyContainer, ie its size and the size of its elements. Keys are also printed if their length is less than 15.
Parameters:
depth - 1, prints the size of the contained vectors for each hash table,
2, gives for each vector its key and the number of its elements,
3, gives the key of each vector and prints its content, each element truncated to 25 characters if longer,
4 is for a special 2, ie only the size of the vectors are printed one behind another.,br> Any other value will result in an empty display.

showStats

private void showStats(IrfHashtable table,
                       int depth,
                       int maxLengthIfDepth3)
Prints statistics for ONE HVtable.
Parameters:
table - The hashtable of vectors to be presented.
depth - Same as showStatistics() depth.

getSourcesNumber

public int getSourcesNumber()
Gives the number of sources in the DualKeyContainer.

getUniqueValuesNumber

public int getUniqueValuesNumber()
Returns the number of different values stored in the DualKeyContainer.

getSources

public java.util.Enumeration getSources()
Returns the enumeration of Objects used as sources in this DualKeyContainer. Caution: these are the actual keys, ie an object used as a source may not be returned if another object equal to the first one (considering hashCode() and equals()) had already been used as a source for this DualKeyContainer.

getValues

public java.util.Enumeration getValues()
Returns the enumeration of Objects used as features for this DualKeyContainer. Caution: these are the actual keys, ie an object used as a feature may not be returned if another object equal to the first one (considering hashCode() and equals()) had already been used as a feature for this DualKeyContainer. Thus, this object would be the one returned.

getActualSource

public java.lang.Object getActualSource(java.lang.Object source)
When a value is stored, it appears in a Vector corresponding to its source (a key of a hashtable). But the key in the hashtable may not be the object the value was stored with. This method gives this object from the object used as a source. This way, information about the Vector of sources (like its size, ...) can be stored in the key used to access this Vector.
See Also:
IrfHashtable.getActualKey(java.lang.Object)

getActualFeature

public java.lang.Object getActualFeature(java.lang.Object feature)
When a value is stored, it appears in a Vector corresponding to its feature (a key of a hashtable). But the key in the hashtable may not be the object the value was stored with. This method gives this object from the object used as a feature. Thus, information about the values stored for a feature can be stored in the key (the feature).
See Also:
IrfHashtable.getActualKey(java.lang.Object)