Beispiel #1
0
 /**
  * Return all the words accepted for index into an array.
  *
  * @param string $string The string to store.
  *
  * @return array Array with words.
  */
 private function _stringToArray($string)
 {
     // Clean up the string
     $string = Phprojekt_Converter_String::cleanupString($string);
     // Split the string into an array
     $tempArray = explode(" ", $string);
     // Strip off short or long words
     $tempArray = array_filter($tempArray, array("Phprojekt_Converter_String", "stripLengthWords"));
     // Strip off stop words
     if (!empty($this->_stopWords)) {
         $tempArray = array_filter($tempArray, array($this, "_stripStops"));
     }
     // Remove duplicate entries
     $tempArray = array_unique($tempArray);
     return $tempArray;
 }
Beispiel #2
0
 /**
  * Process the data of the item into the search words.
  * The return array have per word, the count of ocurrences,
  * and the pair moduleId-itemId where is it.
  *
  * @param string  $string   All the string data of the item.
  * @param integer $moduleId Module ID
  * @param integer $itemId   Item ID
  *
  * @return array Array with words.
  */
 private function _addSearchWords($string, $moduleId, $itemId)
 {
     // Clean up the string
     $string = Phprojekt_Converter_String::cleanupString($string);
     // Split the string into an array
     $tempArray = explode(" ", $string);
     // Strip off short or long words
     $tempArray = array_filter($tempArray, array("Phprojekt_Converter_String", "stripLengthWords"));
     // Strip off stop words
     if (!empty($this->_stopWords)) {
         $tempArray = array_filter($tempArray, array($this, "_stripStops"));
     }
     // Remove duplicate entries
     $tempArray = array_unique($tempArray);
     foreach ($tempArray as $word) {
         if (!isset($this->_searchWord[$word])) {
             $this->_searchWord[$word] = array('count' => 0, 'pair' => array());
         }
         $this->_searchWord[$word]['count']++;
         $this->_searchWord[$word]['pair'][] = array($itemId, $moduleId);
     }
     return $tempArray;
 }
Beispiel #3
0
 /**
  * Return all the words accepted for index into an array.
  *
  * @param string $string The string to store.
  *
  * @return array Array of words.
  */
 private function _stringToArray($string)
 {
     // Clean up the string
     $string = Phprojekt_Converter_String::cleanupString($string);
     // Split the string into an array
     $tempArray = explode(" ", $string);
     // Strip off short or long words
     $tempArray = array_filter($tempArray, array("Phprojekt_Converter_String", "stripLengthWords"));
     return array_values($tempArray);
 }