
    )i*                         S r SSKJrJrJr  SSKrSrSr	Sr
/ SQr/ SQrS	rS
r\
4S\S\S\4S jjrS r\" S\5      rS\S\4S jrS rSSSSSSSS.rS rS rg)z
Library to convert to and from Roman numerals in various encodings

Placed here till https://github.com/jambonrose/roman-numerals/pull/64 is accepted.
    )VERBOSEcompilesubN         ))i     Ⅿ)i  u   ⅭⅯ)i     Ⅾ)i  u   ⅭⅮ)d      Ⅽ)Z   u   ⅩⅭ)2      Ⅼ)(   u   ⅩⅬ)
      Ⅹ)	      Ⅸ)      Ⅴ)      Ⅳ)r      Ⅰ)	)u	   ⅩⅠⅠu   Ⅻ)u   ⅩⅠu   Ⅺ)u   ⅠⅩr   )u   ⅤⅠⅠⅠu   Ⅷ)u	   ⅤⅠⅠu   Ⅶ)u   ⅤⅠu   Ⅵ)   ⅠⅤr   )u	   ⅠⅠⅠu   Ⅲ)u   ⅠⅠu   Ⅱu0   ⅯⅮⅭⅬⅫⅪⅩⅨⅧⅦⅥⅤⅣⅢⅡⅠu0   ⅿⅾⅽⅼⅻⅺⅹⅸⅷⅶⅵⅴⅳⅲⅱⅰdecimal_integermodereturnc                    [        U [        5      (       a  [        U [        5      (       a  [        S5      e[        U[        5      (       a  [        U[        5      (       a  [	        S5      e/ nU n[
         H%  u  pE[        X45      u  pcUR                  XV-  5        M'     SR                  U5      nU[        :X  a
  [        US9nO[        U5      nU[        :X  a/  [        R                  [        [         5      nUR#                  U5      nU$ )z,Convert a decimal integer to a Roman numeral#decimal_integer must be of type intzmode not recognized numeral_string)
isinstanceintbool	TypeError
ValueErrorROMAN_NUMERAL_TABLEdivmodappendjoin
MODE_ASCIIroman_to_asciiuse_shorteningsMODE_LOWERCASEstr	maketransSTANDARD_TRANSLOWERCASE_TRANS	translate)	r   r   return_list	remainderintegernumeralrepetitionsr"   trans_to_lowercases	            d/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/indic_transliteration/roman_numerals.pyconvert_to_numeralr<   0   s    
_c
*
*	OT	*	*
9
::
T3

	D$		
  +)-g#I7Kw,- . 77;'.	Z#>BN$^4N	^~G#--.@AN	    c                 D    [          H  u  p[        SU-  UU 5      n M     U $ Nz%s$SHORTENINGS
substitute)r"   full_string
shortenings      r;   r.   r.   L   s/    !,k{N "- 
r=   uM  
  Ⅿ*                # thousands
  (ⅭⅯ|ⅭⅮ|Ⅾ?Ⅽ{0,3})  # hundreds - ⅭⅯ (900), ⅭⅮ (400), ⅮⅭⅭⅭ (800), ⅭⅭⅭ (300)
  (ⅩⅭ|ⅩⅬ|Ⅼ?Ⅹ{0,3})  # tens - ⅩⅭ (90), ⅩⅬ (40), ⅬⅩⅩⅩ (80), ⅩⅩⅩ (30)
  (Ⅸ|Ⅳ|Ⅴ?Ⅰ{0,3})   # ones - Ⅸ (9), Ⅳ (4), ⅤⅠⅠⅠ (8), ⅠⅠⅠ (3)
  roman_numeralc                 0   [        U [        5      (       d  [        S5      eU S:X  a  [        R                  " S5      e[        R                  [        [        5      nU R                  U5      n[        U5      n[        US9n[        R                  " U5      nU$ )z,Convert a Roman numeral to a decimal integerr   r    z'roman_numeral cannot be an empty stringr!   )r#   r0   r&   romanInvalidRomanNumeralErrorr1   r3   r2   r4   remove_shorteningsr-   	fromRoman)rE   trans_to_uppercasepartial_numeralvalues       r;   convert_to_integerrN   a   s    	M3	'	'
9
::b

(
()R
SS }}_nE!++,>?/&7/"/B/
///
*%	,r=   c                 D    [          H  u  p[        SU-  UU 5      n M     U $ r?   r@   )rL   rC   rD   s      r;   rI   rI   t   s/    !,k zO "- 
r=   IVXLCDM)r   r   r   r   r   r
   r	   c                 x    [        U 5      n [        R                  5        H  u  pU R                  X5      n M     U $ )N)rI   roman_to_ascii_mapitemsreplacer"   romascs      r;   r-   r-      s7    %n5.$**,hc#++C5N -	r=   c                     [         R                  5        H  u  pU R                  X!5      n M     [        U 5      n U R                  SS5        U $ )Nr   r   )rX   rY   rZ   r.   r[   s      r;   ascii_to_romanr_      sG    $**,hc#++C5N -">2.5)	r=   )__doc__rer   r   
re_compiler   rB   rG   MODE_STANDARDr/   r,   r(   rA   r2   r3   r$   r0   r<   r.   NUMERAL_PATTERNrN   rI   rX   r-   r_    r=   r;   <module>rf      s   7 7 
  
 DD :D  3  8  
c c & !SSY\ehi r=   