o
    Zh                     @   s   d Z ddlZddlZdd Zedkr=dZedZee eeZ	e
dd	d
d ee	jddD ]\ZZe
eejd
d q0dS dS )zX
Example of pySBD as a sentencizer component for spaCy

Installation:
pip install spacy
    Nc                    s^   t jdddd}| j} fdd|D }dd |D } D ]}|j|v r)dnd|_q  S )NenFT)languageclean	char_spanc                    s   g | ]
}  |j|jqS  )r   startend).0Z	sent_spandocr   X/var/www/html/lang_env/lib/python3.10/site-packages/examples/pysbd_as_spacy_component.py
<listcomp>   s    z-pysbd_sentence_boundaries.<locals>.<listcomp>c                 S   s   g | ]}|d ur|d j qS )Nr   )idx)r	   spanr   r   r   r      s    )pysbdZ	Segmentersegmenttextr   Zis_sent_start)r   segZsents_char_spansZ
char_spansZstart_token_idstokenr   r
   r   pysbd_sentence_boundaries
   s   r   __main__z9My name is Jonas E. Smith.          Please turn to p. 55.r   sent_idZsentencez	|	)sep   )r   )__doc__r   Zspacyr   __name__r   blankZnlpZadd_piper   print	enumerateZsentsr   sentr   r   r   r   <module>   s    	

	