Package pyarabic :: Module number
[hide private]
[frames] | no frames]

Module number

source code

Arabic number class

Classes [hide private]
  ArNumbers
Arabic number class
Functions [hide private]
integer
text2number(text)
Convert arabic text into number, for example convert تسعة وعشرون = >29.
source code
unicode
vocalize_number(wordlist, syn_tags='')
Vocalize a number words
source code
Boolean
is_unit(word)
return if the given word is a unit
source code
unicode
vocalize_unit(numeric, unit)
Vocalize a number words
source code
unicode
get_previous_tag(word)
Get the word tags
source code
integer
extract_number_phrases(text)
Extract number words in a text.
source code
integer
extract_number_context(text)
Extract number words in a text.
source code
list of tuple
detect_number_phrases_position(wordlist)
Detect number words in a text and return positions of each phrase.
source code
 
detect_number_words(text)
Detect number words in a text.
source code
 
pre_tashkeel_number(wordlist)
Detect number words in a text.
source code
Variables [hide private]
  __package__ = 'pyarabic'
Function Details [hide private]

text2number(text)

source code 

Convert arabic text into number, for example convert تسعة وعشرون = >29.

Example: >>> text2number(u"خمسمئة وثلاث وعشرون") 523

Parameters:
  • text (unicode @return : number extracted from text) - input text
Returns: integer

vocalize_number(wordlist, syn_tags='')

source code 

Vocalize a number words

Parameters:
  • wordlist (unicode list) - words to vocalize
  • syn_tags (unicode) - tags about the clause
Returns: unicode
the vocalized wordlist.

is_unit(word)

source code 

return if the given word is a unit

Parameters:
  • word (unicode) - given word to be tested
Returns: Boolean
if word is a unit return True else False.

vocalize_unit(numeric, unit)

source code 

Vocalize a number words

Parameters:
  • numeric (integer) - given number
  • unit (unicode) - unit to vocalize
Returns: unicode
the vocalized unit, or unit word if itsnt a unit word.

get_previous_tag(word)

source code 

Get the word tags

Parameters:
  • word (unicode @return :word tag) - given word
Returns: unicode

extract_number_phrases(text)

source code 

Extract number words in a text.

Example: >>> extract_number_phrases(u"وجدت خمسمئة وثلاثة وعشرين دينارا فاشتريت ثلاثة عشر دفترا") خمسمئة وثلاثة وعشرين ثلاثة عشر

Parameters:
  • text (unicode @return : number words extracted from text) - input text
Returns: integer

extract_number_context(text)

source code 

Extract number words in a text.

Example: >>> extract_number_context(u"وجدت خمسمئة وثلاثة وعشرين دينارا فاشتريت ثلاثة عشر دفترا") وجدت، خمسمئة وثلاثة وعشرين، دينارا فاشتريت، ثلاثة عشر ، دفترا

Parameters:
  • text (unicode) - input text
Returns: integer
number words extracted from text

detect_number_phrases_position(wordlist)

source code 

Detect number words in a text and return positions of each phrase.

Example: >>> detect_number_phrases_position(u"وجدت خمسمئة وثلاثة وعشرين دينارا فاشتريت ثلاثة عشر دفترا") (1،3)، (6،7)

Parameters:
  • wordlist (unicode list @return : list of numbers clause positions [(start,end),(start2,end2),]) - wordlist
Returns: list of tuple

detect_number_words(text)

source code 

Detect number words in a text.

Example:
>>> text2number(u"وجدت خمسمئة وثلاثة وعشرين دينارا")
                خمسمئة وثلاثة وعشرين

@param text: input text
@type text: unicode
@return : number words extracted from text
@rtype: integer

pre_tashkeel_number(wordlist)

source code 

    Detect number words in a text.
    
    Example:
    >>> preTashkeelNumber(u"وجدت خمسمئة وثلاثة وعشرين دينارا")
    وجدت خمسمئة وثلاثة وعشرين دينار
    @param wordlist: input text
    @type wordlist: unicode
    @return : wordlist with vocalized number clause
    @rtype: list
ا