TextAnalysis\Indexes\InvertedIndex::removeDocument PHP Method

removeDocument() public method

True if the doc was removed
public removeDocument ( mixed $docId ) : boolean
$docId mixed
return boolean
    public function removeDocument($docId)
    {
        $terms = $this->getTermsByDocumentId($docId);
        $flag = false;
        foreach ($terms as $term) {
            $flag = true;
            $row =& $this->index[$term][self::POSTINGS];
            // remove the term altogether
            if (count($row) === 1) {
                unset($this->index[$term]);
            } else {
                $idx = array_search($docId, $row);
                unset($row[$idx]);
                $row = array_values($row);
                // re-index the array
            }
        }
        return $flag;
    }