it.unimi.di.mg4j.index.cluster
Class ContiguousLexicalStrategy

java.lang.Object
  extended by it.unimi.di.mg4j.index.cluster.ContiguousLexicalStrategy
All Implemented Interfaces:
ClusteringStrategy, LexicalClusteringStrategy, LexicalPartitioningStrategy, PartitioningStrategy, Serializable

public class ContiguousLexicalStrategy
extends Object
implements LexicalPartitioningStrategy, LexicalClusteringStrategy

A lexical strategy that partitions terms into contiguous segments.

To partition terms in contiguous segments, you must provide an array of cutpoints, which define each segment of terms. More precisely, given cutpoints c0,c2,…,ck, terms will be partitioned into k local indices containing the terms numbered from c0 (included) to c1 (excluded), from c1 (included) to c2 and so on. Note that necessarily c0=0 and ck=T, where T is the number of terms in the global index.

To make mapping of terms (as opposed to term numbers) possible, you must also provide a parallel array of character sequences that contain the terms corresponding to the terms numbers c0,c2,…,ck. The content of the last element of the array should be null.

The properties() method provides two properties, termfrom and termto, that contain the first (included) and last (excluded) term in the local index, and two analogous properties termnumberfrom and termnumberto.

Author:
Alessandro Arrabito, Sebastiano Vigna
See Also:
Serialized Form

Constructor Summary
ContiguousLexicalStrategy(int[] cutPoint, CharSequence[] cutPointTerm)
          Creates a new contiguous lexical strategy with the given cutpoints.
 
Method Summary
 int globalNumber(int localIndex, int localNumber)
          Returns the global term number given a local index and a local term number (optional operation).
 int localIndex(CharSequence term)
          Returns the index to which a given term is be mapped by this strategy.
 int localIndex(int globalNumber)
          Returns the index to which a given term number is mapped by this strategy.
 int localNumber(int globalNumber)
          Returns the local term number given a global term number.
 int numberOfLocalIndices()
          Returns the number of local indices created by this strategy.
 Properties[] properties()
          Returns an array of properties, one for each local index, that specify additional information about local indices.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ContiguousLexicalStrategy

public ContiguousLexicalStrategy(int[] cutPoint,
                                 CharSequence[] cutPointTerm)
Creates a new contiguous lexical strategy with the given cutpoints.

Parameters:
cutPoint - an array of cutpoints (see the class description}.
cutPointTerm - a parallel array of cutpoints terms; the last element must be null.
Method Detail

numberOfLocalIndices

public int numberOfLocalIndices()
Description copied from interface: PartitioningStrategy
Returns the number of local indices created by this strategy.

Specified by:
numberOfLocalIndices in interface ClusteringStrategy
Specified by:
numberOfLocalIndices in interface PartitioningStrategy
Returns:
the number of local indices created by this strategy.

localIndex

public int localIndex(int globalNumber)
Description copied from interface: LexicalPartitioningStrategy
Returns the index to which a given term number is mapped by this strategy.

Specified by:
localIndex in interface LexicalPartitioningStrategy
Parameters:
globalNumber - the term global number.
Returns:
the corresponding local index, or -1 if the term should be removed from the partitioned index.

localIndex

public int localIndex(CharSequence term)
Description copied from interface: LexicalClusteringStrategy
Returns the index to which a given term is be mapped by this strategy.

Specified by:
localIndex in interface LexicalClusteringStrategy
Parameters:
term - a term.
Returns:
the corresponding local index, or -1 if no index contains the term.

globalNumber

public int globalNumber(int localIndex,
                        int localNumber)
Description copied from interface: LexicalClusteringStrategy
Returns the global term number given a local index and a local term number (optional operation).

This operation is not, in general, necessary for a LexicalCluster to work, as no action on a local index returns local numbers. It is defined here mainly for completeness and for debugging purposes (in case it is implemented).

Specified by:
globalNumber in interface LexicalClusteringStrategy
Parameters:
localIndex - the local index.
localNumber - the local term number.
Returns:
the global term number.

localNumber

public int localNumber(int globalNumber)
Description copied from interface: LexicalPartitioningStrategy
Returns the local term number given a global term number.

Specified by:
localNumber in interface LexicalPartitioningStrategy
Parameters:
globalNumber - a global term number.
Returns:
the corresponding local term number, or -1 if the term should be removed from the partitioned index.

properties

public Properties[] properties()
Description copied from interface: PartitioningStrategy
Returns an array of properties, one for each local index, that specify additional information about local indices.

Specified by:
properties in interface PartitioningStrategy
Returns:
an array of properties, one for each local index; any element can be null (in that case, the set of properties is assumed to be empty).

toString

public String toString()
Overrides:
toString in class Object