Frequency Functions
A pair of functions to efficiently calculate and retrieve the frequency of words and characters in a given text, providing useful insights for text analysis and processing tasks.
Table of Contents
wordFrequency
Calculates the frequency of words in a given input string and returns the top N most frequent words.
Parameters
inputString
(String): The input text for calculating word frequencies.limit
(Number, optional): The maximum number of top frequent words to return. Defaults to 100.
Returns
Map: A sorted map containing the top N most frequent words with their corresponding frequencies.
Example
charFrequency
Calculates the frequency of characters in a given input string and returns them sorted by frequency.
Parameters
inputString
(String): The input text for calculating character frequencies.
Returns
Map: A sorted map containing characters with their corresponding frequencies.
Example
Last updated