Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inserting Persian And Arabic dictionary and Getting the badwords #2

Open
vahid-vahid opened this issue Jun 5, 2017 · 5 comments
Open

Comments

@vahid-vahid
Copy link

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

@vahid-vahid
Copy link
Author

@ConsoleTVs
This is The Way I solved it
The problem was strtolower does not work on MultiByte characters
So I used the method mb_stripos(and is_Numeric to find if it returned something other than false):

public function badWords() { return collect($this->dictionary)->filter(function ($value) { return is_numeric(mb_stripos($this->text, $value['word'])); })->map(function ($value) { return [ 'language' => $value['language'], 'word' => $value['word'], ]; })->toArray(); }

@ConsoleTVs
Copy link
Owner

Hello @v01061374 Does this solution work with other languages?

If so, I would recommend you to make a pull request, so we can all benefit ^^

@vahid-vahid
Copy link
Author

Yes it works

@vahid-vahid
Copy link
Author

The only change I made is what i mentioned before

@ConsoleTVs
Copy link
Owner

Feel free to make a pull request :p

ConsoleTVs added a commit that referenced this issue Sep 20, 2019
fix issue #7 and #2 add feature requested in #4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants