static public function getFreq(array $ngrams, string $sep = ' ') : array
    {
        //getting the frequencies of the ngrams array and an array with no repetition
        $ngramsUnique = array_count_values($ngrams);

        //array to be the product of this function
        $ngramsFinal = array();

        //creates an array of tokens per ngram
        $ngramsArray = self::ngramsAsArray($sep, $ngrams);

        $ngramSize = count($ngramsArray[0]);

        $tokens_frequencies = self::readFreq($sep, $ngrams);
        $combo_frequencies  = self::readCombFreq($sep, $ngrams);

        //interate the array with no repeated ngrams
        foreach ($ngramsUnique as $ngramString => $ngramFrequency) {
            $ngramsFinal[$ngramString] = array($ngramFrequency); //putting into the final array an array of frequencies (first, the ngram frequency)

            $ngramArray = explode($sep, $ngramString); //getting an array of tokens of the ngram
            foreach ($ngramArray as $kToken => $token) { //iterating the array of tokens of the ngram
                $ngramsFinal[$ngramString][$kToken+1] = $tokens_frequencies[$token][$kToken]; //getting the frequency of the token

                if($ngramSize > 2) {
                    //getting the combined frequency of the tokens
                    for ($i = $kToken+1; $i < $ngramSize; $i++) {
                        $ngramsFinal[$ngramString][$ngramSize+$kToken+$i] = $combo_frequencies[$token.$sep.$ngramArray[$i]][$kToken][$i];
                    }
                }
            }

        }

        return $ngramsFinal;
    }
static public function getFreq(array $ngrams, string $sep = ' ') : array
    {
        //getting the frequencies of the ngrams array and an array with no repetition
        $ngramsUnique = array_count_values($ngrams);

        //array to be the product of this function
        $ngramsFinal = array();

        //creates an array of tokens per ngram
        $ngramsArray = self::ngramsAsArray($sep, $ngrams);

        $ngramSize = count($ngramsArray[0]);

        $tokens_frequencies = self::readFreq($sep, $ngrams);
        $combo_frequencies  = self::readCombFreq($sep, $ngrams);

        //interate the array with no repeated ngrams
        foreach ($ngramsUnique as $ngramString => $ngramFrequency) {
            $ngramsFinal[$ngramString] = array($ngramFrequency); //putting into the final array an array of frequencies (first, the ngram frequency)

            $ngramArray = explode($sep, $ngramString); //getting an array of tokens of the ngram
            foreach ($ngramArray as $kToken => $token) { //iterating the array of tokens of the ngram
                $ngramsFinal[$ngramString][$kToken+1] = $tokens_frequencies[$token][$kToken]; //getting the frequency of the token

                if($ngramSize > 2) {
                    //getting the combined frequency of the tokens
                    for ($i = $kToken+1; $i < $ngramSize; $i++) {
                        $ngramsFinal[$ngramString][$ngramSize+$kToken+$i] = $combo_frequencies[$token.$sep.$ngramArray[$i]][$kToken][$i];
                    }
                }
            }

        }

        return $ngramsFinal;
    }
static public function getFreq ( array $ ngrams , string $ sep = ' ' ) : array { //getting the frequencies of the ngrams array and an array with no repetition $ ngramsUnique = array_count_values ( $ ngrams ) ; //array to be the product of this function $ ngramsFinal = array ( ) ; //creates an array of tokens per ngram $ ngramsArray = self :: ngramsAsArray ( $ sep , $ ngrams ) ; $ ngramSize = count ( $ ngramsArray [ 0 ] ) ; $ tokens_frequencies = self :: readFreq ( $ sep , $ ngrams ) ; $ combo_frequencies = self :: readCombFreq ( $ sep , $ ngrams ) ; //interate the array with no repeated ngrams foreach ( $ ngramsUnique as $ ngramString => $ ngramFrequency ) { $ ngramsFinal [ $ ngramString ] = array ( $ ngramFrequency ) ; //putting into the final array an array of frequencies (first, the ngram frequency) $ ngramArray = explode ( $ sep , $ ngramString ) ; //getting an array of tokens of the ngram foreach ( $ ngramArray as $ kToken => $ token ) { //iterating the array of tokens of the ngram $ ngramsFinal [ $ ngramString ] [ $ kToken + 1 ] = $ tokens_frequencies [ $ token ] [ $ kToken ] ; //getting the frequency of the token if ( $ ngramSize > 2 ) { //getting the combined frequency of the tokens for ( $ i = $ kToken + 1 ; $ i < $ ngramSize ; $ i ++ ) { $ ngramsFinal [ $ ngramString ] [ $ ngramSize + $ kToken + $ i ] = $ combo_frequencies [ $ token . $ sep . $ ngramArray [ $ i ] ] [ $ kToken ] [ $ i ] ; } } } } return $ ngramsFinal ; }
Set the frenquecies of the ngrams and their respective tokens
@param array $ngrams
@param string $sep
@return array return an array of the ngrams with frequencies
Set the frenquecies of the ngrams and their respective tokens