Top Description Constructors Methods
org.apache.commons.text.similarity

pack-priv final Class Counter

extends Object
Class Inheritance
Imports
java.util.HashMap, .Map, java.util.stream.Stream

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
https://docs.python.org/dev/library/collections.html#collections.Counter

Constructor Summary

AccessConstructor and Description
private
Counter()

No instance needed.

Method Summary

Modifier and TypeMethod and Description
public static Map<CharSequence, Integer>

Returns:

a map, where the elements are key, and the count the value.
of
(final CharSequence[]
array of tokens.
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.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Counterback to summary
private Counter()

No instance needed.

Method Detail

ofback to summary
public static Map<CharSequence, Integer> of(final 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:CharSequence[]

array of tokens.

Returns:Map<CharSequence, Integer>

a map, where the elements are key, and the count the value.