PHP code example of naux / auto-correct
1. Go to this page and download the library: Download naux/auto-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/ */
naux / auto-correct example snippets
use Naux\AutoCorrect;
$correct = new AutoCorrect;
// 在中英文之间加入合理的空格
$correct->auto_space("php是世界上最好的语言,之一"); // php 是世界上最好的语言,之一
// 纠正专用词汇大小写
$correct->auto_correct("php是世界上最好的语言,之一"); // PHP是世界上最好的语言,之一
// 加入空格并纠正词汇(auto_space + auto_correct)
$correct->convert("php是世界上最好的语言,之一"); // PHP 是世界上最好的语言,之一
//添加外置词典,可添加多个
echo $auto
->withDict(['hello world' => 'Hello World'])
->withDict(['foo bar' => 'Foo Bar'])
->convert('hello world, foo bar, phphub'); // Hello World, Foo Bar, PHPHub