Translate extension for MediaWiki
Loading...
Searching...
No Matches
SimpleStringComparator.php
1
<?php
7
namespace
MediaWiki\Extension\Translate\Utilities\StringComparators
;
8
13
class
SimpleStringComparator
implements
StringComparator
{
15
public
function
getSimilarity
( $addedMessage, $deletedMessage ) {
16
if
( $addedMessage === $deletedMessage ) {
17
return
1;
18
}
19
20
if
( trim( mb_strtolower( $addedMessage ) ) === trim( mb_strtolower( $deletedMessage ) ) ) {
21
// This is an arbitrarily chosen number to differentiate it from an exact match.
22
return
0.95;
23
}
24
25
return
0;
26
}
27
}
MediaWiki\Extension\Translate\Utilities\StringComparators\SimpleStringComparator
A simple string comparator, that compares two strings and determines if they are an exact match.
Definition
SimpleStringComparator.php:13
MediaWiki\Extension\Translate\Utilities\StringComparators\SimpleStringComparator\getSimilarity
getSimilarity( $addedMessage, $deletedMessage)
@inheritDoc
Definition
SimpleStringComparator.php:15
MediaWiki\Extension\Translate\Utilities\StringComparators\StringComparator
An interface to be implemented by comparators that will compare percentage of similarity between stri...
Definition
StringComparator.php:9
MediaWiki\Extension\Translate\Utilities\StringComparators
Contains a simple string compare class.
Definition
SimpleStringComparator.php:7
src
Utilities
StringComparators
SimpleStringComparator.php
Generated by
1.10.0