ConsoleTVs / Profanity

PHP library to block bad words in a string
MIT License
98 stars 46 forks source link

How can I specify my own wordlists? #6

Open andresrex opened 6 years ago

andresrex commented 6 years ago

I need to do it in Spanish from Mexico and there are a lot of bad words missing. Updating directly the Dictionary is not an option since I am using composer.

ConsoleTVs commented 6 years ago

Sets the dictionary. If string is provided, it will be treated as a path and will try to decode the json contained in the path. If array is provided, it will set the dictionary.

Example dictionary:

[
    {
        "language": "en",
        "word": "bitch"
    },
    {
        "language": "en",
        "word": "fuck"
    }
]

Or you may just contribute to the repo by adding the missing ones...

andresrex commented 6 years ago

Is this what I should do?

Profanity::dictionary($dictionary)->blocker("message")->filter()

andresrex commented 6 years ago

I actually do want to contribute but need to finish this up already. PM me if interested

ConsoleTVs commented 6 years ago

Profanity::blocker("message")->dictionary($dictionary)->filter()

andresrex commented 6 years ago

It is not working :( I am able to get the file content with file_get_contents, but when "json_decode" it returns null. My Dictionary has the same structure thank yours.

andresrex commented 6 years ago

What would be the structure for the array?

$array["es"] = [
"puto", "imbecil"
];

Is it like this? Thanks mate

ConsoleTVs commented 6 years ago

I already told you the structure...

[
    {
        "language": "en",
        "word": "bitch"
    },
    {
        "language": "en",
        "word": "fuck"
    }
]

Anyway, the best way to do it if you're not understanding it, is to contribute to the repo and add them yourself...

add the words here:

https://github.com/ConsoleTVs/Profanity/blob/master/Generator/es

Compile using python3: https://github.com/ConsoleTVs/Profanity/blob/master/Generator/build.py

python build.py

copy output.json to the dictionary folder and rename it to Default.json

Then submit the PR