mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-26 09:14:32 +03:00
Add Tok2vec.remove_listener
This commit is contained in:
parent
99af9e7125
commit
0f3e3eedc2
|
@ -82,6 +82,15 @@ class Tok2Vec(TrainablePipe):
|
||||||
self.listener_map.setdefault(component_name, [])
|
self.listener_map.setdefault(component_name, [])
|
||||||
self.listener_map[component_name].append(listener)
|
self.listener_map[component_name].append(listener)
|
||||||
|
|
||||||
|
def remove_listener(self, listener: "Tok2VecListener", component_name: str) -> None:
|
||||||
|
"""Remove a listener for a downstream component. Usually internals."""
|
||||||
|
if component_name in self.listener_map:
|
||||||
|
if listener in self.listener_map[component_name]:
|
||||||
|
self.listener_map[component_name].remove(listener)
|
||||||
|
# If no listeners are left, remove entry
|
||||||
|
if not self.listener_map[component_name]:
|
||||||
|
del self.listener_map[component_name]
|
||||||
|
|
||||||
def find_listeners(self, component) -> None:
|
def find_listeners(self, component) -> None:
|
||||||
"""Walk over a model of a processing component, looking for layers that
|
"""Walk over a model of a processing component, looking for layers that
|
||||||
are Tok2vecListener subclasses that have an upstream_name that matches
|
are Tok2vecListener subclasses that have an upstream_name that matches
|
||||||
|
|
Loading…
Reference in New Issue
Block a user