TextAnalysis\Indexes\InvertedIndex::getDocumentIdsByTerm PHP Метод

getDocumentIdsByTerm() публичный Метод

public getDocumentIdsByTerm ( string $term ) : array
$term string
Результат array
    public function getDocumentIdsByTerm($term)
    {
        if (!isset($this->index[$term])) {
            return [];
        }
        return $this->index[$term][self::POSTINGS];
    }

Usage Example

Пример #1
0
 /**
  * @param InvertedIndex $invertedIndex
  * @return arrray
  */
 public function queryIndex(InvertedIndex $invertedIndex)
 {
     $r = $invertedIndex->getDocumentIdsByTerm($this->getQuery()[0]);
     if (!empty($r)) {
         return [$this->getQuery()[0] => $r];
     }
     // do partial matches
     $terms = array_keys($invertedIndex->getIndex());
     $found = [];
     foreach ($terms as $term) {
         if (Text::contains($term, $this->getQueryString())) {
             $found[$term] = $invertedIndex->getDocumentIdsByTerm($term);
         }
     }
     return $found;
 }
All Usage Examples Of TextAnalysis\Indexes\InvertedIndex::getDocumentIdsByTerm