Giter VIP home page Giter VIP logo

copywriting-correct's Introduction

copywriting-correct

中英文文案排版纠正器。

项目地址 https://github.com/ricoa/copywriting-correct 演示地址 https://copywriting-correct.ricoo.top

描述

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

比较以下排版:

  • 排版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进行的。');

注入自己的纠正器

继承 \Ricoa\CopyWritingCorrect\Correctors\Corrector,并实现 handle 方法。例如 ExampleCorrector.php

<?php

class ExampleCorrector extends \Ricoa\CopyWritingCorrect\Correctors\Corrector {

    protected static $corrector=null;

    /**
     * @param string $text
     *
     * @return mixed
     */
    public function handle($text)
    {
        return $text;
    }
}

使用:

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

use Ricoa\CopyWritingCorrect\CopyWritingCorrectService;

$service=new CopyWritingCorrectService();

$service->addCorrectors([ExampleCorrector::class]);//注入纠正器
$service->resetCorrectors([ExampleCorrector::class]);//重置纠正器,也即废弃默认的纠正器

$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', '-', ' ', '/',
	'%', '#', '@', '&', '<',
	'>', '[', ']', '{', '}',
	'\\','|', '+', '=', '_',
	'^', '~', '`'
];

名词

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

未实现

全角和半角

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

改进

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

License

基于 MIT license.

copywriting-correct's People

Contributors

ricoa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

copywriting-correct's Issues

反馈一个小问题

这是一段(测试)文字

如上,处理包含左右括号的文字的话,返回的结果是左括号为半角,右括号为全角,希望您有时间可以修复一下。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.