Profanity icon indicating copy to clipboard operation
Profanity copied to clipboard

How can I specify my own wordlists?

Open andresrex opened this issue 7 years ago • 7 comments

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.

andresrex avatar Feb 21 '18 21:02 andresrex

  • dictionary($dictionary)

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...

ConsoleTVs avatar Feb 21 '18 22:02 ConsoleTVs

Is this what I should do?

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

andresrex avatar Feb 22 '18 18:02 andresrex

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

andresrex avatar Feb 22 '18 19:02 andresrex

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

ConsoleTVs avatar Feb 22 '18 19:02 ConsoleTVs

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 avatar Feb 23 '18 01:02 andresrex

What would be the structure for the array?

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

Is it like this? Thanks mate

andresrex avatar Feb 23 '18 01:02 andresrex

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

ConsoleTVs avatar Feb 23 '18 09:02 ConsoleTVs