🕵️Detection Functions

A set of functions to detect the numbers from text or arrays.

Table of Contents

detectNumberPhrasesPosition

Syntax

detectNumberPhrasesPosition(wordlist);

Description

Finds the start and end positions of number phrases within the given wordlist.

Parameters

  • wordlist (Array): An array of words (strings) to search for number phrases.

Returns

  • phrases (Array): An array of arrays containing the start and end positions of detected number phrases.

Example

const wordlist = ["أربعة", "عشر", "كتب"];
const phrases = detectNumberPhrasesPosition(wordlist);
console.log(phrases); // [[0, 1]]

detectNumbers

Syntax

detectNumbers(wordlist);

Description

Detects and tags words within the given wordlist based on their association with numbers.

Parameters

  • wordlist (Array): An array of words (strings) to search for number-associated words.

Returns

  • taglist (Array): An array of tags corresponding to the input words' association with numbers. Tags: "DB" (number begin), "DI" (number inside), "O" (other).

Example

const wordlist = ["أربعة", "عشر", "كتب"];
const taglist = detectNumbers(wordlist);
console.log(taglist); // ["DB", "DI", "O"]

detectNumberWords

Syntax

detectNumberWords(text);

Description

Detects number words within the given text and calculates the vocalized similarity between the detected number words and their vocalized counterparts.

Parameters

  • text (string): The input text containing number words.

Returns

  • string. Logs the vocalized similarity and related information to the console.

Example

const text = "أربعة عشر كتب";
console.log(detectNumberWords(text));
// output: 
// -2		أَرْبَعَةَ عَشْر
 //     14  أربعة عشر كتب
// كتب	كتب	true

Last updated