예제 #1
0
    while ($result = $scws->get_result()) {
        foreach ($result as $tmp) {
            $words[] = $tmp['word'];
        }
    }
    $result2 = implode(' ', $words);
    if ($result2 === $data['result']) {
        $success++;
        echo "PASS!\n";
    } else {
        $failure++;
        echo "FAILURE!\n";
        echo "----------------------------------------\n";
        echo "ORGINAL TEXT: {$text}\n";
        echo "EXPECTED RESULT: {$data['result']}\n";
        echo "ACTUAL RESULT: {$result2}\n";
        echo "========================================\n";
    }
    $start++;
}
$scws->close();
//5. show result report
$start -= 1;
echo "// -------------------------------------\n";
echo "// TEST result report\n";
echo "// " . scws_version() . "\n";
echo "// -------------------------------------\n";
echo "// Total test: {$start}\n";
printf("// Passed Num: %d (%.2f%%)\n", $success, 100 * $success / $start);
printf("// Failed Num: %d (%.2f%%)\n", $failure, 100 * $failure / $start);
echo "// -------------------------------------\n";
예제 #2
0
파일: v48.cht.php 프로젝트: timelessz/scws
            } else {
                if ($showa) {
                    printf("%s/%s ", $tmp['word'], $tmp['attr']);
                } else {
                    printf("%s ", $tmp['word']);
                }
            }
        }
        flush();
    }
}
$cws->close();
$time_end = get_microtime();
$time = $time_end - $time_start;
?>
		</textarea>		
		<small>
		  分词耗时: <?php 
echo $time;
?>
秒
		  <a href="../">返回scws主页</a>或直接<a href="?source" target="_blank">查看源码</a> Powered by <?php 
echo scws_version();
?>
		</small>
	</td>
  </tr>
</table>
</body>
</html>
예제 #3
0
파일: api.php 프로젝트: lamphp/scws
//
set_time_limit(0);
error_reporting(0);
ini_set('display_errors', '0');
// show source
if (isset($_SERVER['QUERY_STRING']) && !strncasecmp($_SERVER['QUERY_STRING'], 'source', 6)) {
    header("Content-Type: text/html; charset=utf-8");
    highlight_file(__FILE__);
    exit(0);
}
// get data
if (!isset($_POST['data'])) {
    $charset = 'utf-8';
    $respond = 'plain';
    $apiurl = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'];
    $version2 = scws_version();
    include 'header.inc.php';
    echo <<<__EOF__
<div class="block">
<h2>SCWS(简易中文分词) 基于HTTP/POST的分词 API 使用说明</h2>
<ol>
<li>API 地址:<a href="{$apiurl}">{$apiurl}</a></li>
<li>
\t请求方式:仅支持 POST,推荐采用纯 PHP 实现的 <a href="http://www.hightman.cn/bbs/showthread.php?tid=838" target="_blank">HTTP client 库</a>
</li>
<li>请求的参数变量及含义:
\t<ul>
\t\t<li><em>data</em> 需要分词的字符串(*必须*)</li>
\t\t<li><em>respond</em> 响应结果格式(其值为: php/json/xml, 默认为 php,其中 php是指用php序列化后的结果)</li>
\t\t<li><em>charset</em> 待分词的字符串编码(gbk/utf8,默认是utf8)</li>
\t\t<li><em>ignore</em> 是否忽略标点符号(yes/no,默认为 no)</li>