定制 lsimul/tyop 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lsimul/tyop

最新稳定版本:0.1.0

Composer 安装命令:

composer require lsimul/tyop

包简介

Solves most of the typos found in the Czech phrases.

README 文档

README

Set of regular expressions trying to fix common mistakes in Czech like

  • Multiple spaces,
  • spaces on incorrect places (befora comma/fullstop, lack of space after comma/fullstop etc.),
  • proper date format,
  • currency formating,
  • conversion from '-' to '–' where necessary,
  • and some more small, but neat fixes.

Installation

composer require lsimul/tyop

Usage

use LSimul\Tyop;

$corrector = new Tyop\Corrector;

$text = 'Ale,ovšem ,tato věc , ta je od 2.12. za 300 ,- Kč .  '

$text = $corrector->normalize($text);
// Ale, ovšem, tato věc, ta je od 2.12. za 300,- Kč.

$text = $corrector->fix($text);
// Ale, ovšem, tato věc, ta je od 2. 12. za 300 Kč.

Corrector has two methods and the idea was to use them in the order normalize -> fix (-> fixDomain)

  • normalize(string $text): string resolves some simple issues with spaces, like lack of them before bracket and so on.
  • fix(string $text): string digs a little bit deeper and it is willing to format dates, currencies by removing/adding different chars than just a whitespace.

Extending

Corrector has two methods which allow one to extend its behaviour:

  • addRule(string $regex, string $replacement): self
    • Adds new rule, basically it just validates regex and stores it.
  • fixDomain(string $text): string
    • Uses all of the new rules on the text.

fixDomain is here to fix some issues which are specific for given text and it cannot be put into the main set of rules (for example aggressively turning lt into l because here it always means liter).

Fixing HTML

Next to Corrector there is also a Bridge\Html, which wraps Corrector and can work on HTML; trimming whitespaces on the end of the paragraph, removing newlines.

<p>
	<em><u>Interval 3.3. - 8.3. 2024   </u></em>
</p>
<p><br></p>

<!-- Will be turned into: -->
<p>
	<em><u>Interval 3. 3. – 8. 3. 2024</u></em>
</p>

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固