mirror of
https://github.com/friendica/friendica
synced 2024-12-25 01:20:16 +00:00
18 lines
No EOL
380 B
PHP
18 lines
No EOL
380 B
PHP
<?php
|
|
require_once 'Text/LanguageDetect.php';
|
|
|
|
$text = 'Was wäre, wenn ich Ihnen das jetzt sagen würde?';
|
|
|
|
$ld = new Text_LanguageDetect();
|
|
//3 most probable languages
|
|
$results = $ld->detect($text, 3);
|
|
|
|
foreach ($results as $language => $confidence) {
|
|
echo $language . ': ' . number_format($confidence, 2) . "\n";
|
|
}
|
|
|
|
//output:
|
|
//german: 0.35
|
|
//dutch: 0.25
|
|
//swedish: 0.20
|
|
?>
|