RT.
大德们,哪位有这种算法,请共享一下。或者我们一起讨论一下也可以。就是将一篇英文文章以句为单位切分。
例如:
For the third year in a row, Drupal has been nominated for a Packt Publishing Open Source CMS award. Packt Publishing is announcing winners all week. Today they announced the 2008 best PHP open source CMS.可以拆分为:
For the third year in a row, Drupal has been nominated for a Packt Publishing Open Source CMS award.
Packt Publishing is announcing winners all week.
Today they announced the 2008 best PHP open source CMS.
谢谢!

解决方案 »

  1.   


    <?php
    $s ="For the third year in a row, Drupal has been nominated for a Packt Publishing Open Source CMS award. Packt Publishing is announcing winners all week. Today they announced the 2008 best PHP open source CMS. ";
    $temp =preg_split("/[\?\.\!]\s?/",trim($s));
    array_pop(&$temp);
    var_export($temp);
    ?>
      

  2.   

    $t = "For the third year in a row, Drupal has been nominated for a Packt Publishing Open Source CMS award. Packt Publishing is announcing winners all week. Today they announced the 2008 best PHP open source CMS.";
    $list = explode(". ", $t);
    print_r($list);
      

  3.   

    如果句子中有网址或者小数会产生干扰。PopPhoto.com and Think Tank Photo are offering one lucky reader the chance to win an amazingly versatile set of camera bags that should have you ready for just about any photo adventure you've got planned. All you've got to do is sign up for our weekly newsletter and you're automatically entered for a chance to win the prize package worth $1,146.00!
      

  4.   

    PopPhoto.com and Think Tank Photo are offering one lucky reader the chance to win an amazingly versatile set of camera bags that should have you ready for just about any photo adventure you've got planned. All you've got to do is sign up for our weekly newsletter and you're automatically entered for a chance to win the prize package worth $1,146.00!
      

  5.   

    你该明白英文的写法,因为的标点后应该有一个空格的。例如
    For the third year in a row, Drupal has been nominated for a Packt Publishing Open Source CMS award. Packt Publishing is announcing winners all week. Today they announced the 2008 best PHP open source CMS.
      

  6.   

    解决特殊问题,用特殊办法。
    如果还要忽略特殊的字符,就用special_replace来过滤掉$s ="PopPhoto.com and Think Tank Photo are offering one lucky reader the chance to win an amazingly versatile set of camera bags that should have you ready PopPhoto.com for just about any photo adventure you've got planned. All you've got to do is sign up for our weekly newsletter and you're automatically entered for a chance to win the prize package worth $1,146.00!Welcome to www.new1day.cn.";$special[0] = array();
    $special[1] = array();
    //替换特殊的
    $s = special_replace("/www\.[\w]+\.(com|cn|org)/i",$s);
    $s = special_replace("/\.(com|cn|org)/i",$s);
    $s = special_replace("/[0-9]\.[0-9]/",$s);
    //分句
    $temp =preg_split("/[\?\.\!]\s?/",trim($s));
    array_pop(&$temp);
    //还原每句
    foreach($temp as $k => $v)
    $temp[$k] = special_revert($v);
    print_r($temp);function special_replace($pattern, $str){
    global $special;
    preg_match_all($pattern, $str, $temp);
    if(is_array($temp))
    foreach($temp[0] as $k => $v){
    $special[0][] = $v;
    $special[1][] = $temp2 = "|".md5($v)."|";
    $str = str_replace($v, $temp2, $str);
    }
    return $str;
    }function special_revert($str){
    global $special;
    return str_replace($special[1],$special[0],$str);
    }