Index: trunk/extensions/Translate/utils/TTMServer.php |
— | — | @@ -201,7 +201,13 @@ |
202 | 202 | $b = $row->tms_text; |
203 | 203 | $lenB = mb_strlen( $b ); |
204 | 204 | $len = min( $lenA, $lenB ); |
205 | | - $dist = self::levenshtein_php( $a, $b, $lenA, $lenB ); |
| 205 | + if ( $len > 1000 ) { |
| 206 | + // two strings of length 1500 ~ 10s |
| 207 | + // two strings of length 2250 ~ 30s |
| 208 | + $dist = $len; |
| 209 | + } else { |
| 210 | + $dist = self::levenshtein( $a, $b, $lenA, $lenB ); |
| 211 | + } |
206 | 212 | $quality = 1 - ( $dist / $len ); |
207 | 213 | |
208 | 214 | if ( $quality >= $this->config['cutoff'] ) { |
— | — | @@ -261,7 +267,7 @@ |
262 | 268 | /** |
263 | 269 | * The native levenshtein is limited to 255 bytes. |
264 | 270 | */ |
265 | | - function levenshtein_php( $str1, $str2, $length1, $length2 ) { |
| 271 | + public static function levenshtein( $str1, $str2, $length1, $length2 ) { |
266 | 272 | if ( $length1 == 0 ) return $length2; |
267 | 273 | if ( $length2 == 0 ) return $length1; |
268 | 274 | if ( $str1 === $str2 ) return 0; |