Compute the Pointwise Mutual Information on the collocations
@return array
770584
public function getCollocationsByPmi()
    {
        $nGramFreqDist = freq_dist(ngrams($this->tokens, $this->nGramSize));
        $unigramsFreqDist = freq_dist($this->tokens);
        
        $dataSet = [];
        foreach($nGramFreqDist->getKeys() as $nGramToken)
        {            
            $tokens = explode(" ", $nGramToken);
            $tally = 1;
            foreach($tokens as $unigramToken)
            {      
                $tally *= $unigramsFreqDist->getKeyValuesByWeight()[$unigramToken];
            }        
            
            // get probabilities of all tokens
            $dataSet[$nGramToken] = log($nGramFreqDist->getKeyValuesByWeight()[$nGramToken] / $tally );            
        }
        arsort($dataSet);
        return $dataSet;
    }
577727
private function getAllInfo()
    {
        $data = [];
        $recommendation_area = $this->_parser->find('.borderDark', 0);

        $data['source'] = $this->getSource($recommendation_area);
        $data['recommendation'] = $this->getRecom($recommendation_area);

        return $data;
    }
369194
public function getColumnObjectsMapping()
    {
        $mapping = [];
        $foreignTable = $this->getForeignTable();
        for ($i = 0, $size = count($this->localColumns); $i < $size; $i++) {
            $mapping[] = [
                'local'   => $this->parentTable->getColumn($this->localColumns[$i]),
                'foreign' => $foreignTable->getColumn($this->foreignColumns[$i]),
                'value' => $this->localValues[$i],
            ];
        }

        return $mapping;
    }
91258
private function getAnnotations()
    {
        $tokens = array();

        while (null !== $this->lexer->lookahead) {

            // start at the @ symbol
            if (DocLexer::T_AT !== $this->lexer->lookahead['type']) {
                $this->lexer->moveNext();

                continue;
            }

            // something about being preceded by a non-catchable pattern
            $position = $this->lexer->token['position']
                + strlen($this->lexer->token['value']);

            if ((null !== $this->lexer->token)
                && ($this->lexer->lookahead['position'] === $position)) {
                $this->lexer->moveNext();

                continue;
            }

            // make sure we get a valid annotation name
            if ((null === ($glimpse = $this->lexer->glimpse()))
                || ((DocLexer::T_NAMESPACE_SEPARATOR !== $glimpse['type'])
                    && !in_array($glimpse['type'], self::$classIdentifiers))) {
                $this->lexer->moveNext();

                continue;
            }

            // find them all and merge them to the list
            if (null !== ($token = $this->getAnnotation())) {
                $tokens = array_merge($tokens, $token);
            }
        }

        return $tokens;
    }
898749
public function resolve(): array
    {
        $modelRelationFetcher = $this->getRelationFetcher();

        if ($this->first !== null) {
            $modelRelationFetcher->loadRelationsForPage($this->first, $this->page);
        } else {
            $modelRelationFetcher->loadRelations();
        }

        return $modelRelationFetcher->getRelationDictionary($this->relationName);
    }
1012760
protected function getCommonMethods()/*# : array */
    {
        // di.common node
        $commNode = $this->getResolver()->getSectionId('', 'common');

        return $this->mergeMethods(
            $this->getResolver()->get($commNode)
        );
    }
948033
private function getAssociations() : array
    {
        $result = [];
        foreach ($this->getQueryFields() as $field) {
            $association = $this->getAssociationByField($field);
            if (null === $association) {
                continue;
            }

            if (array_key_exists($association->getName(), $result)) {
                continue;
            }

            $result[$association->getName()] = $association;
        }

        return $result;
    }
1199941
public function getRegexes() : array
    {
        return [
            $this->getPhoneNumbers(),                        
            $this->getUrls(),            
            $this->getEmoticons(),            
            $this->getHashTags(),           
            $this->getAsciiArrows(),            
            $this->getUsernames(),
            $this->getHashTags(),            
            $this->getWordsWith(),
            $this->getNumbers(),            
            $this->getWordsWithout(),            
            $this->getEllipsisDots(),            
            $this->getEverythingElse()
        ];
    }
707080
public function featureImportances() : array
    {
        if (!$this->forest or !$this->featureCount) {
            return [];
        }

        $importances = array_fill(0, $this->featureCount, 0.);

        foreach ($this->forest as $tree) {
            foreach ($tree->featureImportances() as $column => $value) {
                $importances[$column] += $value;
            }
        }

        $k = count($this->forest);

        foreach ($importances as &$importance) {
            $importance /= $k;
        }

        return $importances;
    }
621895
public function getMatchers(): array
    {
        return [
            'verifyNative' => function (DataType $subject, $value) {

                $isClass = (false === $subject->isClass());
                $isClassOrInterface = (false === $subject->isClassOrInterface() || $value === Type::COUNTABLE);
                $isInterface = (false === $subject->isInterface() || $value === Type::COUNTABLE);
                $isNative = (true === $subject->isNative());
                $isTrait = (false === $subject->isTrait());
                $isValid = (true === $subject->isValid());
                $isChildOf = (false === $subject->isChildOf($value));
                $isTypeOf = (true === $subject->isTypeOf($value));


                return $isClass && $isClassOrInterface && $isInterface && $isNative && $isTrait && $isValid && $isChildOf && $isTypeOf;
            },
            'verifyInterface' => function (DataType $subject, $value) {

                $isClass = (false === $subject->isClass());
                $isClassOrInterface = (true === $subject->isClassOrInterface());
                $isInterface = (true === $subject->isInterface());
                $isNative = (false === $subject->isNative());
                $isTrait = (false === $subject->isTrait());
                $isValid = (true === $subject->isValid());
                $isChildOf = (false === $subject->isChildOf($value));
                $isTypeOf = (true === $subject->isTypeOf($value));


                return $isClass && $isClassOrInterface && $isInterface && $isNative && $isTrait && $isValid && $isChildOf && $isTypeOf;
            },
            'verifyClass' => function (DataType $subject, $value) {

                $isClass = (true === $subject->isClass());
                $isClassOrInterface = (true === $subject->isClassOrInterface());
                $isInterface = (false === $subject->isInterface());
                $isNative = (false === $subject->isNative());
                $isTrait = (false === $subject->isTrait());
                $isValid = (true === $subject->isValid());
                $isChildOf = (true === $subject->isChildOf($value));
                $isTypeOf = (true === $subject->isTypeOf($value));

                return $isClass && $isClassOrInterface && $isInterface && $isNative && $isTrait && $isValid && $isChildOf && $isTypeOf;
            },
            'verifyTrait' => function (DataType $subject, $value) {

                $isClass = (false === $subject->isClass());
                $isClassOrInterface = (false === $subject->isClassOrInterface());
                $isInterface = (false === $subject->isInterface());
                $isNative = (false === $subject->isNative());
                $isTrait = (true === $subject->isTrait());
                $isValid = (true === $subject->isValid());
                $isChildOf = (false === $subject->isChildOf($value));
                $isTypeOf = (true === $subject->isTypeOf($value));

                return $isClass  && $isClassOrInterface && $isInterface && $isNative && $isTrait && $isValid && $isChildOf && $isTypeOf;
            }
        ];
    }
84989
public function getOldRelations()
    {
        $oldRelations = [];
        foreach ($this->_relations as $relationName) {
            $oldRelations[$relationName] = $this->getOldRelation($relationName);
        }
        return $oldRelations;
    }
421721
public function gaussianElimination() : array
    {
        $minDim = min($this->shape());

        $b = $this->a;

        $swaps = 0;

        for ($k = 0; $k < $minDim; $k++) {
            $index = $k;

            for ($i = $k; $i < $this->m; $i++) {
                if (abs($b[$i][$k]) > abs($b[$index][$k])) {
                    $index = $i;
                }
            }

            if ($b[$index][$k] == 0) {
                throw new RuntimeException('Cannot compute row echelon form'
                    . ' of a singular matrix.');
            }

            if ($k !== $index) {
                $temp = $b[$k];

                $b[$k] = $b[$index];
                $b[$index] = $temp;

                $swaps++;
            }

            $diag = $b[$k][$k];

            for ($i = $k + 1; $i < $this->m; $i++) {
                $scale = $diag != 0 ? $b[$i][$k] / $diag : 1;
                
                for ($j = $k + 1; $j < $this->n; $j++) {
                    $b[$i][$j] -= $scale * $b[$k][$j];
                }
                
                $b[$i][$k] = 0;
            }
        }

        $b = self::quick($b);

        return [$b, $swaps];
    }
606522
public function getSimilarRecommListIds()
    {
        if ($this->_aSimilarRecommListIds === null) {
            $this->_aSimilarRecommListIds = false;

            $aWishProdList = $this->getWishProductList();
            if (is_array($aWishProdList) && ($oSimilarProd = current($aWishProdList))) {
                $this->_aSimilarRecommListIds = [$oSimilarProd->getId()];
            }
        }

        return $this->_aSimilarRecommListIds;
    }
194355
public function ref() : array
    {
        try {
            $ref = $this->gaussianElimination();
        } catch (RuntimeException $e) {
            $ref = $this->rowReductionMethod();
        }

        return $ref;
    }
383169
public static function asArray()
    {
        return array(
            'DEF' => self::DEF,
            'RECT' => self::RECT,
            'CIRCLE' => self::CIRCLE,
            'POLY' => self::POLY,
            'ELLIPSE' => self::ELLIPSE
        );
    }
597315
protected function determineRelations()
    {
        if (count($this->parameters)) {
            return $this->parameters;
        }

        if ( ! ($info = $this->getModelInformation())) {
            return [];
        }

        return array_pluck($info->relations, 'method');
    }
96491
protected function getRawRelations()
    {
        if (is_null($this->relations)) {
            $this->relations = DB::select(
                'SELECT DISTINCT
                 u.referenced_column_name AS `localKey`
                ,u.column_name AS `foreignKey`
                ,r.table_name AS `foreignTable`
                ,CASE WHEN u.TABLE_NAME = r.referenced_table_name THEN 1 ELSE 0 END selfReferences
                FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS r
                INNER JOIN information_schema.key_column_usage AS u ON u.CONSTRAINT_NAME = r.CONSTRAINT_NAME
                                                                   AND u.table_schema = r.constraint_schema
                                                                   AND u.table_name = r.table_name
                WHERE u.referenced_table_name = ? AND u.constraint_schema = ?;',
                [$this->tableName, $this->databaseName]
            );
        }

        return $this->relations;
    }