]> git.mxchange.org Git - friendica.git/blob - library/langdet/docs/example_clui.php
8e7d8577d377f1e922876b783cfb90c014647445
[friendica.git] / library / langdet / docs / example_clui.php
1 <?php
2
3 /**
4  * example usage (CLI)
5  *
6  * @package Text_LanguageDetect
7  * @version CVS: $Id: example_clui.php 322305 2012-01-15 00:04:17Z clockwerx $
8  */
9
10 require_once 'Text/LanguageDetect.php';
11
12 $l = new Text_LanguageDetect;
13
14 $stdin = fopen('php://stdin', 'r');
15
16 echo "Supported languages:\n";
17 $langs = $l->getLanguages();
18 sort($langs);
19 echo join(', ', $langs);
20
21 echo "\ntotal ", count($langs), "\n\n";
22
23 while ($line = fgets($stdin)) {
24     $result = $l->detect($line, 4);
25     print_r($result);
26     $blocks = $l->detectUnicodeBlocks($line, true);
27     print_r($blocks);
28 }
29
30 fclose($stdin);
31 unset($l);
32
33 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
34
35 ?>