Metadata-Version: 2.4
Name: spamfilter
Version: 3.0.0
Summary: Create spam filtering and mitigation pipelines with ease using fully-customizable, object oriented components.
Project-URL: GitHub, https://github.com/mags0ft/spamfilter
Project-URL: Homepage, https://mags0ft.github.io/spamfilter/
Author-email: Magnus Schlinsog <magnusschlinsog@gmail.com>
License: Copyright 2023-2025 Magnus Schlinsog <magnusschlinsog@gmail.com> and GitHub contributors.
        
        Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
License-File: LICENSE
Keywords: anti spam,classification,spam,spam filter,spam mitigation,spam protection
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.9
Provides-Extra: api
Requires-Dist: requests; extra == 'api'
Provides-Extra: dev
Requires-Dist: mkdocs; extra == 'dev'
Requires-Dist: mkdocs-material; extra == 'dev'
Requires-Dist: mkdocstrings[python]; extra == 'dev'
Requires-Dist: pip-tools; extra == 'dev'
Requires-Dist: pylint; extra == 'dev'
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: python-dotenv; extra == 'dev'
Provides-Extra: docs
Requires-Dist: mkdocs; extra == 'docs'
Requires-Dist: mkdocs-material; extra == 'docs'
Requires-Dist: mkdocstrings[python]; extra == 'docs'
Provides-Extra: openai
Requires-Dist: openai; extra == 'openai'
Provides-Extra: transformers
Requires-Dist: torch; extra == 'transformers'
Requires-Dist: transformers; extra == 'transformers'
Description-Content-Type: text/markdown

<p align="center">
    <img src="https://raw.githubusercontent.com/mags0ft/spamfilter/master/docs/assets/icon-white-box.png" alt="Spamfilter logo" width=350>
</p>

<h1 align="center">spamfilter</h1>

<p align="center">
    <img alt="PyPI - Downloads" src="https://img.shields.io/pypi/dm/spamfilter?style=for-the-badge&logo=pypi&labelColor=%231e1e1e" />
    <img alt="GitHub Actions Workflow Status" src="https://img.shields.io/github/actions/workflow/status/mags0ft/spamfilter/python-package.yml?style=for-the-badge&logo=python&labelColor=%231e1e1e" />
    <img alt="PyPI - License" src="https://img.shields.io/pypi/l/spamfilter?style=for-the-badge&labelColor=%231e1e1e" />
</p>

`spamfilter` is a lightweight, fast and straightforward Python library that helps you to build your own [spam filtering pipelines](https://mags0ft.github.io/spamfilter/pipelines/) in order to keep your applications featuring user-generated content clean.

It's object-oriented and makes a quick, concise approach to remove spam easy. `spamfilter` is highly configurable and ships with deep integrations for [third-party APIs](https://mags0ft.github.io/spamfilter/filters/#spamfilter.filters.API), 🤗 Transformers [AI/ML text classifiers](https://mags0ft.github.io/spamfilter/filters/#spamfilter.filters.MLTextClassifier) and language models via [OpenAI](https://mags0ft.github.io/spamfilter/filters/#spamfilter.filters.OpenAI).

---

**Important links**
- [Website and documentation](https://mags0ft.github.io/spamfilter/)
- [Report a security vulnerability](https://github.com/mags0ft/spamfilter/security/advisories/new)
- [Create a new issue](https://github.com/mags0ft/spamfilter/issues/new/choose)
- [How to contribute](https://mags0ft.github.io/spamfilter/contributing/)

## Installation

You can [install spamfilter](https://mags0ft.github.io/spamfilter/installation/) by cloning the GitHub repository, downloading it from the GitHub page or using pip - which is the recommended approach:

```bash
pip install spamfilter
```

Please see the [installation guide](https://mags0ft.github.io/spamfilter/installation/) for more information and methods on how to install `spamfilter` and its dependencies, especially if you plan to use API or machine learning functionality as this requires additional dependencies.

## Usage

The most basic primer into the `spamfilter` library is defining a [pipeline](https://mags0ft.github.io/spamfilter/pipelines/) using several [filters](https://mags0ft.github.io/spamfilter/filters/) stacked on top of each other.

```python
from spamfilter.filters import Length, SpecialChars
from spamfilter.pipelines import Pipeline

# create a new pipeline
m = Pipeline([
    # length of 10 to 200 chars, crop if needed
    Length(min_=10, max_=200, mode="crop"),
    # limit use of special characters
    SpecialChars(mode="normal")
])

# test a string against it
TEST_STRING = "This is a test string."
print(m.check(TEST_STRING).passed)
```

Output:

```
True
```

## License

This project is published under the [MIT License](./LICENSE).

## Contributing

Feel free to contribute to the project using the GitHub repository. Additions to the spam filters, pipelines and documentation are always welcome!

Learn more [here](https://mags0ft.github.io/spamfilter/contributing/) if you're interested in helping out!
