o
    i                     @   s   d dl mZ d dlmZmZmZmZ zd dlmZm	Z	m
Z
 d dlmZmZmZ W n eyE   d dlmZm	Z	m
Z
 d dlmZmZmZ Y nw G dd deZG dd deZG d	d
 d
eZdeeef dee fddZdS )    )defaultdict)AnyDictListUnion)	BaseModelFieldValidationError)
StrictBool	StrictInt	StrictStrc                   @   sl   e Zd ZU edddZeed< edddZeed< edddZeed< edd	dZ	eed
< G dd dZ
dS )MatchNodeSchema.zPrefix lengthtitle
prefix_lenzSuffix length
suffix_lenzPrefix treeprefix_treezSuffix treesuffix_treec                   @      e Zd ZdZdS )zMatchNodeSchema.ConfigforbidN__name__
__module____qualname__extra r   r   _/home/ubuntu/.local/lib/python3.10/site-packages/spacy/pipeline/_edit_tree_internals/schemas.pyConfig       r   N)r   r   r   r   r   r   __annotations__r   r   r   r   r   r   r   r   r      s   
 r   c                   @   sT   e Zd ZU edddZeeef ed< edddZ	eeef ed< G dd dZ
d	S )
SubstNodeSchema.zOriginal substringr   origzReplacement substringsubstc                   @   r   )zSubstNodeSchema.Configr   Nr   r   r   r   r   r      r   r   N)r   r   r   r   r!   r   intr   r   r"   r   r   r   r   r   r       s   
 r    c                   @   s   e Zd ZU eeef ed< dS )EditTreeSchema__root__N)r   r   r   r   r   r    r   r   r   r   r   r$      s   
 r$   objreturnc                 C   s   zt |  g W S  tyH } z4| }tt}|D ]}ddd |dg D }|| |d qdd |	 D W  Y d}~S d}~ww )zValidate edit tree.

    obj (Dict[str, Any]): JSON-serializable data to validate.
    RETURNS (List[str]): A list of error messages, if available.
    z -> c                 S   s   g | ]}t |qS r   )str).0pr   r   r   
<listcomp>/   s    z&validate_edit_tree.<locals>.<listcomp>locmsgc                 S   s&   g | ]\}}d | dd | qS )[z] z, )join)r)   r,   r-   r   r   r   r+   1   s   & N)
r$   	parse_objr	   errorsr   listr/   getappenditems)r&   er1   dataerrorerr_locr   r   r   validate_edit_tree"   s   
r:   N)collectionsr   typingr   r   r   r   pydantic.v1r   r   r	   pydantic.v1.typesr
   r   r   ImportErrorpydanticpydantic.typesr   r    r$   r(   r:   r   r   r   r   <module>   s    
"