Skip to content

Commit 24a2669

Browse files
Merge pull request #19 from Seen-Arabic/development
rename `Panned` to `Banned`
2 parents e8f0d51 + 38fde33 commit 24a2669

7 files changed

Lines changed: 46 additions & 45 deletions

File tree

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ Can be used in Node.js and the browser.
3838
- **Tashkeel Removal**: Easily remove Tashkeel from Arabic text.
3939
- **Tatweel Removal**: Remove Tatweel character from Arabic phrases.
4040
- **Convert To Old Arabic**: Transform Arabic text into old script.
41-
- **Convert To Old Arabic And Tashfeer Panned Words**: Transform Arabic text into old script and replace Panned Arabic text with visually similar characters for encoding purposes. (Panned words are words that considered as hate speech in social media)
41+
- **Convert To Old Arabic And Tashfeer Banned Words**: Transform Arabic text into old script and replace Banned Arabic text with visually similar characters for encoding purposes. (Banned words are words that considered as hate speech in social media)
4242
- **Tashfeer**: Replaces Arabic text with visually similar characters for encoding purposes.
43-
- **Tashfeer Panned Words**: Replaces Panned Arabic text with visually similar characters for encoding purposes. (Panned words are words that considered as hate speech in social media)
43+
- **Tashfeer Banned Words**: Replaces Banned Arabic text with visually similar characters for encoding purposes. (Banned words are words that considered as hate speech in social media)
4444
- **Remove Arabic Affixes**: Removes predefined affixes (prefixes and suffixes) from an Arabic word if it starts or ends with those affixes.
4545
- **Word To Letters**: Convert Arabic word to its pronounced letters.
4646

@@ -111,11 +111,11 @@ console.log(ArabicServices.toOldArabic('الخَيْلُ وَاللّيْلُ و
111111
// Output: 'الحىل واللىل والٮىدا ٮعرڡٮى'
112112
```
113113

114-
### Convert To Old Arabic And Tashfeer Panned Words
114+
### Convert To Old Arabic And Tashfeer Banned Words
115115

116116
```javascript
117117
const { ArabicServices } = require('arabic-services');
118-
console.log(ArabicServices.toOldArabicAndTashfeerPannedWords('جيش العدو يقتل الأطفال'));
118+
console.log(ArabicServices.toOldArabicAndTashfeerBannedWords('جيش العدو يقتل الأطفال'));
119119
// Output: 'چـێـݭ !ڵعـݚۉ ی۪ـڨـټل الاطڡال'
120120
```
121121

@@ -127,11 +127,11 @@ console.log(ArabicServices.tashfeer('هذا النص مشفر'));
127127
// Output: 'هـۮו اڵـݔص مـݭفـݛ'
128128
```
129129

130-
### Tashfeer Panned Words
130+
### Tashfeer Banned Words
131131

132132
```javascript
133133
const { ArabicServices } = require('arabic-services');
134-
console.log(ArabicServices.tashfeerPannedWords('جيش العدو يقتل الأطفال'));
134+
console.log(ArabicServices.tashfeerBannedWords('جيش العدو يقتل الأطفال'));
135135
// Output: 'چـێـݭ !ڵعـݚۉ ی۪ـڨـټل الأطفال'
136136
```
137137

README_AR.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
</a>
55
</div>
66

7-
87
<h1 align=center>خدمات اللغة العربية بلغة جافا سكريبت</h1>
98

109
<p align=center>
@@ -32,6 +31,7 @@
3231
</div>
3332

3433
## 📋 الميزات
34+
3535
- **إزالة التشكيل:** إزالة التشكيل من النص العربي.
3636
- **إزالة التطويل:** إزالة أحرف التطويل غير الضرورية من العبارات العربية.
3737
- **التحويل إلى العربية القديمة:** تحويل النص العربي إلى الخط العربي القديم.
@@ -82,6 +82,7 @@ console.log(ArabicServices.removeTashkeel('الخَيْلُ وَاللّيْلُ
8282
```
8383

8484
## 💻 الاستخدام
85+
8586
### إزالة التشكيل
8687

8788
```javascript
@@ -110,7 +111,7 @@ console.log(ArabicServices.toOldArabic('الخَيْلُ وَاللّيْلُ و
110111

111112
```javascript
112113
const { ArabicServices } = require('arabic-services');
113-
console.log(ArabicServices.toOldArabicAndTashfeerPannedWords('جيش العدو يقتل الأطفال'));
114+
console.log(ArabicServices.toOldArabicAndTashfeerBannedWords('جيش العدو يقتل الأطفال'));
114115
// Output: 'چـێـݭ !ڵعـݚۉ ی۪ـڨـټل الاطڡال'
115116
```
116117

@@ -126,7 +127,7 @@ console.log(ArabicServices.tashfeer('هذا النص مشفر'));
126127

127128
```javascript
128129
const { ArabicServices } = require('arabic-services');
129-
console.log(ArabicServices.tashfeerPannedWords('جيش العدو يقتل الأطفال'));
130+
console.log(ArabicServices.tashfeerBannedWords('جيش العدو يقتل الأطفال'));
130131
// Output: 'چـێـݭ !ڵعـݚۉ ی۪ـڨـټل الأطفال'
131132
```
132133

@@ -149,20 +150,20 @@ console.log(ArabicServices.removeAffixes('المدرسة'));
149150
<br>
150151

151152
## 💡 المساهمة
152-
إذا كنت ترغب في المساهمة في هذا المشروع وتحسينه بأفكار جديدة، فبإمكانك عمل pull request وطلبك مرحب به للغاية. إذا وجدت أي مشكلة، فقط ضعها في قسم الـIssues في المستودع، شكرًا لك.
153-
154-
155153

154+
إذا كنت ترغب في المساهمة في هذا المشروع وتحسينه بأفكار جديدة، فبإمكانك عمل pull request وطلبك مرحب به للغاية. إذا وجدت أي مشكلة، فقط ضعها في قسم الـIssues في المستودع، شكرًا لك.
156155

157156
<div align=center>
158157
<h2>🌟 ضع نجمة على هذا المستودع 🌟</h2>
159158

160159
من فضلك ضع ⭐️ على هذا المستودع وشاركه مع الآخرين
160+
161161
</div>
162162

163163
<br>
164164

165165
## 📜 الرخصة
166+
166167
هذا المشروع مرخص تحت رخصة GPL-3.0. انظر ملف [الرخصة](./LICENSE) لمزيد من التفاصيل.
167168

168169
## 💬 الاتصال

example.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
),
2626
);
2727
console.log(
28-
'toOldArabicAndTashfeerPannedWords:',
29-
ArabicServices.toOldArabicAndTashfeerPannedWords('جيش العدو يقتل الأطفال'),
28+
'toOldArabicAndTashfeerBannedWords:',
29+
ArabicServices.toOldArabicAndTashfeerBannedWords('جيش العدو يقتل الأطفال'),
3030
);
3131
console.log('Tashfeer:', ArabicServices.tashfeer('هذا النص مشفر'));
32-
console.log('tashfeerPannedWords:', ArabicServices.tashfeerPannedWords('جيش العدو يقتل الأطفال'));
32+
console.log('tashfeerBannedWords:', ArabicServices.tashfeerBannedWords('جيش العدو يقتل الأطفال'));
3333
console.log('wordToLetters:', ArabicServices.wordToLetters('شجرة'));
3434
console.log('removeArabicAffixes:', ArabicServices.removeArabicAffixes('موظفين'));
3535

@@ -40,7 +40,7 @@
4040
console.log('PRONOUNCED_LETTERS:', ArabicServices.constants.PRONOUNCED_LETTERS);
4141
console.log('ARABIC_PREFIXES:', ArabicServices.constants.ARABIC_PREFIXES);
4242
console.log('ARABIC_SUFFIXES:', ArabicServices.constants.ARABIC_SUFFIXES);
43-
console.log('PANNED_WORDS:', ArabicServices.constants.PANNED_WORDS);
43+
console.log('BANNED_WORDS:', ArabicServices.constants.BANNED_WORDS);
4444
</script>
4545
</body>
4646
</html>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const PANNED_WORDS = [
1+
export const BANNED_WORDS = [
22
'فلسطين',
33
'عرب',
44
'هود',

src/constants/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ export {
55
PRONOUNCED_LETTERS,
66
STANDARD_LETTERS,
77
} from './arabic-letters';
8-
export { PANNED_WORDS } from './panned-words';
8+
export { BANNED_WORDS } from './banned-words';
99
export { TASHKEEL } from './tashkeel';

src/scripts/scripts.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ARABIC_DOTLESS_DICT, PANNED_WORDS, TASHKEEL } from '../constants';
1+
import { ARABIC_DOTLESS_DICT, BANNED_WORDS, TASHKEEL } from '../constants';
22
import {
33
ALEF,
44
ALONE_LETTERS,
@@ -59,10 +59,10 @@ export function toOldArabic(sentence: string): string {
5959
return newSentence;
6060
}
6161

62-
export function toOldArabicAndTashfeerPannedWords(sentence: string, levelOfTashfeer: number = 2): string {
62+
export function toOldArabicAndTashfeerBannedWords(sentence: string, levelOfTashfeer: number = 2): string {
6363
let new_sentence = '';
6464
for (const word of sentence.split(' ')) {
65-
if (checkIfPannedWord(word)) {
65+
if (checkIfBannedWord(word)) {
6666
new_sentence += tashfeerHandler(word, levelOfTashfeer) + ' ';
6767
} else {
6868
new_sentence += toOldArabic(word) + ' ';
@@ -271,15 +271,15 @@ export function tashfeer(sentence: string, levelOfTashfeer: number = 1): string
271271
}
272272

273273
/**
274-
* Calculates a ratio that likely represents the degree of similarity of a given string to elements in a 'panned' array.
274+
* Calculates a ratio that likely represents the degree of similarity of a given string to elements in a 'banned' array.
275275
*
276-
* @param {string} string - The string to be compared against the elements in the 'panned' array.
277-
* @returns {number} The highest similarity ratio found between the string and elements in 'panned'.
276+
* @param {string} string - The string to be compared against the elements in the 'banned' array.
277+
* @returns {number} The highest similarity ratio found between the string and elements in 'banned'.
278278
*/
279-
function pannedSimilarityRatio(string: string): number {
279+
function bannedSimilarityRatio(string: string): number {
280280
let maximumSimilarity = -1;
281-
for (const i in PANNED_WORDS) {
282-
const calculatedSimilarity = similarityScore(string, PANNED_WORDS[i]);
281+
for (const i in BANNED_WORDS) {
282+
const calculatedSimilarity = similarityScore(string, BANNED_WORDS[i]);
283283
if (calculatedSimilarity > maximumSimilarity) {
284284
maximumSimilarity = calculatedSimilarity;
285285
}
@@ -288,28 +288,28 @@ function pannedSimilarityRatio(string: string): number {
288288
}
289289

290290
/**
291-
* Checks if a string is similar to any 'panned' words based on a predefined similarity ratio.
291+
* Checks if a string is similar to any 'banned' words based on a predefined similarity ratio.
292292
*
293293
* @param {string} string - The string to be checked.
294-
* @returns {boolean} True if the string is similar to any 'panned' word, false otherwise.
294+
* @returns {boolean} True if the string is similar to any 'banned' word, false otherwise.
295295
*/
296-
function checkIfPannedWord(string: string): boolean {
296+
function checkIfBannedWord(string: string): boolean {
297297
const std_ratio = 70;
298-
return pannedSimilarityRatio(removeArabicAffixes(string)) >= std_ratio;
298+
return bannedSimilarityRatio(removeArabicAffixes(string)) >= std_ratio;
299299
}
300300

301301
/**
302-
* Performs tashfeer encryption on a given sentence, but only for words that are considered "panned" words.
303-
* Panned words are determined based on a predefined similarity ratio.
302+
* Performs tashfeer encryption on a given sentence, but only for words that are considered "banned" words.
303+
* Banned words are determined based on a predefined similarity ratio.
304304
*
305305
* @param {string} sentence - The input sentence to be encrypted.
306306
* @param {number} [levelOfTashfeer=2] - The encryption level (default is 2).
307-
* @returns {string} The encrypted sentence with tashfeer applied to panned words.
307+
* @returns {string} The encrypted sentence with tashfeer applied to banned words.
308308
*/
309-
export function tashfeerPannedWords(sentence: string, levelOfTashfeer: number = 2): string {
309+
export function tashfeerBannedWords(sentence: string, levelOfTashfeer: number = 2): string {
310310
let new_sentence = '';
311311
for (const word of sentence.split(' ')) {
312-
if (checkIfPannedWord(word)) {
312+
if (checkIfBannedWord(word)) {
313313
new_sentence += tashfeerHandler(word, levelOfTashfeer) + ' ';
314314
} else {
315315
new_sentence += word + ' ';

tests/scripts.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ describe('#toOldArabic()', () => {
5858
});
5959
});
6060

61-
describe('#toOldArabicAndTashfeerPannedWords()', () => {
62-
it('should perform tashfeer encryption on panned words only and convert the rest to old arabic script', () => {
61+
describe('#toOldArabicAndTashfeerBannedWords()', () => {
62+
it('should perform tashfeer encryption on banned words only and convert the rest to old arabic script', () => {
6363
const sentence = 'جيش العدو يقتل الأطفال';
64-
const result = ArabicServices.toOldArabicAndTashfeerPannedWords(sentence);
64+
const result = ArabicServices.toOldArabicAndTashfeerBannedWords(sentence);
6565
expect(result).not.toEqual(sentence);
6666
expect(result).toMatch(/الاطڡال/);
6767
expect(result).not.toMatch(/جيش/);
@@ -251,26 +251,26 @@ describe('#similarityScore', () => {
251251
});
252252
});
253253

254-
describe('#tashfeerPannedWords', () => {
255-
it('should perform tashfeer encryption on panned words only', () => {
254+
describe('#tashfeerBannedWords', () => {
255+
it('should perform tashfeer encryption on banned words only', () => {
256256
const sentence = 'جيش العدو يقتل الأطفال';
257-
const result = ArabicServices.tashfeerPannedWords(sentence);
257+
const result = ArabicServices.tashfeerBannedWords(sentence);
258258
expect(result).not.toEqual(sentence);
259259
expect(result).toMatch(/الأطفال/);
260260
expect(result).not.toMatch(/جيش/);
261261
expect(result).not.toMatch(/العدو/);
262262
expect(result).not.toMatch(/يقتل/);
263263
});
264264

265-
it('should not perform tashfeer encryption on non-panned words', () => {
265+
it('should not perform tashfeer encryption on non-banned words', () => {
266266
const sentence = 'هذه جملة غير مشفرة';
267-
const result = ArabicServices.tashfeerPannedWords(sentence);
267+
const result = ArabicServices.tashfeerBannedWords(sentence);
268268
expect(result).toEqual(sentence);
269269
});
270270

271271
it('should handle empty input', () => {
272272
const sentence = '';
273-
const result = ArabicServices.tashfeerPannedWords(sentence);
273+
const result = ArabicServices.tashfeerBannedWords(sentence);
274274
expect(result).toEqual('');
275275
});
276276
});

0 commit comments

Comments
 (0)