irfanh94 / word-counter-php
支持PHP中所有语言的正确单词计数
v1.0.0
2023-04-24 00:00 UTC
Requires
- php: >=7.4
Requires (Dev)
- mockery/mockery: ^1.5
- phpbench/phpbench: ^1.2
- phpunit/phpunit: >=9.6
This package is auto-updated.
Last update: 2024-09-25 12:17:36 UTC
README
介绍我们的新PHP单词计数包,这是一个强大的工具,用于准确统计任何文本输入中的单词数量。该包目前支持3种语言脚本,并且高度可定制,允许排除某些单词或短语从计数中,以及提供对大小写敏感性和词根选择的选项。
支持的脚本
- 拉丁语
- 阿拉伯语
- 西里尔语
使用composer进行安装和使用
安装包
composer require irfanh94/word-counter-php
使用WordCounter仅进行计数
<?php $wordCounter = WordCounter\WordCounter::buildWithDefaults(); $numberOfWords = $wordCounter ->process("This is amazing") ->getCount(); // response: 3
使用WordCounter同时输出检测到的单词列表
<?php $wordCounter = WordCounter\WordCounter::buildWithDefaults(); $wordCounterResponse = $wordCounter->process("This is amazing", true); $numberOfWords = $wordCounterResponse->getCount(); $listOfWords = $wordCounterResponse->getWords();