test.php
1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
require_once dirname(__FILE__).'/keyword.class.php';
$keyword = new keyword();
/**
* 根据txt生成compile词语数组,最后生成字典 |或 根据compile词语数组生成字典
*/
$txt = dirname(__FILE__).'/cache/register/registerWords.txt';
$compile = dirname(__FILE__).'/cache/register/registerWordsCompile.php';
$dictionary = dirname(__FILE__).'/cache/register/registerDictionary.php';
//$keyword->importTxtDictionary($txt, $compile);
//生成字典
//print_r($keyword->compileDictionary($compile, $dictionary));
$keywords = array (
2 =>
array (
0 => '生孩子没屁眼',
1 => '傻逼',
2 => '日你妈',
3 => '妈了个逼',
4 => '妈B',
5 => '贱人',
6 => '贱货',
7 => '狗日的',
8 => '狗娘养的',
9 => '粪青',
)
);
print_r($keyword->compileWord($keywords));
/*
//加载字典库
require_once dirname(__FILE__).'/cache/register/registerDictionary.php';
$str = 'administrator';
$keyword->setDictionaryWords($dictionaryWords);
echo $keyword->allSame(strtolower($str));
//函数
//$starttime= microtime_float();
//$myword = $keyword->replace($str);
//$endtime= microtime_float();
//函数结束
/*
//str_replace函数
$time_start = microtime_float();
require_oncedirname(__FILE__).'/cache/wordsCompile.php';
for($i=0;$i<count($pword);$i++)
{
str_replace($pword[$i], '',$str);
}
$time_end = microtime_float();
//str_replace函数结束
printf("<br>函数时间 : %f<br>",$endtime - $starttime);
printf("<br>str_replace时间: %f<br>",$time_end - $time_start);
echo "<br>结果:<br>".$myword;
//时间函数
function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
*/