cooldfa


Namecooldfa JSON
Version 1.1.1 PyPI version JSON
download
home_pageNone
Summary基于 DFA 算法的敏感词检测器
upload_time2023-11-27 09:43:53
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseNone
keywords cooldfa dfa
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 项目描述

基于 DFA 算法的敏感词检测器。

# 作者信息

昵称:lcctoor.com

[主页](https://lcctoor.github.io/arts/) \| [微信](https://lcctoor.github.io/arts/arts/static/static-files/WeChatQRC.jpg) \| [Github](https://github.com/lcctoor) \| [PyPi](https://pypi.org/user/lcctoor) \| [Python交流群](https://lcctoor.github.io/arts/arts/static/static-files/PythonWeChatGroupQRC.jpg) \| [邮箱](mailto:lcctoor@outlook.com) \| [域名](http://lcctoor.com) \| [捐赠](https://lcctoor.github.io/arts/arts/static/static-files/DonationQRC-0rmb.jpg)

# Bug提交、功能提议

您可以通过 [Github-Issues](https://github.com/lcctoor/arts/issues)、[微信](https://lcctoor.github.io/arts/arts/static/static-files/WeChatQRC.jpg) 与我联系。

# 安装

```
pip install cooldfa
```

# 教程 ([查看美化版](https://lcctoor.github.io/arts/?pk=cooldfa)👈)

### 导入

```python
from cooldfa import DFA
```

### 创建dfa模型

```python
敏感词S = ['123', '234', '56', 'end']
example = DFA(*敏感词S)
```

### 检测是否含有敏感词

```python
example.has_any('1--2--3--4--5--6--7--8--9--end--')
# >>> True
```

### 查找第1个敏感词

```python
example.find_one('1--2--3--4--5--6--7--8--9--end--')
# >>> '1--2--3'
```

### 查找所有敏感词

```python
example.find_all('1--2--3--4--5--6--7--8--9--end--')
# >>> ['1--2--3', '5--6', 'end']
```

### 替换所有敏感词

```python
example.sub('1--2--3--4--5--6--7--8--9--end--', '*')
# >>> '*******--4--****--7--8--9--***--'

example.sub('1--2--3--4--5--6--7--8--9--end--', '*', compress=True)
# >>> '*--4--*--7--8--9--*--'
```

### 使用内置的敏感词库

```python
from cooldfa import DFA, preset_words

example = DFA(
    *preset_words.politics,  # 政治类
    *preset_words.sex,  # 色情类
    *preset_words.violence,  # 暴力类
    *preset_words.url,  # 网址
    *preset_words.others,  # 其它
    *['123', '234', '56', 'end']
)
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "cooldfa",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "cooldfa,dfa",
    "author": null,
    "author_email": "\"lcctoor.com\" <lcctoor@outlook.com>",
    "download_url": "https://files.pythonhosted.org/packages/0c/3b/b91da153a2fc41e6e32ba6114fa099d51b3c8fd7710f59f5abf0e1668907/cooldfa-1.1.1.tar.gz",
    "platform": null,
    "description": "# \u9879\u76ee\u63cf\u8ff0\n\n\u57fa\u4e8e DFA \u7b97\u6cd5\u7684\u654f\u611f\u8bcd\u68c0\u6d4b\u5668\u3002\n\n# \u4f5c\u8005\u4fe1\u606f\n\n\u6635\u79f0\uff1alcctoor.com\n\n[\u4e3b\u9875](https://lcctoor.github.io/arts/) \\| [\u5fae\u4fe1](https://lcctoor.github.io/arts/arts/static/static-files/WeChatQRC.jpg) \\| [Github](https://github.com/lcctoor) \\| [PyPi](https://pypi.org/user/lcctoor) \\| [Python\u4ea4\u6d41\u7fa4](https://lcctoor.github.io/arts/arts/static/static-files/PythonWeChatGroupQRC.jpg) \\| [\u90ae\u7bb1](mailto:lcctoor@outlook.com) \\| [\u57df\u540d](http://lcctoor.com) \\| [\u6350\u8d60](https://lcctoor.github.io/arts/arts/static/static-files/DonationQRC-0rmb.jpg)\n\n# Bug\u63d0\u4ea4\u3001\u529f\u80fd\u63d0\u8bae\n\n\u60a8\u53ef\u4ee5\u901a\u8fc7 [Github-Issues](https://github.com/lcctoor/arts/issues)\u3001[\u5fae\u4fe1](https://lcctoor.github.io/arts/arts/static/static-files/WeChatQRC.jpg) \u4e0e\u6211\u8054\u7cfb\u3002\n\n# \u5b89\u88c5\n\n```\npip install cooldfa\n```\n\n# \u6559\u7a0b ([\u67e5\u770b\u7f8e\u5316\u7248](https://lcctoor.github.io/arts/?pk=cooldfa)\ud83d\udc48)\n\n### \u5bfc\u5165\n\n```python\nfrom cooldfa import DFA\n```\n\n### \u521b\u5efadfa\u6a21\u578b\n\n```python\n\u654f\u611f\u8bcdS = ['123', '234', '56', 'end']\nexample = DFA(*\u654f\u611f\u8bcdS)\n```\n\n### \u68c0\u6d4b\u662f\u5426\u542b\u6709\u654f\u611f\u8bcd\n\n```python\nexample.has_any('1--2--3--4--5--6--7--8--9--end--')\n# >>> True\n```\n\n### \u67e5\u627e\u7b2c1\u4e2a\u654f\u611f\u8bcd\n\n```python\nexample.find_one('1--2--3--4--5--6--7--8--9--end--')\n# >>> '1--2--3'\n```\n\n### \u67e5\u627e\u6240\u6709\u654f\u611f\u8bcd\n\n```python\nexample.find_all('1--2--3--4--5--6--7--8--9--end--')\n# >>> ['1--2--3', '5--6', 'end']\n```\n\n### \u66ff\u6362\u6240\u6709\u654f\u611f\u8bcd\n\n```python\nexample.sub('1--2--3--4--5--6--7--8--9--end--', '*')\n# >>> '*******--4--****--7--8--9--***--'\n\nexample.sub('1--2--3--4--5--6--7--8--9--end--', '*', compress=True)\n# >>> '*--4--*--7--8--9--*--'\n```\n\n### \u4f7f\u7528\u5185\u7f6e\u7684\u654f\u611f\u8bcd\u5e93\n\n```python\nfrom cooldfa import DFA, preset_words\n\nexample = DFA(\n    *preset_words.politics,  # \u653f\u6cbb\u7c7b\n    *preset_words.sex,  # \u8272\u60c5\u7c7b\n    *preset_words.violence,  # \u66b4\u529b\u7c7b\n    *preset_words.url,  # \u7f51\u5740\n    *preset_words.others,  # \u5176\u5b83\n    *['123', '234', '56', 'end']\n)\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "\u57fa\u4e8e DFA \u7b97\u6cd5\u7684\u654f\u611f\u8bcd\u68c0\u6d4b\u5668",
    "version": "1.1.1",
    "project_urls": {
        "HomePage": "https://github.com/lcctoor/arts/tree/main/arts/dfa"
    },
    "split_keywords": [
        "cooldfa",
        "dfa"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "38ceb4ce3887f9243b98e392e864c26a38ec266b114172e7a9b00daf7029a9a5",
                "md5": "3f3a683a3fe85c15ff9ae8ccefc22a01",
                "sha256": "e8208e1d7e2cc8744e81c8151f8618255fe4f7effa7433057518c852e1ed118e"
            },
            "downloads": -1,
            "filename": "cooldfa-1.1.1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3f3a683a3fe85c15ff9ae8ccefc22a01",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 253294,
            "upload_time": "2023-11-27T09:43:49",
            "upload_time_iso_8601": "2023-11-27T09:43:49.764053Z",
            "url": "https://files.pythonhosted.org/packages/38/ce/b4ce3887f9243b98e392e864c26a38ec266b114172e7a9b00daf7029a9a5/cooldfa-1.1.1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "0c3bb91da153a2fc41e6e32ba6114fa099d51b3c8fd7710f59f5abf0e1668907",
                "md5": "ab165cf93bb6ec2c1c8bbce2d2586c09",
                "sha256": "434c9f5aa1dc673322e913362ce089ec459083efd0327c3f205a104f95f5444a"
            },
            "downloads": -1,
            "filename": "cooldfa-1.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "ab165cf93bb6ec2c1c8bbce2d2586c09",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 245421,
            "upload_time": "2023-11-27T09:43:53",
            "upload_time_iso_8601": "2023-11-27T09:43:53.235181Z",
            "url": "https://files.pythonhosted.org/packages/0c/3b/b91da153a2fc41e6e32ba6114fa099d51b3c8fd7710f59f5abf0e1668907/cooldfa-1.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-27 09:43:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lcctoor",
    "github_project": "arts",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "cooldfa"
}
        
Elapsed time: 0.25094s