
    Pi?
                         d dl Z d dlZd dlZd dlZd dlmZmZ  G d de          Zd Z	d Z
d Zd
dZed	k    r e             dS dS )    N)	TokenizerProfilec                       e Zd ZdS )ParserErrorN)__name__
__module____qualname__     e/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/segments/__main__.pyr   r   	   s        Dr   r   c                    | j         r:t          j        | j                                                   st	          d          t           t          | j                   t          |           | j                             dS )z
    Tokenize a string (passed as argument or read from stdin)

    segments [--profile=PATH/TO/PROFILE] tokenize [STRING]
    z---profile must be a path for an existing file)profile)columnN)	r   pathlibPathexistsr   printr   _readmappingargss    r   tokenizer      sw     | KGL66==?? KIJJJ	
))DL
)
)
)%++dl
K
K
KLLLLLr   c                 b    t          t          j        t          |                                dS )z{
    Create an orthography profile for a string (passed as argument or read from stdin)

    segments profile [STRING]
    N)r   r   	from_textr   r   s    r   r   r      s)     
'
E$KK
(
()))))r   c                     | j         r| j         d         nt          j                                        }t	          |t
                    s|                    | j                  }|                                S )Nr   )	r   sysstdinread
isinstancestrdecodeencodingstrip)r   strings     r   r   r   !   sW    !Y<TYq\\CINN,<,<Ffc"" .t}--<<>>r   c                 .   t           t          d}t          j                     t	          j        dd          }|                    dd           |                    dd	                    |                     |                    d
t          j                   |                    ddd           |                    ddd            |                    ddt          j
                   | p|                                }|j        dk    r{t          |j                  rgt          |j        d         |v r*||j        d                  j                                        nd                    |j        d                              n|j        |vr7t          d           |                                 t)          j        d           	  ||j                 |           n# t,          $ r^}t          |           t          ||j                 j                                                   t)          j        d           Y d }~n=d }~wt.          $ r-}t          |           t)          j        d           Y d }~nd }~ww xY wt)          j        d           d S )N)r   r   z4Main command line interface of the segments package.z@Use '%(prog)s help <cmd>' to get help about individual commands.)descriptionepilogz--verbosityzincrease output verbosity)helpcommandz | r   )nargsz
--encodingzinput encodingutf8)r(   defaultz	--profilezpath to an orthography profilez	--mappingz-column name in ortho profile to map graphemesr(   r   zInvalid command: '{}'zinvalid command@      )r   r   loggingbasicConfigargparseArgumentParseradd_argumentjoin	REMAINDERr   GRAPHEME_COL
parse_argsr)   lenr   r   __doc__r#   format
print_helpr   exitr   	Exception)parsed_argscommandsparserr   es        r   mainrB   (   s   $99H$JQS S SF ,GHHH
	

8(<(<===
h&8999
+;VLLL
*JTXYYY
<$  & & &
 -&++--D|v#di.. 	1)) ty|$,22444/F/M/MdiXYl/[/[	] 	] 	] 	] <x''#$$$HRLLL	"HT\"4(((( 	 	 	!HHH(4<(06688999HRLLLLLLLL 	 	 	!HHHHQKKKKKKKK	 HQKKKKKs%   
G! !
I>+AII>#I99I>__main__)N)r   r/   r   r1   segmentsr   r   r=   r   r   r   r   rB   r   r
   r   r   <module>rE      s    



    ' ' ' ' ' ' ' '	 	 	 	 	) 	 	 	M M M* * *  $ $ $ $N zDFFFFF r   