PHP Class DiffMatchPatch\Match

Author: Neil Fraser ([email protected])
Author: Daniil Skrobov ([email protected])
Afficher le fichier Open project: yetanotherape/diff-match-patch

Protected Properties

Свойство Type Description
$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).

Méthodes publiques

Méthode Description
__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 )

Méthodes protégées

Méthode Description
bitapScore ( integer $errors, integer $matchLoc, integer $patternLen, integer $searchLoc ) : float Compute and return the score for a match with e errors and x location.

Method Details

__construct() public méthode

public __construct ( )

alphabet() public méthode

Initialise the alphabet for the Bitap algorithm.
public alphabet ( string $pattern ) : array
$pattern string The text to encode.
Résultat array Hash of character locations.

bitap() public méthode

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.
Résultat integer Best match index or -1.

bitapScore() protected méthode

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.
Résultat float Overall score for match (0.0 = good, 1.0 = bad).

getDistance() public méthode

public getDistance ( ) : integer
Résultat integer

getMaxBits() public méthode

public getMaxBits ( ) : integer
Résultat integer

getThreshold() public méthode

public getThreshold ( ) : float
Résultat float

main() public méthode

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.
Résultat integer Best match index or -1.

setDistance() public méthode

public setDistance ( integer $distance )
$distance integer

setMaxBits() public méthode

public setMaxBits ( integer $maxBits )
$maxBits integer

setThreshold() public méthode

public setThreshold ( float $threshold )
$threshold float

Property Details

$distance protected_oe property

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 protected_oe property

The number of bits in an int.
protected $maxBits

$threshold protected_oe property

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