PHP code example of ricoa / copywriting-correct
1. Go to this page and download the library: Download ricoa/copywriting-correct library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ricoa / copywriting-correct example snippets
Ricoa\CopyWritingCorrect\CopyWritingCorrectService;
$service=new CopyWritingCorrectService();
$text=$service->correct('在LeanCloud上,数据存储是围绕AVObject进行的。');
class ExampleCorrector extends \Ricoa\CopyWritingCorrect\Correctors\Corrector {
protected static $corrector=null;
/**
* @param string $text
*
* @return mixed
*/
public function handle($text)
{
return $text;
}
}
Ricoa\CopyWritingCorrect\CopyWritingCorrectService;
$service=new CopyWritingCorrectService();
$service->addCorrectors([ExampleCorrector::class]);//注入纠正器
$service->resetCorrectors([ExampleCorrector::class]);//重置纠正器,也即废弃默认的纠正器
$text=$service->correct('在LeanCloud上,数据存储是围绕AVObject进行的。');
[
'0' , '1' , '2' , '3' , '4' ,
'5' , '6' , '7' , '8' , '9' ,
'A' , 'B' , 'C' , 'D' , 'E' ,
'F' , 'G' , 'H' , 'I' , 'J' ,
'K' , 'L' , 'M' , 'N' , 'O' ,
'P' , 'Q' , 'R' , 'S' , 'T' ,
'U' , 'V' , 'W' , 'X' , 'Y' ,
'Z' , 'a' , 'b' , 'c' , 'd' ,
'e' , 'f' , 'g' , 'h' , 'i' ,
'j' , 'k' , 'l' , 'm' , 'n' ,
'o' , 'p' , 'q' , 'r' , 's' ,
't' , 'u' , 'v' , 'w' , 'x' ,
'y' , 'z' , '-' , ' ' , '/' ,
'%' , '#' , '@' , '&' , '<' ,
'>' , '[' , ']' , '{' , '}' ,
'\' , '|' , '+' , '=' , '_' ,
'^' , ' ̄' , '`'
];
//转
[
'0', '1', '2', '3', '4',
'5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E',
'F', 'G', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T',
'U', 'V', 'W', 'X', 'Y',
'Z', 'a', 'b', 'c', 'd',
'e', 'f', 'g', 'h', 'i',
'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's',
't', 'u', 'v', 'w', 'x',
'y', 'z', '-', ' ', '/',
'%', '#', '@', '&', '<',
'>', '[', ']', '{', '}',
'\\','|', '+', '=', '_',
'^', '~', '`'
];