👬Comparison Functions
A set of functions for comparing and matching Arabic words based on vocalization, patterns (wazn), and shadda positioning, designed for efficient Arabic text analysis and processing.
Table of Contents
vocalizedlike
Checks if two words are vocalized similar based on their vocalized similarity score.
Parameters
word1(String): The first word to compare.word2(String): The second word to compare.
Returns
Boolean:
trueif the words are vocalized similar,falseotherwise.
Example
const word1 = "سَلَام";
const word2 = "سَلِيم";
console.log(vocalizedlike(word1, word2)); // Output: falsewaznlike
Checks if a given word matches a specified pattern (wazn) and optionally extracts the root.
Parameters
word1(String): The word to be checked against the wazn.wazn(String): The pattern to be matched.extractRoot(Boolean, optional): Iftrue, the function returns the extracted root instead of a boolean value. Defaults tofalse.
Returns
Boolean or String: If
extractRootisfalse, returnstrueif the word matches the wazn andfalseotherwise. IfextractRootistrue, returns the extracted root if the word matches the wazn, andfalseotherwise.
Example
const word = "فَعَلَ";
const pattern = "فَعَلَ";
console.log(waznlike(word, pattern)); // Output: true
console.log(waznlike(word, pattern, true)); // Output: "فعل"shaddalike
Checks if two words are similar based on the position of shadda and their characters.
Parameters
partial(String): The first word to compare.fully(String): The second word to compare.
Returns
Boolean:
trueif the words are similar based on the position of shadda and their characters,falseotherwise.
Example
const partialWord = "مُتَحَدَّث";
const fullyWord = "مُتَحَدَّث";
console.log(shaddalike(partialWord, fullyWord)); // Output: trueLast updated