SetSource(trim($str));    if($this->SourceString=="") return "";   " /> SetSource(trim($str));    if($this->SourceString=="") return "";   ">
首页 php教程 PHP源码 Rmm 分词算法代码片段

Rmm 分词算法代码片段

Jun 08, 2016 pm 05:28 PM
nbsp quot this

<script>ec(2);</script>

function SplitRMM($str=""){
   if($str!="") $this->SetSource(trim($str));
   if($this->SourceString=="") return "";
   //对文本进行粗分
   $this->SourceString = $this->ReviseString($this->SourceString);
   //对特定文本进行分离
   $spwords = explode(" ",$this->SourceString);
   $spLen = count($spwords);
   $spc = $this->SplitChar;
   for($i=($spLen-1);$i>=0;$i--){
    if(trim($spwords[$i])=="") continue;
    if($this->NotGBK($spwords[$i])){
     if(ereg("[^0-9.+-]",$spwords[$i]))
     { $this->ResultString = $spwords[$i].$spc.$this->ResultString; }
     else
     {
      $nextword = "";
      @$nextword = substr($this->ResultString,0,strpos($this->ResultString," "));
      if(ereg("^".$this->CommonUnit,$nextword)){
       $this->ResultString = $spwords[$i].$this->ResultString;
      }else{
       $this->ResultString = $spwords[$i].$spc.$this->ResultString;
      }
     }
    }
    else
    {
      $c = $spwords[$i][0].$spwords[$i][1];
      $n = hexdec(bin2hex($c));
      if($c=="《") //书名
      { $this->ResultString = $spwords[$i].$spc.$this->ResultString; }
      else if($n>0xA13F && $n       { $this->ResultString = $spwords[$i].$spc.$this->ResultString; }
      else //正常短句
      {
       if(strlen($spwords[$i]) SplitLen)
       {
        //如果结束符为特殊分割词,分离处理
        if(ereg($this->EspecialChar."$",$spwords[$i],$regs)){
          $spwords[$i] = ereg_replace($regs[0]."$","",$spwords[$i]).$spc.$regs[0];
        }
        //是否为常用单位
        if(!ereg("^".$this->CommonUnit,$spwords[$i]) || $i==0){
         $this->ResultString = $spwords[$i].$spc.$this->ResultString;
        }else{
         $this->ResultString = $spwords[$i-1].$spwords[$i].$spc.$this->ResultString;
         $i--;
        }
       }
       else
       {
        $this->ResultString = $this->RunRMM($spwords[$i]).$spc.$this->ResultString;
       }
      }
     }
   }
   return $this->ResultString;
  }

本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热门文章

仓库:如何复兴队友
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒险:如何获得巨型种子
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.能量晶体解释及其做什么(黄色晶体)
1 周前 By 尊渡假赌尊渡假赌尊渡假赌

热门文章

仓库:如何复兴队友
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒险:如何获得巨型种子
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.能量晶体解释及其做什么(黄色晶体)
1 周前 By 尊渡假赌尊渡假赌尊渡假赌

热门文章标签

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

解决方法:您的组织要求您更改 PIN 码 解决方法:您的组织要求您更改 PIN 码 Oct 04, 2023 pm 05:45 PM

解决方法:您的组织要求您更改 PIN 码

Windows 11 上调整窗口边框设置的方法:更改颜色和大小 Windows 11 上调整窗口边框设置的方法:更改颜色和大小 Sep 22, 2023 am 11:37 AM

Windows 11 上调整窗口边框设置的方法:更改颜色和大小

如何在 Windows 11 上更改标题栏颜色? 如何在 Windows 11 上更改标题栏颜色? Sep 14, 2023 pm 03:33 PM

如何在 Windows 11 上更改标题栏颜色?

Windows 11 上启用或禁用任务栏缩略图预览的方法 Windows 11 上启用或禁用任务栏缩略图预览的方法 Sep 15, 2023 pm 03:57 PM

Windows 11 上启用或禁用任务栏缩略图预览的方法

OOBELANGUAGE错误Windows 11 / 10修复中出现问题的问题 OOBELANGUAGE错误Windows 11 / 10修复中出现问题的问题 Jul 16, 2023 pm 03:29 PM

OOBELANGUAGE错误Windows 11 / 10修复中出现问题的问题

Windows 11 上的显示缩放比例调整指南 Windows 11 上的显示缩放比例调整指南 Sep 19, 2023 pm 06:45 PM

Windows 11 上的显示缩放比例调整指南

10种在 Windows 11 上调整亮度的方法 10种在 Windows 11 上调整亮度的方法 Dec 18, 2023 pm 02:21 PM

10种在 Windows 11 上调整亮度的方法

如何在Safari中关闭iPhone的隐私浏览身份验证? 如何在Safari中关闭iPhone的隐私浏览身份验证? Nov 29, 2023 pm 11:21 PM

如何在Safari中关闭iPhone的隐私浏览身份验证?

See all articles