PHP Класс DiffMatchPatch\Match

Автор: Neil Fraser ([email protected])
Автор: Daniil Skrobov ([email protected])
Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$distance How far to search for a match (0 = exact location, 1000+ = broad match). A match this many characters away from the expected location will add 1.0 to the score (0.0 is a perfect match).
$maxBits The number of bits in an int.
$threshold At what point is no match declared (0.0 = perfection, 1.0 = very loose).

Открытые методы

Метод Описание
__construct ( )
alphabet ( string $pattern ) : array Initialise the alphabet for the Bitap algorithm.
bitap ( string $text, string $pattern, integer $loc ) : integer Locate the best instance of 'pattern' in 'text' near 'loc' using the Bitap algorithm.
getDistance ( ) : integer
getMaxBits ( ) : integer
getThreshold ( ) : float
main ( string $text, string $pattern, integer $loc ) : integer Locate the best instance of 'pattern' in 'text' near 'loc'.
setDistance ( integer $distance )
setMaxBits ( integer $maxBits )
setThreshold ( float $threshold )

Защищенные методы

Метод Описание
bitapScore ( integer $errors, integer $matchLoc, integer $patternLen, integer $searchLoc ) : float Compute and return the score for a match with e errors and x location.

Описание методов

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

public __construct ( )

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

Initialise the alphabet for the Bitap algorithm.
public alphabet ( string $pattern ) : array
$pattern string The text to encode.
Результат array Hash of character locations.

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

Locate the best instance of 'pattern' in 'text' near 'loc' using the Bitap algorithm.
public bitap ( string $text, string $pattern, integer $loc ) : integer
$text string The text to search.
$pattern string The pattern to search for.
$loc integer The location to search around.
Результат integer Best match index or -1.

bitapScore() защищенный Метод

Accesses loc and pattern through being a closure.
protected bitapScore ( integer $errors, integer $matchLoc, integer $patternLen, integer $searchLoc ) : float
$errors integer Number of errors in match.
$matchLoc integer Location of match.
$patternLen integer Length of pattern to search.
$searchLoc integer The location to search around. TODO refactor param usage.
Результат float Overall score for match (0.0 = good, 1.0 = bad).

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

public getDistance ( ) : integer
Результат integer

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

public getMaxBits ( ) : integer
Результат integer

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

public getThreshold ( ) : float
Результат float

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

Locate the best instance of 'pattern' in 'text' near 'loc'.
public main ( string $text, string $pattern, integer $loc ) : integer
$text string The text to search.
$pattern string The pattern to search for.
$loc integer The location to search around.
Результат integer Best match index or -1.

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

public setDistance ( integer $distance )
$distance integer

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

public setMaxBits ( integer $maxBits )
$maxBits integer

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

public setThreshold ( float $threshold )
$threshold float

Описание свойств

$distance защищенное свойство

How far to search for a match (0 = exact location, 1000+ = broad match). A match this many characters away from the expected location will add 1.0 to the score (0.0 is a perfect match).
protected $distance

$maxBits защищенное свойство

The number of bits in an int.
protected $maxBits

$threshold защищенное свойство

At what point is no match declared (0.0 = perfection, 1.0 = very loose).
protected $threshold