PHPackages                             taoran/filter-word - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. taoran/filter-word

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

taoran/filter-word
==================

PHP敏感词过滤

v1.0.3(4y ago)1501MITPHPPHP &gt;=7.2

Since Mar 16Pushed 4y ago1 watchersCompare

[ Source](https://github.com/taoran1401/filter-word)[ Packagist](https://packagist.org/packages/taoran/filter-word)[ RSS](/packages/taoran-filter-word/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (5)Used By (0)

非法词/敏感词过滤
---------

[](#非法词敏感词过滤)

非法词/敏感词过滤是网站必不可少的功能，一般通过正则和字符串函数来计算和判断，效率比较慢；所以我们必须减少计算量来提高效率，而DFA算法中几乎没有计算量，有的只是状态转移；

功能
--

[](#功能)

- 词库和节点树管理功能
- 判断是否有敏感词(暂时只有判断是否有敏感词，没有替换功能，有需求再加)

使用方式
----

[](#使用方式)

判断敏感词：

```
$filter = new Filter();
$filter->dict->setDictFile(BASE_PATH . '/public/dict/', 'dict.php');
$result = $filter->filter($text);    //return bool: true 表示有敏感词

```

词库管理：

```
$dict = new Dict();
//设置词库文件两个参数： 路径和文件
$dict->setDictFile(BASE_PATH . '/public/dict/', 'dict.php');
// 添加词汇
$addResult = $dict->add(['词汇一', '词汇二', '词汇五']);
// 删除词汇
$delResult = $dict->destroy(['词汇一']);
// 获取词库内容
$dictContent = $dict->getDictContent();
// 获取词库节点树
$dictDFAContent = $dict->getDictDFAContent();

```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

1522d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/698e7e4a16333353987ded991b1ebb4ff60b993f4d41939ade6f038d60193118?d=identicon)[taoran1401](/maintainers/taoran1401)

---

Top Contributors

[![naroat](https://avatars.githubusercontent.com/u/22391562?v=4)](https://github.com/naroat "naroat (9 commits)")

---

Tags

dfa

### Embed Badge

![Health badge](/badges/taoran-filter-word/health.svg)

```
[![Health](https://phpackages.com/badges/taoran-filter-word/health.svg)](https://phpackages.com/packages/taoran-filter-word)
```

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
