Code Monkey home page Code Monkey logo

profanity's Issues

Inserting Persian And Arabic dictionary and Getting the badwords

Hi again
I want to insert an array of Persian and Arabic dictionary array and get the badwords

The text cleanness is discovered correctly but the badwords function returns unknown characters

$bad = Profanity::blocker('فحش است')->dictionary([['language' => 'fa' , 'word' => 'فحش' ]])->badWords();

returns
array (size=1) 0 => array (size=2) 'language' => string 'fa' (length=2) 'word' => string '������' (length=6)

Please help me with this problem
Thank you

Filtering a specific language

Hi

I don't think this is possible, but would like to suggest an option to set a specific language when filtering.
For instance, if I want to filter Portuguese word only, I would pass the pt to the blocker or filter: blocker($words, $lang) or filter( $lang).
If $lang is not set, all words should be used.

Thanks

PHP 8.1 exception with illuminate/support 5.4.36

The badWords() function throws an exception in PHP 8.1

public function badWords()
    {
       // exception thrown here:
       return collect($this->dictionary)->filter(function ($value) {
          
        })->toArray();
    }

ErrorException: Return type of Illuminate\Support\Collection::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

I tried to update illuminate/contracts and illuminate/support to v 8.78 but get this issue:

Problem 1
- illuminate/support v5.4.36 requires illuminate/contracts 5.4.* -> found illuminate/contracts[v5.4.0, ..., 5.4.x-dev] but it conflicts with your root composer.json require (^8.78).
- consoletvs/profanity 3.1.0 requires illuminate/support 5.4.|5.5.|5.6.|5.7.|5.8.|6.|7.|8. -> satisfiable by illuminate/support[v5.4.36].
- consoletvs/profanity is locked to version 3.1.0 and an update of this package was not requested.

Wrong detection

Hi. for example we have string like this:

$value = '<p><span style="color: rgb(246,139,106);">Lauren J.</span>, Hi</p>';

In this case 139 will be replaced as *** because:

Profanity::blocker(trim($value))->badWords() detects the bad word:

Array
(
    [2261] => Array
        (
            [language] => zh
            [word] => 13.
        )
)

Is it possible to fix? as '139' != '13.'

New feature requested: matching not just a single word

Supposed we have a dictionary like this:

[ { "language": "en", "word": "wrapping men" }, { "language": "en", "word": "wrinkled starfish" }, ]

Can we have the badWords() to pick out only these whole strings. For example:

Sentence 1: a men is wrapping gift -> no problem
Sentence 2: a gift is wrapping men -> bad words detected -> Result ["language" => "en", "word" =>"wrapping men"]

Thank you!

How can I specify my own wordlists?

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.

Kashida character problem

hello i am back with another problem from awsome languages persian and arabic :D
here is a wikipedia page that explain this character
https://en.wikipedia.org/wiki/Kashida

this character wont change the meaning of a word and its just using for justification
here is some example

word => Raħīm | meaning => merciful | normal => رحیم | Kashida => رحــیم

the problem is that if someone use a bad word with this character this package can't recognize it as a bad word

production WARNING php 8.1

[2023-02-23 09:11:23] production.WARNING: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in vendor/consoletvs/profanity/Classes/Blocker.php on line 135

Laravel 10 install error

I'm trying to upgrade a Laravel 9 project to Laravel 10. when I install this package I get:

Problem 1
    - consoletvs/profanity[1.0.0, ..., 1.0.2, 2.0.0, ..., 2.0.1] require illuminate/support ^5.4 -> found illuminate/support[v5.4.0, ..., v5.8.36] but these were not loaded, likely because it conflicts with another require.
    - consoletvs/profanity 3.0.0 requires illuminate/support 5.4.*|5.5.*|5.6.*|5.7.*|5.8.*|6.* -> found illuminate/support[v5.4.0, ..., v5.8.36, v6.0.0, ..., v6.20.44] but these were not loaded, likely because it conflicts with another require.
    - consoletvs/profanity 3.0.1 requires illuminate/support 5.4.*|5.5.*|5.6.*|5.7.*|5.8.*|6.*|7.* -> found illuminate/support[v5.4.0, ..., v5.8.36, v6.0.0, ..., v6.20.44, v7.0.0, ..., v7.30.6] but these were not loaded, likely because it conflicts with another require.
    - consoletvs/profanity[3.0.2, ..., 3.1.0] require illuminate/support 5.4.*|5.5.*|5.6.*|5.7.*|5.8.*|6.*|7.*|8.* -> found illuminate/support[v5.4.0, ..., v5.8.36, v6.0.0, ..., v6.20.44, v7.0.0, ..., v7.30.6, v8.0.0, ..., v8.83.27] but these were not loaded, likely because it conflicts with another require.
    - consoletvs/profanity 3.2.0 requires illuminate/support 5.4.*|5.5.*|5.6.*|5.7.*|5.8.*|6.*|7.*|8.*|9.* -> found illuminate/support[v5.4.0, ..., v5.8.36, v6.0.0, ..., v6.20.44, v7.0.0, ..., v7.30.6, v8.0.0, ..., v8.83.27, v9.0.0, ..., v9.52.9] but these were not loaded, likely because it conflicts with another require.
    - Root composer.json requires consoletvs/profanity * -> satisfiable by consoletvs/profanity[1.0.0, 1.0.1, 1.0.2, 2.0.0, 2.0.1, 3.0.0, ..., 3.2.0].

You can also try re-running composer require with an explicit version constraint, e.g. "composer require consoletvs/profanity:*" to figure out if any version is installable, or "composer require consoletvs/profanity:^2.1" if you know which you need.

How do I resolve this?

persian and arabic filter not working

hello
i tested your package and its didnt work with persian language
$bad = Builder::blocker('کیری')->clean();

this code return true that is incorrect taht word is inside your default badwords list here

Whole word matching option

Hi,

Thank you for sharing the code. Is it possible to have whole word only matching option? For example, in my string there is a word "circumstances" and it is picked out by badWords() as "cum" :-( Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.