Skip to content

Commit 70a8191

Browse files
committed
feat: created a better readme.md
1 parent 24cb6c3 commit 70a8191

File tree

1 file changed

+83
-7
lines changed

1 file changed

+83
-7
lines changed

README.md

Lines changed: 83 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,89 @@
1-
# Profanity PHP
1+
# Profanity PHP 🚀
22

3-
[![CodeFactor](https://www.codefactor.io/repository/github/friendshipking/profanity_php/badge)](https://www.codefactor.io/repository/github/friendshipking/profanity_php)
3+
[![CodeFactor](https://www.codefactor.io/repository/github/friendshipking/profanity_php/badge?style=for-the-badge)](https://www.codefactor.io/repository/github/friendshipking/profanity_php)
4+
![GitHub License](https://img.shields.io/github/license/friendshipking/profanity_php?style=for-the-badge&color=blue)
5+
![GitHub Repo stars](https://img.shields.io/github/stars/friendshipking/profanity_php?style=for-the-badge&logo=github)
46

5-
Selfishly made for my own use. Open Sourcing it to receive - `what an ugly code!` compliment every once in a while.
7+
Welcome to Profanity PHP, the vibrant library designed to keep your text sparkling clean! 🌟 This lightweight and efficient tool is your go-to solution for detecting profanity in text using a comprehensive list of naughty words from [List of Dirty, Naughty, Obscene, and Otherwise Bad Words](https://github.com/LDNOOBW/List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words.git).
68

7-
Has some cool functions though.
9+
## Table of Contents 📜
810

9-
Uses [List of Dirty, Naughty, Obscene, and Otherwise Bad Words](https://github.com/LDNOOBW/List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words.git)
11+
- [Features](#features)
12+
- [Getting Started](#getting-started)
13+
- [Prerequisites](#prerequisites)
14+
- [Installation](#installation)
15+
- [Usage](#usage)
16+
- [Function](#function)
17+
- [Global Variables](#global-variables)
18+
- [Contribution](#contribution)
19+
- [License](#license)
1020

11-
Take a look around the code and try to figure out what it does LOL.
21+
## Features 🌈
1222

13-
Have a NOICE day!
23+
1. Detect profane words in a string using a comprehensive list of profane words as a Hash Table.
24+
2. Uncover naughty phrases in a string using a comprehensive list of profane phrases. This uses the Boyer-Moore algorithm to find phrases, treating each word as a character.
25+
26+
## Getting Started 🚀
27+
28+
These instructions will help you set up the library in your project.
29+
30+
### Prerequisites 🛠️
31+
32+
Ensure you have the following installed:
33+
34+
- PHP 7.4 or higher
35+
- Git
36+
37+
### Installation 🚚
38+
39+
1. Clone the repository or add it as a submodule to your project.
40+
41+
```sh
42+
git clone https://github.com/friendshipking/profanity_php.git
43+
# OR
44+
git submodule add https://github.com/friendshipking/profanity_php.git
45+
```
46+
47+
2. Follow these instructions if there is a new commit in the [List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words_V2](https://github.com/LDNOOBWV2/List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words_V2.git):
48+
49+
- Run the [step_1.php](https://github.com/friendshipking/profanity_php/blob/main/build/step_1.php) to create the `languages` directory and files.
50+
- Run the [step_2.php](https://github.com/friendshipking/profanity_php/blob/main/build/step_2.php) to create the `countryToSupportedLanguageCodes` array.
51+
- Run the [step_3.php](https://github.com/friendshipking/profanity_php/blob/main/build/step_3.php) to list all the three-letter codes that are not added to the `countryToSupportedLanguageCodes` array. If there is no output, you are good to go. Otherwise:
52+
- Use the AI prompt inside [three_letter_codes.php](https://github.com/friendshipking/profanity_php/blob/main/build/three_letter_codes.php) file to generate the array. Replace the existing array in the file. If Bing is unable to get the language, use this [link](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) to get the language code. After adding the array, run [step_2.php](https://github.com/friendshipking/profanity_php/blob/main/build/step_2.php) again.
53+
- All required files are successfully generated.
54+
- Test the setup by running the [test.php](https://github.com/friendshipking/profanity_php/blob/main/test.php) file.
55+
- Commit the changes and create a pull request to the main repo. This ensures that the library is up to date with the latest changes in [List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words_V2](https://github.com/LDNOOBWV2/List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words_V2.git).
56+
57+
## Usage 🛠️
58+
59+
Include the library in your project and let the magic begin! 🧙 Refer to the code comments for detailed information on each function.
60+
61+
```php
62+
include 'profanity_php/main.php';
63+
```
64+
65+
### Function ⚙️
66+
67+
#### `isProfanity(&$text, $detectedLanguages = [], &$exploded = [], &$explodedLength = 0, $all = false): bool`
68+
69+
Check if a string contains profanity.
70+
71+
- `$text`: The string to check. Optional, If not provided, then $exploded must be provided.
72+
- `$detectedLanguages`: An array of detected languages. Optional. Languages are automatically detected based on the user's country (using HTTP_CF_IPCOUNTRY header from Cloudflare) , ACCEPT_LANGUAGE header if this is not set.
73+
- `$exploded`: The exploded and cleaned string to remove punctuations and emojis. Optional. If you are already creating an exploded string, pass it to the function to avoid creating it again. If not provided, then $text must be provided.
74+
- `$explodedLength`: The length of the exploded string. Optional. Must be provided if $exploded is provided.
75+
- `$all`: If true, check for all available languages. Optional. When set, all the languages are checked for profanity. If false, only the languages in `$detectedLanguages` or auto-detected languages are checked.
76+
77+
### Global Variables 🌐
78+
79+
When you include this file, the following global variables are available:
80+
81+
1. `$supportedLanguages`: After the function `isProfanity()` is called, it will contain all the language the profanity in the text was checked for.
82+
83+
### Contribution 🤝
84+
85+
Join the community and contribute to the project by submitting issues or pull requests. Your positivity and contributions are always welcome! 🎉
86+
87+
## License 📜
88+
89+
This project is licensed under the [Creative Commons Zero v1.0 Universal](LICENSE.md) - see the [LICENSE](LICENSE.md) file for details.

0 commit comments

Comments
 (0)