# Magic Profanity
`magic_profanity` is a Python library for detecting and censoring profanity in text using customizable word lists and character mappings. It support English and Hinglish
## Installation
You can install `magic_profanity` using pip:
```python
pip install ProfanityFilter
```
## Requirements
- `Python 3+`
## Usage
### Importing the Library
```python
from magic_profanity import ProfanityFilter
```
### Initializing the Profanity Filter
#### Create an instance of MagicProfanity:
```python
profanity_filter = ProfanityFilter()
```
### Loading Custom Words
You can load custom words into the profanity filter either from a list or from a file:
### Load words from a list
```python
profanity_filter.load_words(["badword1", "badword2"])
```
### Load words from a file
```python
profanity_filter.load_words_from_file("path/to/custom_wordlist.txt")
```
### Load Custom Words
Only accepts list, tuple, or set.
```python
profanity_filter.add_custom_words(["badword1", "badword2"])
```
Checking for Profanity
You can check if a text contains profanity using contains_profanity:
```python
text = "This sentence contains a badword1 and a BadWord2."
if profanity_filter.has_profanity(text):
print("Profanity detected!")
else:
print("No profanity found.")
```
### Censoring Text
You can censor profanity in text using censor:
```python
censored_text = profanity_filter.censor_text(text)
print(censored_text)
```
### Adding Custom Words
You can add custom words to the profanity filter:
```python
profanity_filter.add_censor_words(["newbadword1", "newbadword2"])
```
### Custom Character Mappings
You can customize character mappings used for censoring:
```python
profanity_filter.char_map = {
"a": ("a", "@", "*", "4"),
"i": ("i", "*", "l", "1"),
"o": ("o", "*", "0", "@"),
# Add more mappings as needed
}
```
#Contributing
Contributions are welcome! If you have any suggestions, bug reports, or enhancements, please open an issue or a pull request on GitHub.
#License
This project is licensed under the MIT License - see the LICENSE file for details.
Raw data
{
"_id": null,
"home_page": "https://github.com/Kabhishek18/magic_profanity",
"name": "magic-profanity",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "profanity-filter censorship text-processing",
"author": "Kumar Abhishek",
"author_email": "developer@kabhishek18.com",
"download_url": "https://files.pythonhosted.org/packages/3e/32/8c907fbcbdeae79c824860b4e3ac5492190389863e6b8164142afc1c027c/magic_profanity-1.1.1.tar.gz",
"platform": null,
"description": "# Magic Profanity\n\n`magic_profanity` is a Python library for detecting and censoring profanity in text using customizable word lists and character mappings. It support English and Hinglish\n\n## Installation\n\nYou can install `magic_profanity` using pip:\n\n```python\npip install ProfanityFilter\n```\n\n## Requirements\n\n- `Python 3+`\n\n## Usage\n\n### Importing the Library\n\n```python\nfrom magic_profanity import ProfanityFilter\n```\n### Initializing the Profanity Filter\n\n#### Create an instance of MagicProfanity:\n```python\nprofanity_filter = ProfanityFilter()\n```\n\n### Loading Custom Words\nYou can load custom words into the profanity filter either from a list or from a file:\n\n### Load words from a list\n```python\nprofanity_filter.load_words([\"badword1\", \"badword2\"])\n```\n### Load words from a file\n```python\nprofanity_filter.load_words_from_file(\"path/to/custom_wordlist.txt\")\n```\n### Load Custom Words\n Only accepts list, tuple, or set.\n```python\nprofanity_filter.add_custom_words([\"badword1\", \"badword2\"])\n```\n\nChecking for Profanity\nYou can check if a text contains profanity using contains_profanity:\n\n```python\ntext = \"This sentence contains a badword1 and a BadWord2.\"\nif profanity_filter.has_profanity(text):\n print(\"Profanity detected!\")\nelse:\n print(\"No profanity found.\")\n``` \n\n### Censoring Text\nYou can censor profanity in text using censor:\n\n```python \ncensored_text = profanity_filter.censor_text(text)\nprint(censored_text)\n```\n\n### Adding Custom Words\nYou can add custom words to the profanity filter:\n\n```python \nprofanity_filter.add_censor_words([\"newbadword1\", \"newbadword2\"])\n```\n\n### Custom Character Mappings\nYou can customize character mappings used for censoring:\n\n```python\nprofanity_filter.char_map = {\n \"a\": (\"a\", \"@\", \"*\", \"4\"),\n \"i\": (\"i\", \"*\", \"l\", \"1\"),\n \"o\": (\"o\", \"*\", \"0\", \"@\"),\n # Add more mappings as needed\n}\n```\n\n#Contributing\nContributions are welcome! If you have any suggestions, bug reports, or enhancements, please open an issue or a pull request on GitHub.\n\n#License\nThis project is licensed under the MIT License - see the LICENSE file for details.\n\n\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "A Python library for detecting and censoring profanity in text",
"version": "1.1.1",
"project_urls": {
"Homepage": "https://github.com/Kabhishek18/magic_profanity"
},
"split_keywords": [
"profanity-filter",
"censorship",
"text-processing"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "89d5bf5ce8ef76d3bc1b1116fc1102945a5c2968cd022791fd2288462546ebff",
"md5": "eeac213cdf14d45c1a0a29679cf9c869",
"sha256": "105feabc88bb6ff0ddb8ee2806629bca88d32ba1be37bba7730b0d4f203b92a7"
},
"downloads": -1,
"filename": "magic_profanity-1.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "eeac213cdf14d45c1a0a29679cf9c869",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 43356,
"upload_time": "2024-06-21T16:49:26",
"upload_time_iso_8601": "2024-06-21T16:49:26.350803Z",
"url": "https://files.pythonhosted.org/packages/89/d5/bf5ce8ef76d3bc1b1116fc1102945a5c2968cd022791fd2288462546ebff/magic_profanity-1.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3e328c907fbcbdeae79c824860b4e3ac5492190389863e6b8164142afc1c027c",
"md5": "46a842b490c62dccbf99ca58e4893d8e",
"sha256": "e9263b188f32b31338edfdd87ea1c77f10065909efd0c81aa6a93249184f5729"
},
"downloads": -1,
"filename": "magic_profanity-1.1.1.tar.gz",
"has_sig": false,
"md5_digest": "46a842b490c62dccbf99ca58e4893d8e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 26762,
"upload_time": "2024-06-21T16:49:29",
"upload_time_iso_8601": "2024-06-21T16:49:29.193472Z",
"url": "https://files.pythonhosted.org/packages/3e/32/8c907fbcbdeae79c824860b4e3ac5492190389863e6b8164142afc1c027c/magic_profanity-1.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-21 16:49:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Kabhishek18",
"github_project": "magic_profanity",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "magic-profanity"
}