PHP Class TextAnalysis\Analysis\FreqDist

Author: yooper
Show file Open project: yooper/php-text-analysis Class Usage Examples

Protected Properties

Property Type Description
$keyValues array An associative array that holds all the frequencies per token
$keysByWeight array Caches a copy of keys by weight
$totalTokens integer The total number of tokens originally passed into FreqDist

Public Methods

Method Description
__construct ( array $tokens ) This sorts the token meta data collection right away so use frequency distribution data can be extracted.
__destruct ( )
getHapaxes ( ) : array Returns an array of tokens that occurred once
getKeyValuesByFrequency ( ) : array Return an array with key frequency pairs
getKeyValuesByWeight ( ) : array Return an array with key weight pairs
getKeys ( ) : array Return the sorted keys by frequency desc
getTotalTokens ( ) : integer Get the total number of tokens in this tokensDocument
getTotalUniqueTokens ( ) : integer Return get the total number of unique tokens
getValues ( ) : array Return the sorted values by frequency desc
getWeightPerToken ( ) : float Return the weight of a single token

Protected Methods

Method Description
preCompute ( array $tokens ) Internal function for summarizing all the data into a key value store

Method Details

__construct() public method

This sorts the token meta data collection right away so use frequency distribution data can be extracted.
public __construct ( array $tokens )
$tokens array

__destruct() public method

public __destruct ( )

getHapaxes() public method

Returns an array of tokens that occurred once
public getHapaxes ( ) : array
return array

getKeyValuesByFrequency() public method

Return an array with key frequency pairs
public getKeyValuesByFrequency ( ) : array
return array

getKeyValuesByWeight() public method

Return an array with key weight pairs
public getKeyValuesByWeight ( ) : array
return array

getKeys() public method

Return the sorted keys by frequency desc
public getKeys ( ) : array
return array

getTotalTokens() public method

Get the total number of tokens in this tokensDocument
public getTotalTokens ( ) : integer
return integer

getTotalUniqueTokens() public method

Return get the total number of unique tokens
public getTotalUniqueTokens ( ) : integer
return integer

getValues() public method

Return the sorted values by frequency desc
public getValues ( ) : array
return array

getWeightPerToken() public method

Return the weight of a single token
public getWeightPerToken ( ) : float
return float

preCompute() protected method

Internal function for summarizing all the data into a key value store
protected preCompute ( array $tokens )
$tokens array The set of tokens passed into the constructor

Property Details

$keyValues protected property

An associative array that holds all the frequencies per token
protected array $keyValues
return array

$keysByWeight protected property

Caches a copy of keys by weight
protected array $keysByWeight
return array

$totalTokens protected property

The total number of tokens originally passed into FreqDist
protected int $totalTokens
return integer