PHP Class TextAnalysis\Indexes\InvertedIndex

Author: yooper (yooper)
显示文件 Open project: yooper/php-text-analysis Class Usage Examples

Protected Properties

Property Type Description
$index array The index

Public Methods

Method Description
__construct ( TextAnalysis\Interfaces\IDataReader $reader ) Pass in the pre-built indexes for doing lookups
__destruct ( ) clean up
addDocument ( TokensDocument $document ) : void Add a document
getDocumentIdsByTerm ( string $term ) : array
getIndex ( ) : array Return the internal index data structure
getTermsByDocumentId ( mixed $docId ) : array Returns the key value array with the terms found in the document for the given doc id
query ( string $queryStr ) : array Accepts a string a query and returns the set of documents relevant to the query
removeDocument ( mixed $docId ) : boolean True if the doc was removed

Method Details

__construct() public method

Pass in the pre-built indexes for doing lookups
public __construct ( TextAnalysis\Interfaces\IDataReader $reader )
$reader TextAnalysis\Interfaces\IDataReader

__destruct() public method

clean up
public __destruct ( )

addDocument() public method

Add a document
public addDocument ( TokensDocument $document ) : void
$document TextAnalysis\Documents\TokensDocument
return void

getDocumentIdsByTerm() public method

public getDocumentIdsByTerm ( string $term ) : array
$term string
return array

getIndex() public method

Return the internal index data structure
public getIndex ( ) : array
return array

getTermsByDocumentId() public method

Returns the key value array with the terms found in the document for the given doc id
public getTermsByDocumentId ( mixed $docId ) : array
$docId mixed
return array

query() public method

Accepts a string a query and returns the set of documents relevant to the query
public query ( string $queryStr ) : array
$queryStr string
return array

removeDocument() public method

True if the doc was removed
public removeDocument ( mixed $docId ) : boolean
$docId mixed
return boolean

Property Details

$index protected_oe property

The index
protected array $index
return array