Рекурсивный акроним словосочетания «PHP: Hypertext Preprocessor»
Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетили 17177 программистов и 1838 роботов. Сейчас ищет 1551 программист ...
Example
Вернуться к: Text_LanguageDetect
<?php
require_once 'Text/LanguageDetect.php';
$l = new Text_LanguageDetect();
echo "Supported languages:\n";
try {
$langs = $l->getLanguages();
sort($langs);
echo implode(', ', $langs) . "\n\n";
} catch (Text_LanguageDetect_Exception $e) {
die($e->getMessage());
}
$text = <<<EOD
Hallo! Das ist ein Text in deutscher Sprache.
Mal sehen, ob die Klasse erkennt, welche Sprache das hier ist.
EOD;
try {
//return 2-letter language codes only
$l->setNameMode(2);
$result = $l->detect($text, 4);
print_r($result);
} catch (Text_LanguageDetect_Exception $e) {
die($e->getMessage());
}
?>
The above example would give the following output:
Output
Supported languages: albanian, arabic, azeri, bengali, bulgarian, cebuano, croatian, czech, danish, dutch, english, estonian, farsi, finnish, french, german, hausa, hawaiian, hindi, hungarian, icelandic, indonesian, italian, kazakh, kyrgyz, latin, latvian, lithuanian, macedonian, mongolian, nepali, norwegian, pashto, pidgin, polish, portuguese, romanian, russian, serbian, slovak, slovene, somali, spanish, swahili, swedish, tagalog, turkish, ukrainian, urdu, uzbek, vietnamese, welsh Array ( [de] => 0.40703703703704 [nl] => 0.2880658436214 [en] => 0.28333333333333 [da] => 0.23452674897119 )
Вернуться к: Text_LanguageDetect