Exemplo n.º 1
0
 function createSegments()
 {
     $this->radius = $this->radius ? $this->radius : 4;
     $n_segments = 0;
     for ($i = 0; $i < count($this->text); $i++) {
         foreach ($this->needles as $needle) {
             if ($this->match($needle, $this->text[$i])) {
                 $n_segments++;
             }
         }
     }
     if ($n_segments < 4) {
         $this->addRadius(3);
     } elseif ($n_segments > 6) {
     }
     for ($i = 0; $i < count($this->text); $i++) {
         //debug(array('word',$this->removeNoneAlpha($this->text[$i])));
         foreach ($this->needles as $needle) {
             if ($this->match($needle, $this->text[$i])) {
                 //debug("match!");
                 $start = $i - $this->radius > 0 ? $i - $this->radius : 0;
                 $end = $i + $this->radius < count($this->text) ? $i + $this->radius : count($this->text) - 1;
                 $segment = $this->array_segment($this->text, $start, $end);
                 $segment = new Segment($segment, $start, $end);
                 $segment->addNeedle($i);
                 $this->segments[] = $segment;
             }
         }
     }
 }