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


PHP SplitWord::SetSource方法代码示例

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


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

示例1: SplitWord

 $sp = new SplitWord($cfg_soft_lang, $cfg_soft_lang);
 $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
 $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 . ',';
             }
开发者ID:playfay,项目名称:FlowDedeCmsBackstageTemplets,代码行数:31,代码来源:archives_do.php

示例2: array

     $smarty->assign('cat_list', cat_list(0, $adv_value['category'], true, 2, false));
     $smarty->assign('brand_list', get_brand_list());
     $smarty->assign('action', 'form');
     $smarty->assign('use_storage', $_CFG['use_storage']);
     $action = 'form';
 }
 /* 初始化搜索条件 */
 $keywords = '';
 $tag_where = '';
 if (!empty($_REQUEST['keywords'])) {
     /* 代码修改_START   By    www.68ecshop.com   */
     include_once 'includes/lib_splitword_www_68ecshop_com.php';
     $Recordkw = str_replace(array("\\'"), array(''), trim($_REQUEST['keywords']));
     $cfg_soft_lang_www_68ecshop_com = 'utf-8';
     $sp_www_68ecshop_com = new SplitWord($cfg_soft_lang_www_68ecshop_com, $cfg_soft_lang_www_68ecshop_com);
     $sp_www_68ecshop_com->SetSource($Recordkw, $cfg_soft_lang_www_68ecshop_com, $cfg_soft_lang_www_68ecshop_com);
     $sp_www_68ecshop_com->SetResultType(1);
     $sp_www_68ecshop_com->StartAnalysis(TRUE);
     $word_www_68ecshop_com = $sp_www_68ecshop_com->GetFinallyResult(' ');
     //echo  $word_www_68ecshop_com;
     $word_www_68ecshop_com = preg_replace("/[ ]{1,}/", " ", trim($word_www_68ecshop_com));
     $replacef_www_68ecshop_com = explode(' ', $word_www_68ecshop_com);
     $keywords = 'AND (';
     $goods_ids = array();
     foreach ($replacef_www_68ecshop_com as $key => $val) {
         if ($key > 0 && $key < count($replacef_www_68ecshop_com) && count($replacef_www_68ecshop_com) > 1) {
             $keywords .= " AND ";
         }
         $val = mysql_like_quote(trim($val));
         $sc_dsad = $_REQUEST['sc_ds'] ? " OR goods_desc LIKE '%{$val}%'" : '';
         $keywords .= "(goods_name LIKE '%{$val}%' OR goods_sn LIKE '%{$val}%' OR keywords LIKE '%{$val}%' {$sc_dsad})";
开发者ID:moonlight-wang,项目名称:feilun,代码行数:31,代码来源:search.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: 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


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