mirror of https://github.com/explosion/spaCy.git
Add Language.has_pipe method
This commit is contained in:
parent
485c4f6df5
commit
8ca344712d
|
@ -255,6 +255,15 @@ class Language(object):
|
||||||
unfound = before or after
|
unfound = before or after
|
||||||
raise ValueError(msg.format(unfound, self.pipe_names))
|
raise ValueError(msg.format(unfound, self.pipe_names))
|
||||||
|
|
||||||
|
def has_pipe(self, name):
|
||||||
|
"""Check if a component name is present in the pipeline. Equivalent to
|
||||||
|
`name in nlp.pipe_names`.
|
||||||
|
|
||||||
|
name (unicode): Name of the component.
|
||||||
|
RETURNS (bool): Whether a component of that name exists in the pipeline.
|
||||||
|
"""
|
||||||
|
return name in self.pipe_names
|
||||||
|
|
||||||
def replace_pipe(self, name, component):
|
def replace_pipe(self, name, component):
|
||||||
"""Replace a component in the pipeline.
|
"""Replace a component in the pipeline.
|
||||||
|
|
||||||
|
|
|
@ -327,6 +327,30 @@ p
|
||||||
+cell bool
|
+cell bool
|
||||||
+cell Insert component last / not last in the pipeline.
|
+cell Insert component last / not last in the pipeline.
|
||||||
|
|
||||||
|
+h(2, "has_pipe") Language.has_pipe
|
||||||
|
+tag method
|
||||||
|
+tag-new(2)
|
||||||
|
|
||||||
|
p
|
||||||
|
| Check whether a component is present in the pipeline. Equivalent to
|
||||||
|
| #[code name in nlp.pipe_names].
|
||||||
|
|
||||||
|
+aside-code("Example").
|
||||||
|
nlp.add_pipe(lambda doc: doc, name='component')
|
||||||
|
assert 'component' in nlp.pipe_names
|
||||||
|
assert nlp.has_pipe('component')
|
||||||
|
|
||||||
|
+table(["Name", "Type", "Description"])
|
||||||
|
+row
|
||||||
|
+cell #[code name]
|
||||||
|
+cell unicode
|
||||||
|
+cell Name of the pipeline component to check.
|
||||||
|
|
||||||
|
+row("foot")
|
||||||
|
+cell returns
|
||||||
|
+cell bool
|
||||||
|
+cell Whether a component of that name exists in the pipeline.
|
||||||
|
|
||||||
+h(2, "get_pipe") Language.get_pipe
|
+h(2, "get_pipe") Language.get_pipe
|
||||||
+tag method
|
+tag method
|
||||||
+tag-new(2)
|
+tag-new(2)
|
||||||
|
|
Loading…
Reference in New Issue