Download the PHP package szwsuny/swfilter without Composer

On this page you can find all versions of the php package szwsuny/swfilter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package swfilter

SwFilter - 敏感词过滤 - 关键词取出

Sensitive Word Filtering

这是一个PHP版本的AC自动机,没有啥目的性,就是看到其他语言的实现特别多就做了一个,很简单。 关键词树被缓存在Scope文件夹下,使用前先要建立这个缓存文档。


依赖

* PHP >= 7

效率

在test文件下 add.php 有6000个敏感词汇,你可以直接执行,然后执行 filter.php 平均效率在 0.01秒。(macbook pro i5)


使用方式

* 可以参考test目录
* 过滤/查找 前要先添加关键词缓存。

引入项目

require __DIR__ . '/../vendor/autoload.php'; //注意调整所在目录位置

use SzwSuny\SW\Filter\SwFilter;

声明对象

$swFilter = new SwFilter();

设定范围

$swFilter->setScope('短信类'); //你可以理解为词库的分类,这样你可拥有多个过滤词库,想用哪个用哪个。

添加词

$swFilter->adds($words); //这个批量添加,$words是个词数组
$swFilter->add($word);   //这个就是一个一个加。

保存词库

$swFilter->save(); //添加词完事后一定要保存,才可以使用。

获得匹配到的词

$swFilter->getMatchWords('这个是要匹配的内容或者文章'); //返回匹配到的词数组

过滤掉匹配的词

$result = $swFilter->filter('这个是要匹配的内容或者文章','*'); //最后这个 * 符号,敏感词将会被替换成它,3个字就是 *** 2个字就是 **

版本号说明

xx.xx.0 最后一位为0是正式版
xx.xx.1-99 这种属于测试版本

更新

2019年02月1日 1.1.0
    发布正式版本

2019年02月05日 1.1.3
    替换成ac自动机,修复词汇匹配不到的问题,需要重新生成词库。

2019年02月05日 1.1.4
    又修复了一下bug

2019年02月05日 1.1.5
    新增一个函数,解决长词中包含短词的匹配不到问题,正在考虑是否转为正式使用。使用请看overMatch.php

sunzhiwei 2019-2-1


All versions of swfilter with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package szwsuny/swfilter contains the following files

Loading the files please wait ....