lsimul/tyop
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): stringresolves some simple issues with spaces, like lack of them before bracket and so on.fix(string $text): stringdigs 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>
lsimul/tyop 适用场景与选型建议
lsimul/tyop 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 2, 最近一次更新时间为 2024 年 08 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 lsimul/tyop 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 lsimul/tyop 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-08-07