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

Update vietnamese dictionary profane #49

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .phpunit.result.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":1,"defects":{"LaravelProfaneTests\\DictionaryTest::test_word_from_only_vi_files":3,"LaravelProfaneTests\\ProfaneValidatorTest::test_can_validate_a_word_in_vietnamese":3,"LaravelProfaneTests\\StrTest::test_remove_accents_in_vietnamese":3},"times":{"LaravelProfaneTests\\DictionaryTest::test_words_from_only_one_locale":0.021,"LaravelProfaneTests\\DictionaryTest::test_words_from_only_one_file":0.001,"LaravelProfaneTests\\DictionaryTest::test_words_from_locale_array":0.001,"LaravelProfaneTests\\DictionaryTest::test_words_from_file_array":0.001,"LaravelProfaneTests\\ProfaneValidatorTest::test_can_validate_a_word_with_numbers":0.003,"LaravelProfaneTests\\ProfaneValidatorTest::test_can_not_validate_a_word_with_numbers_in_strict_mode":0.004,"LaravelProfaneTests\\ProfaneValidatorTest::test_can_validate_a_text":0.003,"LaravelProfaneTests\\ProfaneValidatorTest::test_can_evaluate_profanity_of_a_word":0.001,"LaravelProfaneTests\\ProfaneValidatorTest::test_can_evaluate_profanity_of_a_sentence":0.001,"LaravelProfaneTests\\ProfaneValidatorTest::test_can_evaluate_profanity_of_a_sentence_in_strict_mode":0.001,"LaravelProfaneTests\\ProfaneValidatorTest::test_can_evaluate_profanity_of_a_html_string":0.001,"LaravelProfaneTests\\ProfaneValidatorTest::test_can_evaluate_as_caseless_mode":0,"LaravelProfaneTests\\ProfaneValidatorTest::test_match_content":0.001,"LaravelProfaneTests\\ProfaneValidatorTest::test_match_exact_word_in_strict_mode":0.004,"LaravelProfaneTests\\ProfaneValidatorTest::test_can_validate_a_bad_word_with_accent":0.001,"LaravelProfaneTests\\ProfaneValidatorTest::test_enie_in_spanish_is_evaluated":0,"LaravelProfaneTests\\ProfaneValidatorTest::test_can_validate_a_word_in_greek":0.002,"LaravelProfaneTests\\ProfaneValidatorTest::test_can_validate_a_text_in_greek":0.002,"LaravelProfaneTests\\ProfaneValidatorTest::test_can_validate_a_word_in_french":0.002,"LaravelProfaneTests\\ProfaneValidatorTest::test_can_validate_a_word_in_french_canadian":0.001,"LaravelProfaneTests\\StrTest::test_string_contains_a_piece_insensitive_match_from_text":0,"LaravelProfaneTests\\StrTest::test_text_contains_insensitive_match_from_array":0,"LaravelProfaneTests\\StrTest::test_text_contains_insensitive_match_from_string":0,"LaravelProfaneTests\\StrTest::test_text_does_not_contain_match_in_strict_mode":0,"LaravelProfaneTests\\StrTest::test_text_contains_match_in_strict_mode":0,"LaravelProfaneTests\\StrTest::test_text_contains_match_in_not_strict_mode":0,"LaravelProfaneTests\\StrTest::test_text_contains_the_same_insensitive_match_from_string":0,"LaravelProfaneTests\\StrTest::test_remove_accents_in_spanish_text":0,"LaravelProfaneTests\\StrTest::test_enie_char_is_allowed":0,"LaravelProfaneTests\\StrTest::test_remove_accents_in_greek":0,"LaravelProfaneTests\\DictionaryTest::test_word_from_only_vi_files":0,"LaravelProfaneTests\\ProfaneValidatorTest::test_can_validate_a_word_in_vietnamese":0,"LaravelProfaneTests\\StrTest::test_remove_accents_in_vietnamese":0,"LaravelProfaneTests\\StrTest::test_text_contains_sensitive_match_from_string_in_vietnamese":0}}
25 changes: 25 additions & 0 deletions src/dict/vi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

return [
'con cạc',
'đỉ chó',
'đỉ mẹ',
'má mày',
'đủ má',
'đỉ lồn',
'thằng đỉ',
'cc',
'chó má',
'thằng lồn',
'đụ mẹ',
'mẹ mày',
'đỉ mẹ mày',
'cặc lồn',
'lồn mẹ',
'đủy mẹ',
'thằng lờ',
'đỉ má',
'lồn chó',
'nứng lồn',
'cặc lồn'
];
5 changes: 5 additions & 0 deletions src/lang/vi/validation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

return [
'profane' => 'Trường :attribute có từ thô tục'
];
7 changes: 7 additions & 0 deletions tests/DictionaryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,11 @@ public function test_words_from_file_array()

$this->assertEquals($dictionary->getDictionary(), $expected);
}

public function test_word_from_only_vi_files(){
$dictionary = new Dictionary(__DIR__.'/../src/dict/vi.php');
$expected = include __DIR__.'/../src/dict/vi.php';
$this->assertEquals($dictionary->getDictionary(), $expected);
}

}
11 changes: 11 additions & 0 deletions tests/ProfaneValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,15 @@ public function test_can_validate_a_word_in_french_canadian()

$this->assertFalse($builder->validate(['description', 'Décrisse gros cave', ['en', 'fr-ca']]));
}

public function test_can_validate_a_word_in_vietnamese(){
$this->mockConfigs();

$builder = new ProfaneValidatorBuilder('vi');

$word = 'ê con cạc thằng lồn';

$this->assertTrue($builder->build()->isProfane($word));
}

}
9 changes: 9 additions & 0 deletions tests/StrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,13 @@ public function test_remove_accents_in_greek()
{
$this->assertEquals('μαλακας', Str::removeAccent('μαλάκας'));
}

public function test_remove_accents_in_vietnamese(){
$this->assertEquals('thằng lồn', Str::removeAccent('thằng lồn'));
}

public function test_text_contains_sensitive_match_from_string_in_vietnamese(){
$this->assertTrue(Str::containsCaseless('con đỉ mẹ mày', 'đỉ mẹ mày'));
}

}