中文文案排版纠正器

项目地址 https://github.com/ricoa/copywriting-corre...

描述

统一中文文案、排版的相关用法,降低团队成员之间的沟通成本,增强网站气质。

比较以下排版:

  • 排版1

    LeanCloud数据存储是围绕AVObject进行的.每个AVObject都包含了与JSON兼容的key-value对应的数据。数据是schema-free的,你不需要在每个AVObject上提前指定存在哪些键,只要直接设定对应的key-value即可。
    gitHub是一个通过git进行版本控制的软件源代码托管服务,由GitHub公司(曾称Logical Awesome)的开发者Chris Wanstrath、PJ Hyett和Tom Preston-Werner使用Ruby on Rails编写而成。

  • 排版2

    LeanCloud 数据存储是围绕 AVObject 进行的。每个 AVObject 都包含了与 JSON 兼容的 key-value 对应的数据。数据是 schema-free 的,你不需要在每个 AVObject 上提前指定存在哪些键,只要直接设定对应的 key-value 即可。
    GitHub 是一个通过 Git 进行版本控制的软件源代码托管服务,由 GitHub 公司(曾称 Logical Awesome)的开发者 Chris Wanstrath、PJ Hyett 和 Tom Preston-Werner 使用 Ruby on Rails 编写而成。

很明显,第二种排版中英文有空格,标点符号也使用正确,专有名词使用正确,会让人看起来更舒服,也更专业。
本系统正是基于 中文文案排版指北(简体中文版) 进行纠正,帮助解决中英文混排的排版问题。

安装

//安装开发中版本
composer require ricoa/copywriting-correct:dev-master

使用

<?php
require_once 'vendor/autoload.php';

use Ricoa\CopyWritingCorrect\CopyWritingCorrectService;

$service=new CopyWritingCorrectService();

$text=$service->correct('在LeanCloud上,数据存储是围绕AVObject进行的。');

已实现

空格

  1. 中文字符与半角字符(例如英文字符,数字,英文标点符号)间添加空格。
  2. 数字后面跟着英文字符则在数字后添加空格(适用于数字+单位,例如 1 GB)。
  3. 全角标点与其他字符之间不加空格
  4. 希腊字母与中文字符以及数字和英文字符之间添加空格(不在指北内)。

标点符号

  1. 不重复使用中文标点符号(仅!和?),重复时只保留第一个。

全角和半角

  1. 中文后使用全角中文标点符号(包括!?。,():;)。
  2. 数字使用半角字符。
  3. 全角转半角(不在指北内)。
    [
    '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', '-', ' ', '/',
    '%', '#', '@', '&', '<',
    '>', '[', ']', '{', '}',
    '\\','|', '+', '=', '_',
    '^', '~', '`'
    ];

    名词

  4. 专有名词使用正确的大小写(部分名词达成,见 词典

未实现

全角和半角

  1. 遇到完整的英文整句、特殊名词,其內容使用半角标点

改进

有什么新的想法和建议,欢迎提交 issue 或者 Pull Requests

本作品采用《CC 协议》,转载必须注明作者和本文链接
X先生
本帖由 Summer 于 3年前 加精
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
讨论数量: 7
Destiny

:+1:

3年前 评论
in CharacterCorrector.php line 40
at HandleExceptions->handleError(8, 'Undefined index: \'', '/data/wwwroot/copywriting-correct.ricoo.top/vendor/ricoa/copywriting-correct/src/Correctors/CharacterCorrector.php', 40, array('m' => array('份\'', '份', '\''), 'replace' => array('!' => '!', '?' => '?', '.' => '。', ',' => ',', '(' => '(', ')' => ')', ':' => ':', ';' => ';'))) in CharacterCorrector.php line 40
at CharacterCorrector->Ricoa\CopyWritingCorrect\Correctors\{closure}(array('份\'', '份', '\''))
at preg_replace_callback('/([\\p{Han}])([!?\\.,\\(\\):;\'\\"])/iu', object(Closure), '234234 手機號科y ‘技時代合法的身份\'\'334534') in CharacterCorrector.php line 41
at CharacterCorrector->handle('234234 手機號科y ‘技時代合法的身份\'\'334534') in CopyWritingCorrectService.php line 25
at CopyWritingCorrectService->correct('234234 手機號科y ‘技時代合法的身份\'\'334534') in CorrectorController.php line 15
at CorrectorController->correct(object(Request), object(CopyWritingCorrectService))
at call_user_func_array(array(object(CorrectorController), 'correct'), array(object(Request), object(CopyWritingCorrectService))) in Controller.php line 55
at Controller->callAction('correct', array(object(Request), object(CopyWritingCorrectService))) in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(CorrectorController), 'correct') in Route.php line 203
at Route->runController() in Route.php line 160
at Route->run() in Router.php line 559
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 30
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41
at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 65
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Router.php line 561
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 520
at Router->dispatchToRoute(object(Request)) in Router.php line 498
at Router->dispatch(object(Request)) in Kernel.php line 174
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 30
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in TransformsRequest.php line 30
at TransformsRequest->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in TransformsRequest.php line 30
at TransformsRequest->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ValidatePostSize.php line 27
at ValidatePostSize->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Kernel.php line 149
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116
at Kernel->handle(object(Request)) in index.php line 53
3年前 评论

@waney 已更正,谢谢指出

3年前 评论

如果用来格式化的文本是markdown语法写的,纠正排版时会不会影响到markdown语法?

3年前 评论

正好需要 用上了

6个月前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!