<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php 
	// 英文预处理：中文标点 换英文，标点后加空格，替换特殊符号
	session_start(); 
	require_once('inc/conn.php');
	require_once('inc/constant.php');
	require_once('inc/ls_syscode.php');
	require_once('inc/check.php');
	require('inc/conn_var.php');
	$ls_msg="";
	
	$opendb=new mydb();
	require_once('inc/char_set.php');
 
	$punctuation = array(
	',' => "，",
	'...' => "。。。",   
	'.' => "。",
	';' => "；",    
	':' => "：",    
	')' => "）",    
	'?' => "？",    
	'!' => "！",   
	);         
	$content="A bonus of up to 5 per  。 cent can：   be added？ to;a student’ s final ！ exam （mark） as a:reward for good spelling .   punctuation and grammar。";
	
	foreach($punctuation as $key => $value){
		$content = str_replace($value, $key, $content);
		$content=str_replace( $key."    ",$key,$content); // 标点3空格
		$content=str_replace( $key."   ",$key,$content); // 标点3空格
		$content=str_replace( $key."  ",$key,$content); // 标点2空格
		$content=str_replace( $key." ",$key,$content); // 标点1空格
		$content=str_replace( "   ".$key,$key,$content); // 标点3空格
		$content=str_replace( "  ".$key,$key,$content); // 标点2空格
		$content=str_replace( " ".$key,$key,$content); // 标点1空格
		$content=str_replace( $key,$key." ",$content); // 换回
	}
	$content=str_replace( "’", "'",$content); // 单引号
	$content=str_replace("'  ","'",$content); // 换回
	$content=str_replace("' ","'",$content); // 换回
	$content=str_replace("'","''",$content); // 换成2'

	$content=str_replace( "（", "(",$content); // 单引号
	$content=str_replace("   (","(",$content); // 换回
	$content=str_replace("  (","(",$content); // 换回
	$content=str_replace(" (","(",$content); // 换回
	$content=str_replace("("," (",$content); // 换回

	$transstr=str_replace("¿" ,"",$transstr); 
	//echo $content;
	// 整句首字母大选
	$strlen=strlen($content);
	$fullstop=array('.','?','!'); // 其后需要首字母大写的标点
	foreach($fullstop as  $value){
		$thisstr=($newstr==""?$content:$newstr);
		$newstr="";
		while(1){
			$dotpos=strpos($thisstr,$value);
			//echo $value.var_dump($dotpos)."++";
			$substr1=rtrim(substr($thisstr,0,$dotpos+3));
			if($substr1=="") break;
			$laststr=substr($substr1,-2,1);
			//echo $substr1."==".$value." >>".$laststr."<< <br/>";
			if($laststr==" "){ //如果 句号带空格，则大写 下一个字母
				$upletter=strtoupper(substr($substr1,-1,1));
				$substr1=substr($substr1,0,$dotpos+2).$upletter;
			}
			$newstr.=	$substr1;
			$thisstr=substr($thisstr,$dotpos+3,$strlen); //去除前一句
		}
	}
	 $content=$newstr;

echo $content;
 	


?>
<title>无标题文档</title>
</head>

<body>
</body>
</html>