๐Ÿš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more โ†’
Socket
DemoInstallSign in
Socket

@flowdegree/arabic-strings

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@flowdegree/arabic-strings

A library for handling Arabic strings, including removing diacritics, normalizing characters, and more.

2.0.0
latest
Source
npm
Version published
Weekly downloads
151
36.04%
Maintainers
1
Weekly downloads
ย 
Created
Source

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)

// Define a string with Arabic diacritics (Harakat)
const str = 'ู…ูŽุฑุญุจู‹ุง';

// Use the removeHarakat method to remove the diacritics from the string
const result = arabicStrings.removeHarakat(str);

// Output the result without diacritics
console.log(result); // Outputs: ู…ุฑุญุจุง

How much of the string is Arabic

The percentage of Arabic letters in the String.

arabicString.howArabic('foobar');
//=> 0.0

arabicString.howArabic('ููˆูˆ bar');
//=> 0.5

arabicString.howArabic('ููˆุจุงุฑ');
//=> 1.0

String#howNotArabic()

The percentage of non-Arabic letters in the String.

arabicString.howNotArabic('ููˆุจุงุฑ');
//=> 0.0

arabicString.howNotArabic('ููˆูˆ bar');
//=> 0.5

arabicString.howNotArabic('foobar');
//=> 1.0

String#isArabic(threshold)

Is the String Arabic, based on a given threshold between 0 and 1. Defaults to 0.79.

arabicString.isArabic('ููˆูˆ');

//=> true
arabicString.isArabic('ููˆูˆ bar baz');
//=> false

String#hasArabic()

Does the String have any Arabic letter.

arabicString.hasArabic('ููˆูˆ bar');
//=> ture

arabicString.hasArabic('foo bar');
//=> false

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

  • Original script [https://github.com/ahmads/arabicString]
  • Enhancements [https://github.com/ahmads/arabicString/pulls]
  • sanitization [https://github.com/ielashi/arabic-nlp]

License

(The MIT License)

Keywords

strings

FAQs

Package last updated on 02 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts