alfreddagenais/php-word-count-utf8

PHP实现的UTF-8文本词频统计

1.0.2 2020-07-11 19:51 UTC

This package is auto-updated.

Last update: 2024-09-07 03:13:43 UTC


README

build Love Open Source Stars Forks Issues License Visitors Tweet

简单的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)

贡献

如果你愿意,那将非常感谢你 😍🔥

  1. PSR-2 🎅.
  2. 使用PHP Formatter 格式化代码 .
  3. 编写测试 🐛.
  4. 向我发送PR ✉️.
  5. 😬 🦄

测试

composer test./vendor/bin/phpunit tests

💵 支持

如果你觉得这个项目有帮助,或者从源代码中学到了一些东西,想要感谢我,考虑给我买一杯 ☕

Donate

待办事项

  1. 检查是否将 &(和号)视为单词 🤔
  • Google文档:
  • 在线单词计数器:
  • Microsoft Word:

🐛 缺陷或请求

如果你遇到任何问题,请随意打开一个问题。如果你觉得这个库缺少某个功能,请请在GitHub上提出一个问题,我会查看。也欢迎Pull request。

许可

GNU GPLv3

在哪里找到我?