protected function countTrainingSet(FeatureFactoryInterface $ff, TrainingSet $tset, array &$termcount_per_class, array &$termcount, array &$ndocs_per_class, array &$voc, &$ndocs)
    {
        foreach ($tset as $tdoc) {
            $ndocs++;
            $c = $tdoc->getClass();
            $ndocs_per_class[$c]++;
            $features = $ff->getFeatureArray($c,$tdoc);
            if (is_int(key($features)))
                $features = array_count_values($features);
            foreach ($features as $f=>$fcnt) {
                if (!isset($voc[$f]))
                    $voc[$f] = 0;

                $termcount_per_class[$c]+=$fcnt;
                if (isset($termcount[$c][$f]))
                    $termcount[$c][$f]+=$fcnt;
                else
                    $termcount[$c][$f] = $fcnt;
            }
        }
    }
protected function countTrainingSet(FeatureFactoryInterface $ff, TrainingSet $tset, array &$termcount_per_class, array &$termcount, array &$ndocs_per_class, array &$voc, &$ndocs)
    {
        foreach ($tset as $tdoc) {
            $ndocs++;
            $c = $tdoc->getClass();
            $ndocs_per_class[$c]++;
            $features = $ff->getFeatureArray($c,$tdoc);
            if (is_int(key($features)))
                $features = array_count_values($features);
            foreach ($features as $f=>$fcnt) {
                if (!isset($voc[$f]))
                    $voc[$f] = 0;

                $termcount_per_class[$c]+=$fcnt;
                if (isset($termcount[$c][$f]))
                    $termcount[$c][$f]+=$fcnt;
                else
                    $termcount[$c][$f] = $fcnt;
            }
        }
    }
protected function countTrainingSet ( FeatureFactoryInterface $ ff , TrainingSet $ tset , array & $ termcount_per_class , array & $ termcount , array & $ ndocs_per_class , array & $ voc , & $ ndocs ) { foreach ( $ tset as $ tdoc ) { $ ndocs ++ ; $ c = $ tdoc -> getClass ( ) ; $ ndocs_per_class [ $ c ] ++ ; $ features = $ ff -> getFeatureArray ( $ c , $ tdoc ) ; if ( is_int ( key ( $ features ) ) ) $ features = array_count_values ( $ features ) ; foreach ( $ features as $ f => $ fcnt ) { if ( ! isset ( $ voc [ $ f ] ) ) $ voc [ $ f ] = 0 ; $ termcount_per_class [ $ c ] += $ fcnt ; if ( isset ( $ termcount [ $ c ] [ $ f ] ) ) $ termcount [ $ c ] [ $ f ] += $ fcnt ; else $ termcount [ $ c ] [ $ f ] = $ fcnt ; } } }
Count all the features for each document. All parameters are passed
by reference and they are filled in this function. Useful for not
making copies of big arrays.

@param  FeatureFactoryInterface $ff                  A feature factory to create the features for each document in the set
@param  TrainingSet             $tset                The training set (collection of labeled documents)
@param  array                   $termcount_per_class The count of occurences of each feature in each class
@param  array                   $termcount           The total count of occurences of each term
@param  array                   $ndocs_per_class     The total number of documents per class
@param  array                   $voc                 A set of the found features
@param  integer                 $ndocs               The number of documents
@return void
Count all the features for each document . All parameters are passed by reference and they are filled in this function . Useful for not making copies of big arrays .