alfreddagenais / php-word-count-utf8
PHP实现的UTF-8文本词频统计
1.0.2
2020-07-11 19:51 UTC
Requires
- php: ^7.2
- ext-intl: *
Requires (Dev)
- phpunit/phpunit: ^8.2
This package is auto-updated.
Last update: 2024-09-07 03:13:43 UTC
README
简单的PHP实现UTF-8文本词频统计。受sylae/word-count启发 😗。
🙌 使用方法
composer require alfreddagenais/php-word-count-utf8
<?php use AlfredDagenais\WordCountUtf8; // Example 1 $text = "This string has five words!"; $count = WordCountUtf8::getWordCount($text); // int(5) $count = WordCountUtf8::getCharacterCount($text); // int(27) $count = WordCountUtf8::getCharacterWithoutSpaceCount($text); // int(23) // Example 2 $text = "When you don't create things, you become defined by your tastes rather than ability. your tastes only narrow and exclude people. so create."; $count = WordCountUtf8::getWordCount($text); // int(23) $count = WordCountUtf8::getCharacterCount($text); // int(139) $count = WordCountUtf8::getCharacterWithoutSpaceCount($text); // int(117) // Example 3 $text = "Un langage qui n'affecte pas votre manière de penser la programmation ne vaut pas la peine d'être connu."; $count = WordCountUtf8::getWordCount($text); // int(18) $count = WordCountUtf8::getCharacterCount($text); // int(104) $count = WordCountUtf8::getCharacterWithoutSpaceCount($text); // int(87)
贡献
如果你愿意,那将非常感谢你 😍🔥
- PSR-2 🎅.
- 使用PHP Formatter 格式化代码 .
- 编写测试 🐛.
- 向我发送PR ✉️.
- 😬 🦄
测试
composer test
或 ./vendor/bin/phpunit tests
💵 支持
如果你觉得这个项目有帮助,或者从源代码中学到了一些东西,想要感谢我,考虑给我买一杯 ☕
待办事项
- 检查是否将
&
(和号)视为单词 🤔
- Google文档:
否
- 在线单词计数器:
是
- Microsoft Word:
是
🐛 缺陷或请求
如果你遇到任何问题,请随意打开一个问题。如果你觉得这个库缺少某个功能,请请在GitHub上提出一个问题,我会查看。也欢迎Pull request。
许可
GNU GPLv3