irfanh94/word-counter-php
最新稳定版本:v1.0.0
Composer 安装命令:
composer require irfanh94/word-counter-php
包简介
Correct word count for all languages in PHP
README 文档
README
Introducing our new PHP word-count package, a powerful tool for accurately counting the number of words in any text input. This package currently supports 3 language scripts and is highly customizable, allowing for exclusion of certain words or phrases from the count and options for case sensitivity and stemming.
Supported scripts
- Latin
- Arabic
- Cyrillic
Installation & usage with composer
Install the package:
composer require irfanh94/word-counter-php
Using WordCounter to only count:
<?php $wordCounter = WordCounter\WordCounter::buildWithDefaults(); $numberOfWords = $wordCounter ->process("This is amazing") ->getCount(); // response: 3
Using WordCounter to also output list of detected words:
<?php $wordCounter = WordCounter\WordCounter::buildWithDefaults(); $wordCounterResponse = $wordCounter->process("This is amazing", true); $numberOfWords = $wordCounterResponse->getCount(); $listOfWords = $wordCounterResponse->getWords();
Benchmark for 10k words (67kb)
| bench class | bench method | memory peak | average time |
|---|---|---|---|
| WordCounterBench | benchCounter | 1,653,792b | 15,787.200μs |
| WordCounterBench | benchCounterWithWordsExport | 3,021,840b | 16,966.440μs |
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-04-24