Skip to content

Commit f7f999d

Browse files
committed
Upgrade to v3
1 parent 3057214 commit f7f999d

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
![supported PHP versions](https://img.shields.io/badge/PHP-%3E%3D%207.4-blue)
66
[![license](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
77
[![supported languages](https://img.shields.io/badge/supported%20languages-60-brightgreen.svg)](#languages)
8-
![version](https://img.shields.io/badge/ver.-3.0--beta-blue)
8+
![version](https://img.shields.io/badge/ver.-3.0-blue)
99

1010
</div>
1111

@@ -21,7 +21,7 @@ ELD is also available (outdated versions) in [Javascript](https://github.com/nit
2121
5. [Testing](#testing)
2222
6. [Languages](#languages)
2323

24-
> Changes from ELD v2 to v3-beta:
24+
> Changes from ELD v2 to v3:
2525
> * detect()->language now returns string `'und'` for *undetermined* instead of `NULL`
2626
> * Databases are not compatible, and bigger, medium v2 ≈ small v3
2727
> * dynamicLangSubset() function is removed
@@ -107,7 +107,7 @@ I compared *ELD* with a different variety of detectors, as there are not many in
107107

108108
| URL | Version | Language |
109109
|:---------------------------------------------------------|:-------------|:-------------|
110-
| https://github.com/nitotm/efficient-language-detector/ | 3.0.0-BETA | PHP |
110+
| https://github.com/nitotm/efficient-language-detector/ | 3.0.0 | PHP |
111111
| https://github.com/pemistahl/lingua-py | 2.0.2 | Python |
112112
| https://github.com/facebookresearch/fastText | 0.9.2 | C++ |
113113
| https://github.com/CLD2Owners/cld2 | Aug 21, 2015 | C++ |

src/LanguageResult.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414
final class LanguageResult
1515
{
16-
public string $language;
16+
public string $language; // TODO make it readonly when we upgrade to PHP +8.1
1717
private int $languageId;
1818
/** @var array<int, float> $rawScores */
1919
private array $rawScores;
@@ -90,12 +90,14 @@ public function isReliable(): bool
9090
}
9191
/** @var array<string, float> $scores */
9292
$scores = $this->scores();
93+
reset($scores); // Make sure the pointer is at the beginning
9394

9495
// Is reliable if score is >75% of average, and +5% higher than next score. Selected numbers after testing
9596
if ($this->avgScore[$this->languageId] * 0.75 > $scores[$this->language]
9697
|| 0.05 > abs($scores[$this->language] - next($scores)) / $scores[$this->language]) {
9798
return false;
9899
}
100+
99101
return true;
100102
}
101103
}

0 commit comments

Comments
 (0)