function test_unicode_off() { // see what happens when you turn the unicode setting off $myobj = new TextLanguageDetect(); $str = 'This is a delightful sample of English text'; $myobj->useUnicodeBlocks(true); $result1 = $myobj->detectConfidence($str); $myobj->useUnicodeBlocks(false); $result2 = $myobj->detectConfidence($str); $this->assertEquals($result1, $result2); // note this test doesn't tell if unicode narrowing was actually used or not }
Enter text to identify language (at least a couple of sentences):<br /> <textarea name="q" wrap="virtual" cols="80" rows="8"><?php echo $q; ?> </textarea> <br /> <input type="submit" value="Submit" /> </form> <?php if (isset($q) && strlen($q)) { $len = $l->utf8strlen($q); if ($len < 20) { // this value picked somewhat arbitrarily echo "Warning: string not very long ({$len} chars)<br />\n"; } $result = $l->detectConfidence($q); if ($result == null) { echo "Text_LanguageDetect cannot identify this piece of text. <br /><br />\n"; } else { echo "Text_LanguageDetect thinks this text is written in <b>{$result['language']}</b> ({$result['similarity']}, {$result['confidence']})<br /><br />\n"; } $result = $l->detectUnicodeBlocks($q, false); if (!empty($result)) { arsort($result); echo "Unicode blocks present: ", join(', ', array_keys($result)), "\n<br /><br />"; } } unset($l); /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ ?> </body></html>