2016-11-14 83 views
1

無法檢測英語我想這包http://pear.php.net/package/Text_LanguageDetect/梨包語言檢測上PHP 7

這是非常準確的PHP 5.4。但是我在PHP 7上失敗了。任何想法爲什麼?

腳本我運行:

<?php 
    require_once 'Text/LanguageDetect.php'; 

    $l = new Text_LanguageDetect; 

    $stdin = fopen('php://stdin', 'r'); 

    echo "Supported languages:\n"; 

    try { 
    $langs = $l->getLanguages(); 
    } catch (Text_LanguageDetect_Exception $e) { 
    die($e->getMessage()); 
    } 

    sort($langs); 
    echo join(', ', $langs); 

    //$l->setNameMode(2); 
    while ($line = fgets($stdin)) { 
    print_r($l->detect($line, 4)); 
    //print_r($l->detectSimple($line)); 
    } 

輸入:

This is English. What does this mean? 

相同的腳本在PHP 7.0.9 PHP的

This is English. What does this mean? 
Array 
(
    [hungarian] => 0.20114942528736 
    [albanian] => 0.19632183908046 
    [danish] => 0.1848275862069 
    [french] => 0.17183908045977 
) 

相同的腳本。 5.4.34

This is English. What does this mean? 
Array 
(
    [english] => 0.34965517241379 
    [dutch] => 0.24896551724138 
    [latin] => 0.23931034482759 
    [hungarian] => 0.20114942528736 
) 

回答