Skip to content

PHP Frequency Distribution

yooper edited this page Jun 30, 2016 · 3 revisions

Frequency Distributions with PHP Text Analysis

The frequency distribution is a great way to find out how frequently or in-frequently specific words are used in a body of text. The FreqDist class expects the tokens to be normalized prior to object instantiation.

$tokenizer = new GeneralTokenizer()
$tokens = $tokenizer->tokenize("time flies like an arrow and an arrow flies like time");
$freqDist = new FreqDist($tokens);
$freqDist->getHapaxes(); //Get the Hapaxes
$freqDist->getTotalTokens()
$freqDist->getTotalUniqueTokens();
Clone this wiki locally