shabeh
v1.0.6
Published
A light-weight Javascript package to calculate the similarity between two Arabic words.
Downloads
16
Maintainers
Readme
Shabeh
✨ A light-weight Javascript package to calculate the similarity between two Arabic words. ✨
Installation
To install this module, run:
npm install shabeh
Usage
Importing the Module
import { isSimilar, isEqual, similarityPercentage, countMatched, countUnmatched } from 'shabeh';
Functions
isSimilar(word1: string, word2: string): boolean
console.log(isSimilar("فاطمه", "فاطمة")); // Output: true
console.log(isSimilar("داوود", "داؤود")); // Output: true
console.log(isSimilar("علي", "على")); // Output: true
console.log(isSimilar("أحمد بن داوودمحمد", "احْمد بِن دَاؤود مُحمد")); // Output: true
isEqual(word1: string, word2: string): boolean
console.log(isEqual("فاطمه", "فاطمة")); // Output: false
console.log(isEqual("داوود", "داؤود")); // Output: false
console.log(isEqual("علي", "على")); // Output: false
console.log(isEqual("مرحباً", "مرحبا")); // Output: true
console.log(isEqual("علي بنمبارك", "علي بن مبارك")); // Output: true
similarityPercentage(word1: string, word2: string): number
const similarity = similarityPercentage("داؤود", "داوود");
console.log(similarity.toFixed(2)); // Output: 100
countMatched(word1: string, word2: string): number
const matched = countMatched("محمد", "محمود");
console.log(matched); // Output: 4
countUnmatched(word1: string, word2: string): number
const unmatched = countUnmatched("محمد", "محمود");
console.log(unmatched); // Output: 1
Testing
To run the tests, run:
npm test
License
This project is licensed under the MIT License - see the LICENSE file for details.