
    h                        S SK r S SKrS SKrS SKrS SKJr  S SKJrJrJ	r	J
r
  S SKrS SKrS SKrS SKJrJr  SSKJr  SSKJr  SS	KJrJrJrJrJr  \R6                  " S
5      \R6                  " S
SS9\" SSS9\" SSSSS9\" SSSSS94S\R8                  S\S\\   S\4S jj5       5       rS#S\S\\   S\SS4S jjr S\S\	\   SS4S jr!S \
\\4   S!\S\\   4S" jr"g)$    N)Path)IteratorOptionalSequenceUnion)Printermsg   )Language)
load_model   )NAMEArgOptapp	debug_cliprofileT)hidden.zTrained pipeline to load)helpz&Location of input file. '-' for stdin.)r   exists
allow_dash'  z	--n-textsz-nz+Maximum number of texts to use if availablectxmodelinputsn_textsc                     U R                   R                  R                  [        :X  a  [        R
                  " S5        [        XUS9  g)aD  
Profile which functions take the most time in a spaCy pipeline.
Input should be formatted as one JSON object per line with a key "text".
It can either be provided as a JSONL file, or be read from sys.sytdin.
If no input file is specified, the IMDB dataset is loaded via Thinc.

DOCS: https://spacy.io/api/cli#debug-profile
zThe profile command is now available via the 'debug profile' subcommand. You can run python -m spacy debug --help for an overview of the other available debugging commands.)r   r   N)parentcommandnamer   r	   warnr   )r   r   r   r   s       K/home/james-whalen/.local/lib/python3.13/site-packages/spacy/cli/profile.pyprofile_clir#      s:    $ zz$&B	

 E'2    returnc                 H   Ub/  [        U[        5      n[        [        R                  " X25      5      nUcZ   SS Kn[        R                  " S5         WR                  USS9u  pV[        U6 u  p6S S S 5        [        R                  " SU S35        [        R                  " S	U  S
35         [        U 5      nS S S 5        [        R                  " SU  S35        [        R                  " S[!        5       [#        5       S5        [$        R&                  " S5      n[        R(                  " S5        UR+                  5       R-                  S5      R/                  5         g ! [         a    [        R                  " SSS9   GNBf = f! , (       d  f       GN= f! , (       d  f       N= f)Nr   zwThis command, when run without an input file, requires the ml_datasets library to be installed: pip install ml_datasetsr   exitsz'Loading IMDB dataset via ml_datasets...)train_limit	dev_limitzLoaded IMDB dataset and using z	 exampleszLoading pipeline 'z'...zLoaded pipeline ''zparse_texts(nlp, texts)zProfile.profzProfile statstime)_read_inputsr	   list	itertoolsisliceml_datasetsImportErrorfailloadingimdbzipinfor   goodcProfilerunctxglobalslocalspstatsStatsdivider
strip_dirs
sort_statsprint_stats)	r   r   r   textsr1   
imdb_train_nlpss	            r"   r   r   -   sI   VS)Y%%e56~	 [[BC',,A,NMJJ'HE D 	1')DE	)%5	6 
7HH q)*OO-wy&(NS^$AKK LLNf%113%  	HH* 		 DC 
7	6s)   E F*FE>=E>
F
F!rF   rC   c                 X    U R                  [        R                  " US S9SS9 H  nM     g )N)disable   )
batch_size)pipetqdm)rF   rC   docs      r"   parse_textsrO   I   s(    xx		%62xF Gr$   locr	   c              #     #    U S:X  a,  UR                   " S5        [        R                  nS U 5       nOy[        U 5      nUR	                  5       (       a  UR                  5       (       d  UR                  " SU SS9  UR                   " SUR                  S    35        UR                  5       nU H"  n[        R                  " U5      nUS	   nUv   M$     g 7f)
N-zReading input from sys.stdinc              3   B   #    U  H  oR                  S 5      v   M     g7f)utf8N)encode).0lines     r"   	<genexpr>_read_inputs.<locals>.<genexpr>R   s     7V$$s   zNot a valid input data filer   r'   zUsing data from text)r7   sysstdinr   r   is_filer3   partsopensrsly
json_loads)rP   r	   file_
input_pathrW   datar[   s          r"   r-   r-   N   s     
cz/0		77#Y
  ""**<*<*>*>HH2CqA#J$4$4R$8#9:;!%F|
 s   CC)Nr   )#r9   r/   r=   r\   pathlibr   typingr   r   r   r   ra   rM   typerwasabir   r	   languager   utilr   _utilr   r   r   r   r   r   Contextstrintr#   r   rO   r-    r$   r"   <module>rq      s*      
  6 6       1 1 9Yt$ S9: ,T]anrsuk46cd3	3 3 TN	3
 3 % 3243 4 4 4PT 48X hsm  
eD#I& W # r$   