static public function readFreq(string $sep, array $ngrams) : array
    {
        $ngrams = self::ngramsAsArray($sep, $ngrams);
        $frequencies = array();
        foreach ($ngrams as $ngram) {
            foreach ($ngram as $pos => $token) {
                if(isset($frequencies[$token][$pos])) { //checks if the token in that position was already counted
                    $frequencies[$token][$pos] += 1;
                } else {
                    $frequencies[$token][$pos] = 1;
                }
            }
        }
        return $frequencies;
    }
static public function readFreq(string $sep, array $ngrams) : array
    {
        $ngrams = self::ngramsAsArray($sep, $ngrams);
        $frequencies = array();
        foreach ($ngrams as $ngram) {
            foreach ($ngram as $pos => $token) {
                if(isset($frequencies[$token][$pos])) { //checks if the token in that position was already counted
                    $frequencies[$token][$pos] += 1;
                } else {
                    $frequencies[$token][$pos] = 1;
                }
            }
        }
        return $frequencies;
    }
static public function readFreq ( string $ sep , array $ ngrams ) : array { $ ngrams = self :: ngramsAsArray ( $ sep , $ ngrams ) ; $ frequencies = array ( ) ; foreach ( $ ngrams as $ ngram ) { foreach ( $ ngram as $ pos => $ token ) { if ( isset ( $ frequencies [ $ token ] [ $ pos ] ) ) { //checks if the token in that position was already counted $ frequencies [ $ token ] [ $ pos ] += 1 ; } else { $ frequencies [ $ token ] [ $ pos ] = 1 ; } } } return $ frequencies ; }
Counts the frequency of each token of an ngram array
@param string $sep
@param array $ngrams
@return array $frequencies Return an array of tokens with its frequencies by its positions
Counts the frequency of each token of an ngram array