Beispiel #1
0
 public function getTable()
 {
     $this->logger->info("Will print table...");
     while ($content = $this->inputStrategy->read()) {
         $content = $this->clean($content);
         $words = preg_split("/[\\s,]+/", $content);
         $words = array_filter($words);
         $counts = array_count_values($words);
         foreach ($counts as $word => $freq) {
             if (!isset($this->frequencyTable[$word])) {
                 $this->frequencyTable[$word] = $freq;
             } else {
                 $this->frequencyTable[$word] += $freq;
             }
         }
     }
     ksort($this->frequencyTable);
     return $this->frequencyTable;
 }
Beispiel #2
0
 public function close()
 {
     $this->logger->info("Closing resource.");
     fclose($this->resource);
     $this->resource = null;
 }