当前位置: 首页>>代码示例>>PHP>>正文


PHP SplitWord::GetFinallyIndex方法代码示例

本文整理汇总了PHP中SplitWord::GetFinallyIndex方法的典型用法代码示例。如果您正苦于以下问题:PHP SplitWord::GetFinallyIndex方法的具体用法?PHP SplitWord::GetFinallyIndex怎么用?PHP SplitWord::GetFinallyIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SplitWord的用法示例。


在下文中一共展示了SplitWord::GetFinallyIndex方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: in

 $query = "SELECT arc.*, addt.* From `#@__archives` arc LEFT JOIN `#@__addonarticle` addt ON addt.aid=arc.id  WHERE arc.id in({$arcids}) AND arc.channel=1 ";
 $dsql->SetQuery($query);
 $dsql->Execute();
 while ($row = $dsql->GetArray()) {
     //跳过已经有关键字的内容
     if (trim($row['keywords']) != '') {
         continue;
     }
     $aid = $row['id'];
     $keywords = '';
     $title = $row['title'];
     $description = $row['description'];
     $body = cn_substr($row['body'], 5000);
     $sp->SetSource($title, $cfg_soft_lang, $cfg_soft_lang);
     $sp->StartAnalysis();
     $titleindexs = preg_replace("/#p#|#e#/", '', $sp->GetFinallyIndex());
     $sp->SetSource(Html2Text($body), $cfg_soft_lang, $cfg_soft_lang);
     $sp->StartAnalysis();
     $allindexs = preg_replace("/#p#|#e#/", '', $sp->GetFinallyIndex());
     if (is_array($allindexs) && is_array($titleindexs)) {
         foreach ($titleindexs as $k => $v) {
             if (strlen($keywords . $k) >= 60) {
                 break;
             } else {
                 if (strlen($k) <= 2) {
                     continue;
                 }
                 $keywords .= $k . ',';
             }
         }
         foreach ($allindexs as $k => $v) {
开发者ID:playfay,项目名称:FlowDedeCmsBackstageTemplets,代码行数:31,代码来源:archives_do.php

示例2: GetKeywords

 /**
  *  获得关键字的分词结果,并保存到数据库
  *
  * @access    public
  * @param     string  $keyword  关键词
  * @return    string
  */
 function GetKeywords($keyword)
 {
     global $cfg_soft_lang;
     $keyword = cn_substr($keyword, 50);
     $row = $this->dsql->GetOne("SELECT spwords FROM `#@__search_keywords` WHERE keyword='" . addslashes($keyword) . "'; ");
     if (!is_array($row)) {
         if (strlen($keyword) > 7) {
             $sp = new SplitWord($cfg_soft_lang, $cfg_soft_lang);
             $sp->SetSource($keyword, $cfg_soft_lang, $cfg_soft_lang);
             $sp->SetResultType(2);
             $sp->StartAnalysis(TRUE);
             $keywords = $sp->GetFinallyResult();
             $idx_keywords = $sp->GetFinallyIndex();
             ksort($idx_keywords);
             $keywords = $keyword . ' ';
             foreach ($idx_keywords as $key => $value) {
                 if (strlen($key) <= 3) {
                     continue;
                 }
                 $keywords .= ' ' . $key;
             }
             $keywords = preg_replace("/[ ]{1,}/", " ", $keywords);
             //var_dump($idx_keywords);exit();
             unset($sp);
         } else {
             $keywords = $keyword;
         }
         $inquery = "INSERT INTO `#@__search_keywords`(`keyword`,`spwords`,`count`,`result`,`lasttime`)\n          VALUES ('" . addslashes($keyword) . "', '" . addslashes($keywords) . "', '1', '0', '" . time() . "'); ";
         $this->dsql->ExecuteNoneQuery($inquery);
     } else {
         $this->dsql->ExecuteNoneQuery("UPDATE `#@__search_keywords` SET count=count+1,lasttime='" . time() . "' WHERE keyword='" . addslashes($keyword) . "'; ");
         $keywords = $row['spwords'];
     }
     return $keywords;
 }
开发者ID:wshudong,项目名称:hbypsy,代码行数:42,代码来源:arc.searchview.class.php

示例3: AnalyseHtmlBody

/**
 * 处理HTML文本
 * 删除非站外链接、自动摘要、自动获取缩略图
 *
 * @access    public
 * @param     string  $body  内容
 * @param     string  $description  描述
 * @param     string  $litpic  缩略图
 * @param     string  $keywords  关键词
 * @param     string  $dtype  类型
 * @return    string
 */
function AnalyseHtmlBody($body, &$description, &$litpic, &$keywords, $dtype = '')
{
    global $autolitpic, $remote, $dellink, $autokey, $cfg_basehost, $cfg_auot_description, $id, $title, $cfg_soft_lang;
    $autolitpic = empty($autolitpic) ? '' : $autolitpic;
    $body = stripslashes($body);
    //远程图片本地化
    if ($remote == 1) {
        $body = GetCurContent($body);
    }
    //删除非站内链接
    if ($dellink == 1) {
        $allow_urls = array($_SERVER['HTTP_HOST']);
        // 读取允许的超链接设置
        if (file_exists(DEDEDATA . "/admin/allowurl.txt")) {
            $allow_urls = array_merge($allow_urls, file(DEDEDATA . "/admin/allowurl.txt"));
        }
        $body = Replace_Links($body, $allow_urls);
    }
    //自动摘要
    if ($description == '' && $cfg_auot_description > 0) {
        $description = cn_substr(html2text($body), $cfg_auot_description);
        $description = trim(preg_replace('/#p#|#e#/', '', $description));
        $description = addslashes($description);
    }
    //自动获取缩略图
    if ($autolitpic == 1 && $litpic == '') {
        $litpic = GetDDImgFromBody($body);
    }
    //自动获取关键字
    if ($autokey == 1 && $keywords == '') {
        $subject = $title;
        $message = $body;
        include_once DEDEINC . '/splitword.class.php';
        $keywords = '';
        $sp = new SplitWord($cfg_soft_lang, $cfg_soft_lang);
        $sp->SetSource($subject, $cfg_soft_lang, $cfg_soft_lang);
        $sp->StartAnalysis();
        $titleindexs = preg_replace("/#p#|#e#/", '', $sp->GetFinallyIndex());
        $sp->SetSource(Html2Text($message), $cfg_soft_lang, $cfg_soft_lang);
        $sp->StartAnalysis();
        $allindexs = preg_replace("/#p#|#e#/", '', $sp->GetFinallyIndex());
        if (is_array($allindexs) && is_array($titleindexs)) {
            foreach ($titleindexs as $k => $v) {
                if (strlen($keywords . $k) >= 60) {
                    break;
                } else {
                    if (strlen($k) <= 2) {
                        continue;
                    }
                    $keywords .= $k . ',';
                }
            }
            foreach ($allindexs as $k => $v) {
                if (strlen($keywords . $k) >= 60) {
                    break;
                } else {
                    if (!in_array($k, $titleindexs)) {
                        if (strlen($k) <= 2) {
                            continue;
                        }
                        $keywords .= $k . ',';
                    }
                }
            }
        }
        $sp = null;
    }
    $body = GetFieldValueA($body, $dtype, $id);
    $body = addslashes($body);
    return $body;
}
开发者ID:playfay,项目名称:FlowDedeCmsBackstageTemplets,代码行数:83,代码来源:inc_archives_functions.php

示例4: SplitWord

 if ($limitSql != '') {
     $fquery = "SELECT arc.id,arc.title,arc.keywords,addon.body FROM `#@__archives` arc\n              LEFT JOIN `#@__addonarticle` addon ON addon.aid=arc.id WHERE arc.channel='1' {$limitSql} ";
     $dsql->SetQuery($fquery);
     $dsql->Execute();
     $sp = new SplitWord($cfg_soft_lang, $cfg_soft_lang);
     while ($row = $dsql->GetObject()) {
         if ($row->keywords != '') {
             continue;
         }
         $tjnum++;
         $id = $row->id;
         $keywords = "";
         $sp->SetSource($row->title, $cfg_soft_lang, $cfg_soft_lang);
         $sp->SetResultType(2);
         $sp->StartAnalysis(TRUE);
         $titleindexs = $sp->GetFinallyIndex();
         $sp->SetSource(Html2Text($row->body), $cfg_soft_lang, $cfg_soft_lang);
         $sp->SetResultType(2);
         $sp->StartAnalysis(TRUE);
         $allindexs = $sp->GetFinallyIndex();
         if (is_array($allindexs) && is_array($titleindexs)) {
             foreach ($titleindexs as $k => $v) {
                 if (strlen($keywords) >= 30) {
                     break;
                 } else {
                     if (strlen($k) <= 2) {
                         continue;
                     }
                     $keywords .= $k . ",";
                 }
             }
开发者ID:hensonvip,项目名称:ymroad,代码行数:31,代码来源:article_keywords_make.php


注:本文中的SplitWord::GetFinallyIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。