🔦Extraction Functions

A set of functions to extract the numbers from text

Table of Contents

extractNumberPhrases

Syntax

extractNumberPhrases(text)

Description

Extracts all Arabic number phrases from the input text. The input should be a string containing Arabic text.

Parameters

  • text (string) - The input Arabic text to extract number phrases from.

Returns

  • array - An array of strings containing all Arabic number phrases extracted from the input text.

Example

const text = "أنا أملك اثنين سيارات وثلاثة منازل";
const phrases = extractNumberPhrases(text);
console.log(phrases); // [ 'اثنين', 'وثلاثة' ]

extractNumberContext

Syntax

extractNumberContext(text)

Description

Extracts all Arabic number phrases from the input text, along with their surrounding context (the preceding and following words). The input should be a string containing Arabic text.

Parameters

  • text (string) - The input Arabic text to extract number phrases and their context from.

Returns

  • array - An array of arrays containing the preceding word, the number phrase, and the following word for each extracted number phrase.

Example

const text = "أنا أملك اثنين سيارات وثلاثة منازل";
const phrases = extractNumberContext(text);
console.log(phrases); // [[ 'أملك', 'اثنين', 'سيارات' ], [ 'سيارات', 'وثلاثة', 'منازل' ]]

Last updated