瀏覽代碼

调整自动关键词功能

tags/6.5.6
叙述、别离 1 周之前
父節點
當前提交
89706cf78c
共有 2 個檔案被更改,包括 5 行新增17 行删除
  1. +2
    -2
      src/admin/archives_do.php
  2. +3
    -15
      src/admin/inc/inc_archives_functions.php

+ 2
- 2
src/admin/archives_do.php 查看文件

@@ -658,7 +658,7 @@ else if ($dopost == "makekw") {
if (strlen($keywords.$k) >= 60) { if (strlen($keywords.$k) >= 60) {
break; break;
} else { } else {
if (strlen($k) <= 2 || $length == 3) continue;
if (strlen($k) <= 6 || $length == 3) continue;
$keywords .= $k.','; $keywords .= $k.',';
} }
} }
@@ -666,7 +666,7 @@ else if ($dopost == "makekw") {
if (strlen($keywords.$k) >= 60) { if (strlen($keywords.$k) >= 60) {
break; break;
} else if (!in_array($k, $titleindexs)) { } else if (!in_array($k, $titleindexs)) {
if (strlen($k) <= 2 || $length == 3) continue;
if (strlen($k) <= 6 || $length == 3) continue;
$keywords .= $k.','; $keywords .= $k.',';
} }
} }


+ 3
- 15
src/admin/inc/inc_archives_functions.php 查看文件

@@ -537,12 +537,10 @@ function AnalyseHtmlBody($body, &$description, &$litpic, &$keywords, $dtype = ''
//自动获取关键词 //自动获取关键词
if ($autokey == 1) { if ($autokey == 1) {
$subject = $title; $subject = $title;
$message = $body;
//采用DedeBIZ Core分词组件分词 //采用DedeBIZ Core分词组件分词
if (!empty($cfg_bizcore_appid) && !empty($cfg_bizcore_key)) { if (!empty($cfg_bizcore_appid) && !empty($cfg_bizcore_key)) {
$keywords = ''; $keywords = '';
$client = new DedeBizClient(); $client = new DedeBizClient();
$data = $client->Spliteword($subject.Html2Text($message));
$keywords = $data->data; $keywords = $data->data;
$client->Close(); $client->Close();
} else { } else {
@@ -552,24 +550,14 @@ function AnalyseHtmlBody($body, &$description, &$litpic, &$keywords, $dtype = ''
$sp->SetSource($subject, $cfg_soft_lang); $sp->SetSource($subject, $cfg_soft_lang);
$sp->StartAnalysis(); $sp->StartAnalysis();
$titleindexs = preg_replace("/#p#|#e#/", '', $sp->GetFinallyIndex()); $titleindexs = preg_replace("/#p#|#e#/", '', $sp->GetFinallyIndex());
$sp->SetSource(Html2Text($message), $cfg_soft_lang);
$sp->StartAnalysis(); $sp->StartAnalysis();
$allindexs = preg_replace("/#p#|#e#/", '', $sp->GetFinallyIndex());
if (is_array($allindexs) && is_array($titleindexs)) {
if (is_array($titleindexs)) {
foreach ($titleindexs as $k => $v) { foreach ($titleindexs as $k => $v) {
if (strlen($keywords.$k) >= 60) { if (strlen($keywords.$k) >= 60) {
break; break;
} else { } else {
if (strlen($k) <= 2 || $length == 3) continue;
$keywords .= $k.',';
}
}
foreach ($allindexs as $k => $v) {
if (strlen($keywords.$k) >= 60) {
break;
} else if (!in_array($k, $titleindexs)) {
if (strlen($k) <= 2 || $length == 3) continue;
$keywords .= $k.',';
if (strlen($k) <= 6 || $length == 3) continue;
$keywords .= ($keywords == '' ? "{$k}" : ",{$k}");
} }
} }
} }


Loading…
取消
儲存