//德华刘你能修正过来吗? //coo; function get_tags_arr($title) { require APP_ROOT . '/pscws4.class.php'; $pscws = new PSCWS4(); $pscws->set_dict(APP_ROOT . '/scws/dict.utf8.xdb'); $pscws->set_rule(APP_ROOT . '/scws/rules.utf8.ini'); $pscws->set_ignore(true); $pscws->send_text($title); $words = $pscws->get_tops(5); $tags = array(); foreach ($words as $val) { $tags[] = $val['word']; } $pscws->close(); return $tags; } print_r(get_tags_arr($con)); function get_keywords_str($content) { require APP_ROOT . '/phpanalysis.class.php'; PhpAnalysis::$loadInit = false; $pa = new PhpAnalysis('utf-8', 'utf-8', false); $pa->LoadDict(); $pa->SetSource($content); $pa->StartAnalysis(false); $tags = $pa->GetFinallyResult(); return $tags; } print get_keywords_str($con);
} $config = array("template" => "Template/temp.html", "style" => "Template/Style/Github2.css"); $template = @file_get_contents($config['template']); $style = @file_get_contents($config['style']); $dir = ROOT . "/../Docs"; $out_dir = ROOT . "/../HTML"; echo "\nGenerate html file\n\n"; $files = glob($dir . "/*.md"); $file_tags = array(); foreach ($files as $file) { echo "Processing file " . $file . "\n"; $filename = pathinfo($file)['filename']; $markdown = @file_get_contents($file); //$content = MarkdownExtra::defaultTransform($markdown); $content = MarkdownExtended($markdown); $tags = get_tags_arr(strip_tags($content)); // 提取文章的关键词 sort($tags); $tag_str = implode(",", $tags); $html = $template; $html = str_replace("{{title}}", $filename, $html); $html = str_replace("{{style}}", $style, $html); $html = str_replace("{{content}}", $content, $html); $html = str_replace("{{tags}}", $tag_str, $html); $htmlfile = $filename . ".html"; $file_tags[] = array("file" => $htmlfile, "tags" => $tags); file_put_contents($out_dir . "/" . $htmlfile, $html); } echo "\nGenerate related pages\n\n"; foreach ($file_tags as $file_tag) { $filename = $file_tag['file'];