o
    ॵi                     @   s   d dl mZmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZmZ dgZejejejd	ejejejd	ejejejd	G d
d de
ZdS )    )OptionalUnion)	Pipelines)Model)	PIPELINES)TokenClassificationPipeline)Preprocessor)	ModelFileTasksNamedEntityRecognitionPipeline)module_namec                	       sF   e Zd Z					ddeeef dee dedef fd	d
Z  Z	S )r   NgpuT   modelpreprocessorconfig_filedevicec                    s   t  j||||||dd|di d t| jts#J dtj |du r5tj	| jj
fd|i|| _| j  t| jdsBJ | jj| _dS )	u  Use `model` and `preprocessor` to create a nlp NER pipeline for prediction

        Args:
            model (str or Model): Supply either a local model dir which supported NER task, or a
            model id from the model hub, or a torch model instance.
            preprocessor (Preprocessor): An optional preprocessor instance, please make sure the preprocessor fits for
                the model if supplied.
            kwargs (dict, `optional`):
                Extra kwargs passed into the preprocessor's constructor.

        Examples:
            >>> from modelscope.pipelines import pipeline
            >>> pipeline_ins = pipeline(task='named-entity-recognition',
            >>>        model='damo/nlp_raner_named-entity-recognition_chinese-base-news')
            >>> input = '这与温岭市新河镇的一个神秘的传说有关。'
            >>> print(pipeline_ins(input))

            To view other examples plese check the tests/pipelines/test_plugin_model.py.
        compileFcompile_options)r   r   r   r   auto_collater   r   z,please check whether model config exists in Nsequence_lengthid2label)super__init__pop
isinstancer   r   r	   CONFIGURATIONr   from_pretrained	model_dirr   evalhasattrr   )selfr   r   r   r   r   r   kwargs	__class__ n/home/ubuntu/.local/lib/python3.10/site-packages/modelscope/pipelines/nlp/named_entity_recognition_pipeline.pyr      s.   

	

z'NamedEntityRecognitionPipeline.__init__)NNr   Tr   )
__name__
__module____qualname__r   r   strr   r   r   __classcell__r%   r%   r#   r&   r      s    
N)typingr   r   modelscope.metainfor   modelscope.modelsr   modelscope.pipelines.builderr   modelscope.pipelines.nlpr   modelscope.preprocessorsr   modelscope.utils.constantr	   r
   __all__register_modulenamed_entity_recognitionnamed_entity_recognition_thainamed_entity_recognition_vietr   r%   r%   r%   r&   <module>   s*   