Class 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

      Constructors 
      Constructor Description
      ContiguousLexicalStrategy​(int[] cutPoint, CharSequence[] cutPointTerm)
      Creates a new contiguous lexical strategy with the given cutpoints.
    • Method Summary

      Modifier and Type Method Description
      long globalNumber​(int localIndex, long localNumber)
      Returns the global term number given a local index and a local term number (optional operation).
      int localIndex​(long globalNumber)
      Returns the index to which a given term number is mapped by this strategy.
      int localIndex​(CharSequence term)
      Returns the index to which a given term is be mapped by this strategy.
      long localNumber​(long 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()  
    • 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

      • localIndex

        public int localIndex​(long 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 long globalNumber​(int localIndex,
                                 long 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 long localNumber​(long 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).