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


PHP SplitWord类代码示例

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


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

示例1: splitWords

function splitWords($str, $style = 'array')
{
    //字典文件太大,防止读取时服务器配置内存不够用
    //@ini_set("memory_limit","30M");
    require_once dirname(__FILE__) . "/utf8_splitword.php";
    $sp = new SplitWord();
    $result = $sp->SplitRMM($str);
    $sp->Clear();
    if ($style == 'string') {
        return $result;
    } else {
        if ($style == 'array') {
            return split(',', $result);
        }
    }
}
开发者ID:Nightchen0521,项目名称:cmf,代码行数:16,代码来源:index.php

示例2: check

 /**
  *Ajax检测商机名称
  *
  **/
 public function check()
 {
     import("@.ORG.SplitWord");
     $sp = new SplitWord();
     $m_business = M('Business');
     $useless_words = array(L('COMPANY'), L('LIMITED'), L('DI'), L('LIMITED_COMPANY'));
     if ($this->isAjax()) {
         $split_result = $sp->SplitRMM($_POST['name']);
         if (!is_utf8($split_result)) {
             $split_result = iconv("GB2312//IGNORE", "UTF-8", $split_result);
         }
         $result_array = explode(' ', trim($split_result));
         if (count($result_array) < 2) {
             $this->ajaxReturn(0, '', 0);
             die;
         }
         foreach ($result_array as $k => $v) {
             if (in_array($v, $useless_words)) {
                 unset($result_array[$k]);
             }
         }
         $name_list = $m_business->getField('name', true);
         $seach_array = array();
         foreach ($name_list as $k => $v) {
             $search = 0;
             foreach ($result_array as $k2 => $v2) {
                 if (strpos($v, $v2) > -1) {
                     $v = str_replace("{$v2}", "<span style='color:red;'>{$v2}</span>", $v, $count);
                     $search += $count;
                 }
             }
             if ($search > 2) {
                 $seach_array[$k] = array('value' => $v, 'search' => $search);
             }
         }
         $seach_sort_result = array_sort($seach_array, 'search', 'desc');
         if (empty($seach_sort_result)) {
             $this->ajaxReturn(0, L('ABLE_ADD'), 0);
         } else {
             $this->ajaxReturn($seach_sort_result, L('CUSTOMER_IS_CREATED'), 1);
         }
     }
 }
开发者ID:strollClouds,项目名称:snkStudy,代码行数:47,代码来源:BusinessAction.class.php

示例3: usingRMM

function usingRMM($keyword)
{
    $yuan = trim($keyword);
    $yuan = iconv('UTF-8', 'GB2312', $yuan);
    $tt = $yuan;
    $str = gl($tt);
    $sp = new SplitWord();
    $tt = $sp->SplitRMM($str);
    $cc = $tt;
    if (substr($cc, 0, 3) == "、") {
        $cc = substr($cc, 3);
    }
    if (substr($cc, -3, 3) == "、") {
        $cc = substr($cc, 0, -3);
    }
    $newstr = explode("、", $cc);
    if ($newstr[0] == "") {
        return false;
    }
    for ($i = 0; $i < count($newstr); $i++) {
        $newstr[$i] = iconv("gb2312", "UTF-8", $newstr[$i]);
    }
    return $newstr;
}
开发者ID:piriterchen,项目名称:online_learning,代码行数:24,代码来源:useRMM.php

示例4: urldecode

 $i_sqlstr = "select * from tb_video_type ";
 $arraysi = $result->getRows($i_sqlstr, $conn);
 $smarty->assign("video_type", $arraysi);
 //获取更多相关视频
 require "splitword.php";
 //进行分词处理
 require "common/function.php";
 //过滤标点
 if (isset($_GET["video_name"])) {
     $keyword = urldecode($_GET['video_name']);
     //获取内容
 }
 $yuan = trim($keyword);
 $tt = $yuan;
 $str = gl($tt);
 $sp = new SplitWord();
 $sp->SplitRMM($str);
 $tt = $sp->SplitRMM($str);
 //$sp->Clear();
 $str = array(" ", "");
 //定义一个数组
 $cc = str_replace($str, "", $tt);
 //去掉字符串中的空格
 if (substr($cc, 0, 2) == "、") {
     $cc = substr($cc, 2);
     //去掉前面的“、”符号
 }
 if (substr($cc, -2, 2) == "、") {
     $cc = substr($cc, 0, -2);
     //去掉后面的“、”符号
 }
开发者ID:Arrray,项目名称:PHPpractice,代码行数:31,代码来源:look.php

示例5: addnews_action

 function addnews_action()
 {
     if ($_POST['updatenews']) {
         $news_base = $this->obj->DB_select_once('news_base', "`id`='" . $_POST['id'] . "'", "`newsphoto`,`s_thumb`,`datetime`");
         if ($_POST['uplocadpic']) {
             if ($news_base['s_thumb'] != $_POST['uplocadpic']) {
                 if ($news_base['s_thumb']) {
                     unlink_pic('../' . $news_base['s_thumb']);
                     unlink_pic('../' . $news_base['newsphoto']);
                 }
                 $upload = $this->upload_pic("../data/upload/news/");
                 if (file_exists('..' . $_POST['uplocadpic'])) {
                     $uplocadpic = $upload->picture('..' . $_POST['uplocadpic'], false, 1);
                     //同名文件已经存在了
                     $s_thumb = $upload->news_makeThumb($uplocadpic, 120, 120, '_S_');
                     $value .= "`newsphoto`='" . str_replace("../data/upload/new", "data/upload/new", $uplocadpic) . "',";
                     $value .= "`s_thumb`='" . str_replace("../data/upload/new", "data/upload/new", $s_thumb) . "',";
                 } else {
                     $s_thumb = $upload->news_makeThumb('..' . $_POST['uplocadpic'], 120, 120, '_S_');
                     $value .= "`newsphoto`='" . str_replace("/config/", "config/", $_POST['uplocadpic']) . "',";
                     $value .= "`s_thumb`='" . str_replace("../config/", "config/", $s_thumb) . "',";
                 }
             }
             unlink_pic('..' . $_POST['uplocadpic']);
         }
         $content = str_replace(array("&amp;", "background-color:#ffffff", "background-color:#fff", "white-space:nowrap;"), array("&", '', '', ''), html_entity_decode($_POST["content"], ENT_QUOTES, "GB2312"));
         $describe = @implode(",", $_POST['describe']);
         $time = time();
         if (empty($_POST['did'])) {
             $_POST['did'] = 0;
         }
         $value .= "`did`='" . $_POST['did'] . "',";
         $value .= "`color`='" . $_POST['color'] . "',";
         $value .= "`sort`='" . $_POST['sort'] . "',";
         $value .= "`nid`='" . $_POST['nid'] . "',";
         $value .= "`author`='" . $_POST['author'] . "',";
         $value .= "`source`='" . $_POST['source'] . "',";
         $value .= "`title`='" . $_POST['title'] . "',";
         $value .= "`describe`='" . $describe . "',";
         $value .= "`lastupdate`='" . $time . "',";
         if (!$_POST['keyword']) {
             require LIB_PATH . "lib_splitword_class.php";
             $sp = new SplitWord();
             $keywordarr = $sp->getkeyword(strip_tags($content));
             $value .= "`keyword`='" . @implode(",", $keywordarr) . "',";
         } else {
             $value .= "`keyword`='" . $_POST['keyword'] . "',";
         }
         $value .= "`description`='" . $_POST['description'] . "'";
         $nbid = $this->obj->DB_update_all("news_base", $value, "`id`='" . $_POST['id'] . "'");
         $row = $this->obj->DB_select_once('news_content', "`nbid`='" . $_POST['id'] . "'", "nbid");
         if (is_array($row)) {
             $cont = $this->obj->DB_update_all("news_content", "`content`='" . $content . "'", "`nbid`='" . $_POST['id'] . "'");
         } else {
             $cont = $this->obj->DB_insert_once("news_content", "`nbid`='" . $_POST['id'] . "',`content`='" . $content . "'");
         }
         $this->autohtml($_POST['id'], $news_base['datetime']);
         isset($nbid) ? $this->ACT_layer_msg("新闻(ID:" . $_POST['id'] . ")更新成功!", 9, Url('admin_news', null, 'admin'), 2, 1) : ${$this}->ACT_layer_msg("更新失败!", 8, Url('admin_news', null, 'admin'));
     }
     if ($_POST['newsadd']) {
         if ($_POST['uplocadpic']) {
             $upload = $this->upload_pic("../data/upload/news/");
             if (file_exists('..' . $_POST['uplocadpic'])) {
                 $uplocadpic = $upload->picture('..' . $_POST['uplocadpic'], false, 1);
                 $s_thumb = $upload->news_makeThumb($uplocadpic, 120, 120, '_S_');
                 $value .= "`newsphoto`='" . str_replace("../data/upload/new", "data/upload/new", $uplocadpic) . "',";
                 $value .= "`s_thumb`='" . str_replace("../data/upload/new", "data/upload/new", $s_thumb) . "',";
             } else {
                 $s_thumb = $upload->news_makeThumb('..' . $_POST['uplocadpic'], 120, 120, '_S_');
                 $value .= "`newsphoto`='" . str_replace("/config/", "config/", $_POST['uplocadpic']) . "',";
                 $value .= "`s_thumb`='" . str_replace("../config/", "config/", $s_thumb) . "',";
             }
             unlink_pic('..' . $_POST['uplocadpic']);
         }
         $content = str_replace(array("&amp;", "background-color:#ffffff", "background-color:#fff", "white-space:nowrap;"), array("&", '', '', ""), html_entity_decode($_POST["content"], ENT_QUOTES, "GB2312"));
         $describe = @implode(",", $_POST['describe']);
         $time = time();
         if ($_POST['sort'] != '') {
             $value .= "`sort`='" . $_POST['sort'] . "',";
         } else {
             $value .= "`sort`='0',";
         }
         if (empty($_POST['did'])) {
             $_POST['did'] = 0;
         }
         $value .= "`did`='" . $_POST['did'] . "',";
         $value .= "`color`='" . $_POST['color'] . "',";
         $value .= "`nid`='" . $_POST['nid'] . "',";
         $value .= "`author`='" . $_POST['author'] . "',";
         $value .= "`source`='" . $_POST['source'] . "',";
         $value .= "`title`='" . $_POST['title'] . "',";
         $value .= "`datetime`='" . $time . "',";
         $value .= "`lastupdate`='" . $time . "',";
         $value .= "`describe`='" . $describe . "',";
         if (!$_POST["keyword"]) {
             require LIB_PATH . "lib_splitword_class.php";
             $sp = new SplitWord();
             $keywordarr = $sp->getkeyword(strip_tags($content));
             $value .= "`keyword`='" . @implode(",", $keywordarr) . "',";
         } else {
//.........这里部分代码省略.........
开发者ID:justinyaoqi,项目名称:qyhr,代码行数:101,代码来源:admin_news.class.php

示例6: splitWord

 /**
  * 拆分字符串
  * @param $string 要拆分的字符
  * @param string $source_charset 输入字符的字符编码
  * @param string $target_charset 输出字符的字符编码
  * @param bool $load_all
  * @param string $source
  * @return array 拆分后的字符以数组形式返回,键名为字符,键值为字符数量
  */
 public static function splitWord($string, $source_charset = 'utf-8', $target_charset = 'utf-8', $load_all = TRUE, $source = '')
 {
     require_cache(HDPHP_EXTEND_PATH . '/Org/SplitWord/SplitWord.class.php');
     $words = SplitWord::splitWord($string, $source_charset = 'utf-8', $target_charset = 'utf-8', $load_all = TRUE, $source = '');
     //按词频从大向小排序
     if (is_array($words)) {
         array_multisort($words, SORT_DESC);
     }
     return $words;
 }
开发者ID:jyht,项目名称:v5,代码行数:19,代码来源:String.class.php

示例7: splitWord

 /**
  * 拆分字符串
  * @param $string 要拆分的字符
  * @param string $source_charset 输入字符的字符编码
  * @param string $target_charset 输出字符的字符编码
  * @param bool $load_all
  * @param string $source
  * @return array 拆分后的字符以数组形式返回,键名为字符,键值为字符数量
  */
 public static function splitWord($string, $source_charset = 'utf-8', $target_charset = 'utf-8', $load_all = TRUE, $source = '')
 {
     require_cache(HDPHP_EXTEND_PATH . '/Org/SplitWord/SplitWord.class.php');
     return SplitWord::splitWord($string, $source_charset = 'utf-8', $target_charset = 'utf-8', $load_all = TRUE, $source = '');
 }
开发者ID:sxau-web-team,项目名称:wish-web,代码行数:14,代码来源:String.class.php

示例8: q

 function q($wd, $domain = '')
 {
     global $db;
     $this->db =& $db;
     $this->wd = $wd;
     require "../include/splitword.func.php";
     $sp = new SplitWord();
     $wd_split = $sp->SplitRMM($wd);
     $sp->Clear();
     $this->wd_split = $wd_split = ereg_replace("[ ]{1,}", " ", trim($wd_split));
     $this->wd_array = $wd_array = explode(" ", $wd_split);
     $this->wd_count = $wd_count = count($wd_split);
     //echo $wd_count;
     $tgarray = $this->GetTg();
     $tgarray_count = count($tgarray);
     $ordersql = " order by  links.tuiguang desc,(";
     foreach ($wd_array as $value) {
         $ordersql .= "(case when links.title like '%" . $value . "%' then 1 else 0 end)+";
     }
     $ordersql .= "(case when links.title like '%" . $wd . "%' then 8 else 0 end)";
     // $ordersql=rtrim($ordersql,"+");
     $ordersql .= ") desc";
     $keywordsql = $this->GetKeywordSql("links.title,' ',links.url,' ',links.keywords");
     if (empty($keywordsql)) {
         $keywordsql = "links.title like '%" . $wd . "%'";
     }
     if (empty($domain)) {
         $sql = "select links.*,sites.qp from kuaso_links links left join kuaso_sites sites on links.site_id=sites.site_id where links.title<>'' and " . $keywordsql . $ordersql;
     } else {
         if ($domain == getdomain($domain)) {
             $sql = "select * from kuaso_links where title<>'' and url like '%." . $domain . "%' or url like '%//" . $domain . "%'";
             //echo $sql;
         } else {
             $sql = "select * from kuaso_links where title<>'' and url regexp 'http://" . $domain . "'";
             //echo $sql;
         }
     }
     //echo $sql;
     $query = $db->query($sql);
     $this->total = $total = $db->num_rows($query) + $tgarray_count;
     $pagesize = 10;
     $this->totalpage = $totalpage = ceil($total / $pagesize);
     $p = intval($_GET["p"]);
     if ($p <= 0) {
         $p = 1;
     }
     $offset = ($p - 1) * $pagesize;
     $query = $db->query($sql . " limit {$offset},{$pagesize}");
     while ($row = $db->fetch_array($query)) {
         $data["title"] = $this->GetRedKeyWord(str_cut($row["title"], 60));
         $data["txt"] = $this->GetRedKeyWord(str_cut($row["fulltxt"], 250));
         $data["url"] = str_cut($row["url"], 50);
         $data["updatetime"] = date("Y-m-d", $row["updatetime"]);
         $data["pagesize"] = $row["pagesize"];
         $data["link_id"] = $row["link_id"];
         $data["tuiguang"] = $row["tuiguang"];
         $array[] = $data;
     }
     $array_count = count($array);
     if (empty($array_count)) {
         $newarray = $tgarray;
     } elseif ($p == 1 && $tgarray_count > 0) {
         $newarray = array_merge($tgarray, $array);
     } else {
         $newarray = $array;
     }
     return $newarray;
 }
开发者ID:dalinhuang,项目名称:shopexts,代码行数:68,代码来源:search.class.php

示例9: SplitWord

 //获取记录,并分析关键字
 if ($totalnum > $startdd + $pagesize) {
     $limitSql = " limit {$startdd},{$pagesize}";
 } else {
     if ($totalnum - $startdd > 0) {
         $limitSql = " limit {$startdd}," . ($totalnum - $startdd);
     } else {
         $limitSql = '';
     }
 }
 $tjnum = $startdd;
 if ($limitSql != '') {
     $fquery = "Select arc.id,arc.title,arc.keywords,addon.body From `#@__archives` arc\r\n\t          left join `#@__addonarticle` addon on addon.aid=arc.id where arc.channel='1' {$limitSql} ";
     $dsql->SetQuery($fquery);
     $dsql->Execute();
     $sp = new SplitWord();
     while ($row = $dsql->GetObject()) {
         if ($row->keywords != '') {
             continue;
         }
         $tjnum++;
         $id = $row->id;
         $keywords = "";
         if ($cfg_soft_lang == 'utf-8') {
             $row->title = utf82gb($row->title);
             $row->body = utf82gb($row->body);
         }
         $titleindexs = explode(' ', trim($sp->GetIndexText($row->title)));
         $allindexs = explode(' ', trim($sp->GetIndexText(Html2Text($row->body), 500)));
         if (is_array($allindexs) && is_array($titleindexs)) {
             foreach ($titleindexs as $k) {
开发者ID:klr2003,项目名称:sourceread,代码行数:31,代码来源:article_keywords_make.php

示例10: 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

示例11: MakeArt

     $artUrl = MakeArt($aid, true, true);
     $backurl = !empty($_COOKIE['ENV_GOBACK_URL']) ? $_COOKIE['ENV_GOBACK_URL'] : '-1';
     ShowMsg('成功更新一篇文档的基本信息!', $backurl);
     exit;
 } else {
     if ($dopost == "makekw") {
         include_once DEDEINC . '/splitword.class.php';
         CheckPurview('a_Commend,sys_ArcBatch');
         if (!empty($aid) && empty($qstr)) {
             $qstr = $aid;
         }
         if ($qstr == '') {
             ShowMsg("参数无效!", $ENV_GOBACK_URL);
             exit;
         }
         $sp = new SplitWord();
         $arcids = ereg_replace('[^0-9,]', '', ereg_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);
             if ($cfg_soft_lang == 'utf-8') {
开发者ID:klr2003,项目名称:sourceread,代码行数:31,代码来源:archives_do.php

示例12: SplitWord

 //获取记录,并分析关键字
 if ($totalnum > $startdd + $pagesize) {
     $limitSql = " LIMIT {$startdd},{$pagesize}";
 } else {
     if ($totalnum - $startdd > 0) {
         $limitSql = " LIMIT {$startdd}," . ($totalnum - $startdd);
     } else {
         $limitSql = '';
     }
 }
 $tjnum = $startdd;
 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();
开发者ID:hensonvip,项目名称:ymroad,代码行数:31,代码来源:article_keywords_make.php

示例13: AnalyseHtmlBody

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) {
        $basehost = "http://" . $_SERVER['HTTP_HOST'];
        $body = str_replace($cfg_basehost, '#basehost#', $body);
        $body = str_replace($basehost, '#2basehost2#', $body);
        $body = preg_replace("/(<a[ \t\r\n]{1,}href=[\"']{0,}http:\\/\\/[^\\/]([^>]*)>)|(<\\/a>)/isU", "", $body);
        $body = str_replace('#basehost#', $cfg_basehost, $body);
        $body = str_replace('#2basehost2#', $basehost, $body);
    }
    //自动摘要
    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;
        if ($cfg_soft_lang == 'utf-8') {
            $subject = utf82gb($title);
            $message = utf82gb($message);
        }
        include_once DEDEINC . '/splitword.class.php';
        $keywords = '';
        $sp = new SplitWord();
        $titleindexs = explode(' ', preg_replace("/#p#|#e#/", '', $sp->GetIndexText($subject)));
        $allindexs = explode(' ', preg_replace("/#p#|#e#/", '', $sp->GetIndexText(Html2Text($message), 500)));
        if (is_array($allindexs) && is_array($titleindexs)) {
            foreach ($titleindexs as $k) {
                if (strlen($keywords . $k) >= 60) {
                    break;
                } else {
                    $keywords .= $k . ',';
                }
            }
            foreach ($allindexs as $k) {
                if (strlen($keywords . $k) >= 60) {
                    break;
                } else {
                    if (!in_array($k, $titleindexs)) {
                        $keywords .= $k . ',';
                    }
                }
            }
        }
        $sp->Clear();
        $sp = null;
    }
    $body = GetFieldValueA($body, $dtype, $id);
    $body = addslashes($body);
    return $body;
}
开发者ID:klr2003,项目名称:sourceread,代码行数:66,代码来源:inc_archives_functions.php

示例14: SplitWord

/**
 * [SplitWord 分词]
 * @param [type] $str [description]
 */
function SplitWord($str)
{
    vendor('SplitWord/SplitWord');
    $split = new SplitWord();
    $data = $split->SplitRMM($str);
    p($data);
    $split->Clear();
    return $data;
}
开发者ID:js-wei,项目名称:Wechat,代码行数:13,代码来源:function.php

示例15: addnews_action

 function addnews_action()
 {
     include "locoy_config.php";
     if ($locoyinfo['locoy_online'] != 1) {
         echo 4;
         die;
     }
     if ($locoyinfo['locoy_key'] != trim($_GET['key'])) {
         echo 5;
         die;
     }
     if (!$_POST['title'] || !$_POST['content'] || !$_POST['nid']) {
         echo 2;
         die;
     }
     $row = $this->obj->DB_select_once("news_base", "`title`='" . trim($_POST['title']) . "' and `nid`='" . $_POST['nid'] . "'");
     if (is_array($row)) {
         echo 3;
         die;
     }
     $value = "";
     $value .= "`title`='" . trim($_POST['title']) . "',";
     $value .= "`nid`='" . $_POST['nid'] . "',";
     $value .= "`author`='" . $_POST['author'] . "',";
     $value .= "`description`='" . $_POST['description'] . "',";
     $value .= "`source`='" . $_POST['source'] . "'";
     if ($_POST['ctime']) {
         $value .= ",`datetime`='" . strtotime($_POST['ctime']) . "'";
     } else {
         $value .= ",`datetime`='" . time() . "'";
     }
     if ($_POST['hits']) {
         $value .= ",`hits`='" . trim($_POST['hits']) . "'";
     } else {
         $row = explode('-', $locoyinfo['locoy_rand']);
         if (is_array($row)) {
             $rand = rand(trim($row[0]), trim($row[1]));
         } else {
             $rand = !trim($row) ? 0 : $row;
         }
         $value .= ",`hits`='" . $rand . "'";
     }
     if ($_POST['sort']) {
         $value .= ",`sort`='" . trim($_POST['sort']) . "'";
     } else {
         $row = explode('-', $locoyinfo['locoy_sort']);
         if (is_array($row)) {
             $rand = rand(trim($row[0]), trim($row[1]));
         } else {
             $rand = !trim($row) ? 0 : $row;
         }
         $value .= ",`sort`='" . $rand . "'";
     }
     if ($_POST['newsphoto']) {
         $value .= ",`newsphoto`='" . trim($_POST['newsphoto']) . "'";
     }
     if ($_POST['s_thumb']) {
         $value .= ",`s_thumb`='" . trim($_POST['s_thumb']) . "'";
     }
     $content = $_POST['content'];
     if (!$_POST['keyword'] && $locoyinfo['locoy_keyword'] == 1) {
         require APP_PATH . "/include/lib_splitword_class.php";
         $sp = new SplitWord();
         $keywordarr = $sp->getkeyword(strip_tags($content));
         $value .= ",`keyword`='" . @implode(",", $keywordarr) . "'";
     } elseif ($_POST['keyword']) {
         $value .= ",`keyword`='" . str_replace(",", ",", $_POST['keyword']) . "'";
     }
     $new_base = $this->obj->DB_insert_once("news_base", $value);
     $news_content = $this->obj->DB_insert_once("news_content", "`nbid`='{$new_base}',`content`='{$content}'");
     if ($new_base) {
         echo 1;
         die;
     } else {
         echo 0;
         die;
     }
 }
开发者ID:keyu199314,项目名称:php,代码行数:78,代码来源:news.class.php


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