
    i                         S r SSKrSSKrSSKJr  S rS rS rS rS rS	 r	\
S
:X  a%  \	" 5       r\" \R                  \R                  5        gg)z
convert table label to html
    N)tqdmc                     [        USSS9 nUR                  SR                  X5      5        S S S 5        g ! , (       d  f       g = f)Nza+utf-8)encodingz{}	{}
)openwriteformat)keyvaltmp_file_pathfs       n/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/paddleocr/ppstructure/table/convert_label2html.pysave_pred_txtr      s3    	mTG	4	
!!#+, 
5	4	4s	   !6
Ac                 <    U H  nU R                  US5      n M     U $ )ze
skip empty cell
@param text: text in cell
@param sp_char_list: style char and special code
@return:
 )replace)textsp_char_listsp_chars      r   	skip_charr      s#      ||GR(  K    c                    U S   S   S   R                  5       n[        U5       VVs/ s H  u  p#US;   d  M  UPM     nnn[        USSS2   U S   S   SSS2   5       HZ  u  p%US   (       d  M  SR                  US   5      n/ S	Qn[	        Xg5      n[        U5      S
:X  a  ME  UR                  US-   U5        M\     SR                  U5      nSR                  U5      nU$ s  snnf )z4
Formats HTML code from tokenized annotation of img
html	structuretokens)z<td>>Ncellsr   )z<b>z</b>u     z<i>z</i>r      z+<html><body><table>{}</table></body></html>)copy	enumeratezipjoinr   leninsertr	   )	img	html_codeitag	to_insertcellr   r   text_remove_styles	            r   gen_htmlr.   (   s     FK(2779I!*9!5N!5vq9M!5INy2FG(<TrT(BC>>774>*DHL )$ =$%*QUD) D 	"I=DDYOI Os
   C!C!c                    0 n[        U S5       nUR                  5       n[        U5       H@  nUR                  S5      R	                  S5      n[
        R                  " U5      nXaUS   '   MB     SSS5        U$ ! , (       d  f       U$ = f)z"
load gt
@param gt_path:
@return:
rbr   
filenameN)r   	readlinesr   decodestripjsonloads)gt_path	data_listr   linesline	data_lineinfos          r   load_gt_datar>   <   s     I	gt	KDG,2248I::i(D*.d:&'   
  
	 s   A A99
Bc                     [        U 5      n[        UR                  5       5       H  u  p4[        U5      n[	        X5U5        M     [        S5        g)zL
gen html from label file
@param origin_gt_path:
@param save_path:
@return:
zconvert finishN)r>   r   itemsr.   r   print)origin_gt_path	save_path	data_dictimg_namegtr   s         r   convertrG   L   sD     ^,IY__./|hi0 0 

r   c                      [         R                  " SS9n U R                  S[        SSS9  U R                  S[        SSS9  U R	                  5       nU$ )	Nzargs for paddleserving)descriptionz--ori_gt_pathTzlabel gt path)typerequiredhelpz--save_pathzpath to save file)argparseArgumentParseradd_argumentstr
parse_args)parserargss     r   rQ   rQ   Z   s\    $$1IJF
cDW
C$5H   DKr   __main__)__doc__r6   rM   r   r   r   r.   r>   rG   rQ   __name__rS   ori_gt_pathrC    r   r   <module>rY      s]      -
	(  z<DDdnn- r   