PHP 生成文本关键词作为Tags PHP生成Tags

namespace NT;

class Tags {
	public function makeTags($string) {
		$remove = array("a", "an", "the", "is", "are", "i", "we", "you", "he", "she", "it",
            		"they", "has", "had", "have", "be", "been", "do", "does", "done", "did", "in",
            		"was", "were", "here", "there", "where", "when", "how", "why", "to",
            		"and", "or", "this", "that", "there", "those", "them", "their", "me",
            		"my", "am", "on", "so", "at", "as", "of", "with", "will", "shall", "event");

        	$symbols = array(".", ",", "!", "\"", "'", "?", "/", "[", "]", "{", "}", "!",
            	"@", "#", "$", "%", "^", "&", "*", "(", ")", "-", "_", "+", "=", "\\", "`", "~");

        	$string = explode(" ", str_replace($symbols, " ", $string));
        	$tags = array();
        	foreach ($string as $word) {
            		$word = strtolower(trim($word));
            			if (!in_array($word, $remove) && $word != "" && !is_numeric($word)) {
                			$word = stem($word);
                			if (!in_array($word, $tags))
                    				$tags[] = $word;
            			}
        	}
        	return $tags;
	}
}

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注