Class Counter

java.lang.Object
org.apache.commons.text.similarity.Counter

final class Counter extends Object
Java implementation of Python's collections Counter module.

It counts how many times each element provided occurred in an array and returns a map with the element as key and the count as value.

Since:
1.0
See Also:
  • Constructor Details

    • Counter

      private Counter()
      No instance needed.
  • Method Details

    • of

      public static Map<CharSequence, Integer> of(CharSequence[] tokens)
      Counts how many times each element provided occurred in an array and returns a map with the element as key and the count as value.
      Parameters:
      tokens - array of tokens.
      Returns:
      a map, where the elements are key, and the count the value.