def add_pipe(<EOL>self, component, name=None, before=None, after=None, first=None, last=None<EOL>):
if not hasattr(component, "<STR_LIT>"):<EOL><INDENT>msg = Errors.E003.format(component=repr(component), name=name)<EOL>if isinstance(component, basestring_) and component in self.factories:<EOL><INDENT>msg += Errors.E004.format(component=component)<EOL><DEDENT>raise ValueError(msg)<EOL><DEDENT>if name is None:<EOL><INDENT>if hasattr(component, "<STR_LIT:name>"):<EOL><INDENT>name = component.name<EOL><DEDENT>elif hasattr(component, "<STR_LIT>"):<EOL><INDENT>name = component.__name__<EOL><DEDENT>elif hasattr(component, "<STR_LIT>") and hasattr(<EOL>component.__class__, "<STR_LIT>"<EOL>):<EOL><INDENT>name = component.__class__.__name__<EOL><DEDENT>else:<EOL><INDENT>name = repr(component)<EOL><DEDENT><DEDENT>if name in self.pipe_names:<EOL><INDENT>raise ValueError(Errors.E007.format(name=name, opts=self.pipe_names))<EOL><DEDENT>if sum([bool(before), bool(after), bool(first), bool(last)]) >= <NUM_LIT:2>:<EOL><INDENT>raise ValueError(Errors.E006)<EOL><DEDENT>pipe = (name, component)<EOL>if last or not any([first, before, after]):<EOL><INDENT>self.pipeline.append(pipe)<EOL><DEDENT>elif first:<EOL><INDENT>self.pipeline.insert(<NUM_LIT:0>, pipe)<EOL><DEDENT>elif before and before in self.pipe_names:<EOL><INDENT>self.pipeline.insert(self.pipe_names.index(before), pipe)<EOL><DEDENT>elif after and after in self.pipe_names:<EOL><INDENT>self.pipeline.insert(self.pipe_names.index(after) + <NUM_LIT:1>, pipe)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError(<EOL>Errors.E001.format(name=before or after, opts=self.pipe_names)<EOL>)<EOL><DEDENT>
Add a component to the processing pipeline. Valid components are
        callables that take a `Doc` object, modify it and return it. Only one
        of before/after/first/last can be set. Default behaviour is "last".

        component (callable): The pipeline component.
        name (unicode): Name of pipeline component. Overwrites existing
            component.name attribute if available. If no name is set and
            the component exposes no name attribute, component.__name__ is
            used. An error is raised if a name already exists in the pipeline.
        before (unicode): Component name to insert component directly before.
        after (unicode): Component name to insert component directly after.
        first (bool): Insert component first / not first in the pipeline.
        last (bool): Insert component last / not last in the pipeline.

        DOCS: https://spacy.io/api/language#add_pipe