apie/count-words

apie库的Composer包:计算单词

dev-main 2023-08-29 13:29 UTC

This package is auto-updated.

Last update: 2024-09-16 14:58:39 UTC


README

count-words

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require Code coverage

PHP Composer

此包是Apie库的一部分。代码维护在单体仓库中,所以PR需要发送到单体仓库

文档

这个小包包含一个类,用于在文本中计算单词。所有单词都返回为小写。

使用方法

use Apie\CountWords\WordCounter;

var_dump(WordCounter::countFromString('This is the text with many words like the or and'));

这将回显

array(10) {
  ["this"]=>
  int(1)
  ["is"]=>
  int(1)
  ["the"]=>
  int(2)
  ["text"]=>
  int(1)
  ["with"]=>
  int(1)
  ["many"]=>
  int(1)
  ["words"]=>
  int(1)
  ["like"]=>
  int(1)
  ["or"]=>
  int(1)
  ["and"]=>
  int(1)
}