Arabic Strings
A library for handling Arabic strings, including removing diacritics, normalizing characters, and more.
Installation
npm install @flowdegree/arabic-strings
Usage
Importing the Library
import * as arabicStrings from '@flowdegree/arabic-strings';
Removing Diacritics (Harakat)
const str = 'ู
ูุฑุญุจูุง';
const result = arabicStrings.removeHarakat(str);
console.log(result);
How much of the string is Arabic
The percentage of Arabic letters in the String
.
arabicString.howArabic('foobar');
arabicString.howArabic('ููู bar');
arabicString.howArabic('ููุจุงุฑ');
String#howNotArabic()
The percentage of non-Arabic letters in the String
.
arabicString.howNotArabic('ููุจุงุฑ');
arabicString.howNotArabic('ููู bar');
arabicString.howNotArabic('foobar');
String#isArabic(threshold)
Is the String
Arabic, based on a given threshold
between 0
and 1
. Defaults to 0.79
.
arabicString.isArabic('ููู');
arabicString.isArabic('ููู bar baz');
String#hasArabic()
Does the String
have any Arabic letter.
arabicString.hasArabic('ููู bar');
arabicString.hasArabic('foo bar');
String#removeTashkel()
Will return the String
without the diacritics.
arabicString.removeTashkel('ู
ูุญู
ูุฏ');
arabicString.removeTashkel('ููุชูุฑู ุงููููููุงููุจู ููู ุงููู
ูุฌูุฑููุฉู ุดูุฑูุนูุง*** ู
ูุซููู ุงูุธููุจุงุกู ููุงุฑุนุง ููู ุฌูุฏููููู');
String#removeTatwel()
Will return the String
without the diacritics.
arabicString.removeTatwel('ู
ููุฑุญููุจููุง');
String#sanitize()
Will return the String
without the diacritics, and clean characters.
arabicString.sanitize(`ุฃููุง ุงูููุฐู ููุธูุฑู ุงูุฃูุนู
ู ุฅููู ุฃูุฏูุจู ... ููุฃูุณู
ููุนูุช ููููู
ุงุชู ู
ูู ุจููู ุตูู
ูู
ู
ุฃูููุงู
ู ู
ููุกู ุฌููููู ุนูู ุดููุงุฑูุฏููููุง ... ููููุณููุฑู ุงูุฎูููู ุฌูุฑูุงูุง ููููุฎุชูุตูู
ู
ููุฌูููุงูููู ู
ูุฏูููู ูู ุฌูููููู ุถูุญููู ... ุญูุชูู ุฃูุชูุชูู ููุฏู ููุฑูุงุณูููููููุฉู ูููููููููู
ู
`);
Credits
License
(The MIT License)