Copy语言代码:
if(isset($_SERVER['QUERY_STRING']) ...
Copy
语言代码:
<?
function test()
{
list($a,$b)= explode(" ",microtime());
return (float)$a+(float)$b;
}
if (isset($_SERVER['QUERY_STRING'])
&& !strncasecmp($_SERVER['QUERY_STRING'], 'source', 6))
{
highlight_file(__FILE__);die;
}
if($_POST){
$str = stripslashes($_POST['mydata']);
$len = strlen($str);
$a = test();
$output = sun_ws($str);
$time = sprintf("%.12f",(double)test()-$a);
}
?>
<html>
<head>
<title>中文分词测试 (by sunceenjoy)</title>
<meta http-equiv="Content-type" content="text/html; charset=gbk">
<style type="text/css">
<!--
td, body { background-color: #efefef; font-family: tahoma; font-size: 14px; }
.demotx { font-size: 12px; width: 100%; height: 100px; }
small { font-size: 12px; }
//-->
</style>
</head>
<body>
<h3>
中文分词测试 (by sunceenjoy)
</h3>
<small>
<font color="red">根据词频分词,相同词频长度优先,并未考虑其他情况,目前暂定最大长度为2048字节</font>
</small>
<table width=100% border=0>
<tr>
<form method=post>
<td width=100%>
<strong>请输入文字点击提交尝试分词: </strong> <br />
<textarea name=mydata cols=60 rows=8 class=demotx></textarea>
<input type=submit>
</td>
</form>
</tr>
<tr>
<td><hr /></td>
</tr>
<tr>
<td width=100%>
<strong>分词结果(原文总长度 <?=$len?> 字符) </strong>
<br />
<textarea cols=60 rows=8 class=demotx readonly style="color:#888888;">
<?=$output?></textarea>
<small>
分词耗时: <?=$time?>
</small>
</td>
</tr>
</table>
<small>
或直接 <a href="?source" target="_blank">查看源码</a>
</small>
</body>
</html>