๐Ÿ““Additional Functions

A set of functions to do many things

Table of Contents

hasShadda

Checks if a given word contains the shadda character.

Parameters

  • word (String): The word to be checked for the presence of shadda.

Returns

  • Boolean: true if the word contains shadda, false otherwise.

Example

isVocalized

Checks if a given word contains any tashkeel (vocalization) characters, where the word can't contain spaces, digits and punctuation.

Parameters

  • word (String): The word to be checked for the presence of tashkeel.

Returns

  • Boolean: true if the word contains tashkeel, false otherwise.

Example

isVocalizedText

Checks if a given text contains any tashkeel (vocalization) characters, where the text can contain spaces, digits and punctuation.

Parameters

  • text (String): The text to be checked for the presence of tashkeel.

Returns

  • Boolean: true if the text contains tashkeel, false otherwise.

Example

isArabicString

Checks if a given text does contain ONLY Arabic words, where the text can contain spaces, digits and punctuation.

Parameters

  • text (String): The text to be checked for Arabic words.

Returns

  • Boolean: true if the text does contain ONLY Arabic characters, false otherwise.

Example

isArabicRange

Checks if a given word does contain ONLY Arabic characters, where the word can't contain spaces, digits and punctuation.

Parameters

  • text (String): The word to be checked for characters within the Arabic range.

Returns

  • Boolean: true if the word does contain Arabic characters, false otherwise.

Example

isArabicWord

Checks if a given word is a valid Arabic word, where the word can't contain spaces, digits and punctuation, TEH_MARBUTA must be at the end.

Parameters

  • word (String): The word to be checked for validity.

Returns

  • Boolean: true if the word is a valid Arabic word, false otherwise.

Example

separate

Separates the given Arabic word into letters and marks.

Parameters

  • word (String): The Arabic word to be separated.

  • extractShadda (Boolean): Optional, defaults to false. If set to true, the function will extract the Shadda character separately.

Returns

  • Array: An array of strings that contains the separated components. If extractShadda is set to false, the array will contain two elements: letters and marks. If extractShadda is set to true, the array will contain three elements: letters without shadda, marks, and shadda places.

Example

joint

Combines the given letters and marks to form an Arabic word.

Parameters

  • letters (String): The Arabic letters.

  • marks (String): The corresponding marks.

Returns

  • String: The combined Arabic word, or an empty string if the lengths of letters and marks are not equal.

Example

reduceTashkeel

Reduces unnecessary tashkeel (diacritic marks) from the given Arabic text.

Parameters

  • text (String): The Arabic text with tashkeel.

Returns

  • String: The Arabic text with reduced tashkeel.

Example

fixSpaces

Fixes the spacing issues in the given Arabic text.

Parameters

  • text (String): The Arabic text with spacing issues.

Returns

  • String: The Arabic text with fixed spacing.

Example

autoCorrect

Automatically corrects common mistakes in the given Arabic text.

Parameters

  • text (String): The Arabic text with potential mistakes.

Returns

  • String: The corrected Arabic text.

spellit

Spells out the given Arabic word by returning a comma-separated list of character names.

Parameters

  • word (String): The Arabic word to be spelled out.

  • lang (String): Optional, defaults to 'ar'. The language of the character names, either 'ar' for Arabic or 'en' for English.

Returns

  • String: The spelled-out representation of the given word.

Example

Last updated