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.
谢谢!
大德们,哪位有这种算法,请共享一下。或者我们一起讨论一下也可以。就是将一篇英文文章以句为单位切分。
例如:
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.
谢谢!
解决方案 »
- 服务器LINUX有时会出现“域名无法解析”的现象
- 关于php和serv-u的问题,希望高手帮忙!
- 学习STMP发送邮件时形成了一个认识--认为fsockopen/fwrite/fread读写的指令可以通过都可以直接在telnet中使用,请大家看看这段代码
- PHP官方站点也有中文版的手册了
- 紧急求助,求用几个控件来连接数据库实现增删改查。
- 一个SQL语句和获取客户端信息问题??
- 本人想做一个在校模拟考试系统有接的吗?
- 为什么PHP的图书都那么贵?
- ajaxfileupload.js这个上传文件的插件谁用过啊 我第一次用 为什么不对啊
- 关于PHP调用打印机问题
- 求php下拉框代码?
- PHp怎么获取网络传过来的xml文件
<?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);
?>
$list = explode(". ", $t);
print_r($list);
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.
如果还要忽略特殊的字符,就用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);
}