Class SparseArray

java.lang.Object
org.carrot2.text.preprocessing.SparseArray

public final class SparseArray
extends Object
Sparse array encoding utilities. Sparse means an index and its value are kept in an array as a pair.
  • Constructor Summary

    Constructors 
    Constructor Description
    SparseArray()  
  • Method Summary

    Modifier and Type Method Description
    static int countUnique​(int[] buffer, int fromIndex, int toIndex)
    Count unique values in the sorted array.
    static int[] mergeSparseArrays​(Iterable<int[]> source)
    Merge data from one or more sparse arrays.
    static String sparseToString​(int[] intIntArray)
    Convert an int-int compact mapping array to a string.
    static int[] toSparseEncoding​(com.carrotsearch.hppc.IntStack documents)
    Convert a list of documents to sparse document-count representation.
    static int[] toSparseEncodingByHash​(com.carrotsearch.hppc.IntStack documents)
    Convert to sparse encoding using a hash map.
    static int[] toSparseEncodingBySort​(com.carrotsearch.hppc.IntStack documents)
    Convert to sparse encoding using sorting and counting.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • toSparseEncoding

      public static int[] toSparseEncoding​(com.carrotsearch.hppc.IntStack documents)
      Convert a list of documents to sparse document-count representation.
    • toSparseEncodingByHash

      public static int[] toSparseEncodingByHash​(com.carrotsearch.hppc.IntStack documents)
      Convert to sparse encoding using a hash map.
    • toSparseEncodingBySort

      public static int[] toSparseEncodingBySort​(com.carrotsearch.hppc.IntStack documents)
      Convert to sparse encoding using sorting and counting.
    • countUnique

      public static int countUnique​(int[] buffer, int fromIndex, int toIndex)
      Count unique values in the sorted array.
    • mergeSparseArrays

      public static int[] mergeSparseArrays​(Iterable<int[]> source)
      Merge data from one or more sparse arrays.
    • sparseToString

      public static String sparseToString​(int[] intIntArray)
      Convert an int-int compact mapping array to a string.