forked from wulijun/php-ext-trie-filter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
triefilter.php
100 lines (85 loc) · 2.42 KB
/
triefilter.php
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
/**
* Helper autocomplete for php trie-filter extension
* @author wulijun01234 <[email protected]>
* @link https://github.com/wulijun/php-ext-trie-filter
*/
/**
* Load a trie tree from a saved trie tree file
*
* @param string $strDictFile Path to saved trie tree file
* @return resource The trie tree handler or NULL on error.
*/
function trie_filter_load($strDictFile) {
}
/**
* Find if a spam word exists in the content
*
* @param resource $resTree
* @param string $strContent
* @return array spam word info, like Array(0 => start position, 1 => spam word len), if no one found, return empty array, false on error.
* @example
* <pre>
* $arrSpamWord = trie_filter_search($resTree, $strContent);
* if (! empty($arrSpamWord)) {
* echo substr($strContent, $arrSpamWord[0], $arrSpamWord[1]);
* }
* </pre>
*/
function trie_filter_search($resTree, $strContent) {
}
/**
* Find all spam word exists in the content
*
* @param resource $resTree
* @param string $strContent
* @return array spam word info, like Array(Array(0 => start position, 1 => spam word len)), if no one found, return empty array, false on error.
* @example
* <pre>
* $arrSpamWord = trie_filter_search_all($resTree, $strContent);
* if (! empty($arrSpamWord)) {
* foreach ($arrSpamWord as $arrOneWord) {
* echo substr($strContent, $arrOneWord[0], $arrOneWord[1]);
* }
* }
* </pre>
*/
function trie_filter_search_all($resTree, $strContent) {
}
/**
* Create an empty trie tree
*
* @return resource The trie tree handler or NULL on error.
*/
function trie_filter_new() {
}
/**
* Add a word to the trie tree
*
* @param resource $resTree
* @param string $strWord
* @return bool true on success or false on error.
*/
function trie_filter_store($resTree, $strWord) {
}
/* {{{ proto array (int trie_tree_identifier, string dict_path)
Returns true, or false on error*/
/**
* Save trie tree to a file
*
* @param resource $resTree
* @param string $strDictFile
* @return bool true on success or false on error.
*/
function trie_filter_save($resTree, $strDictFile) {
}
/**
* Free trie tree
*
* Trie tree will be destructed automaticly when script finished, however, you can free it yourself.
*
* @param resource $resTree
* @return bool true on success or false on error.
*/
function trie_filter_free($resTree) {
}