mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-12 18:26:30 +03:00
NEL docs & UX (#7129)
* EL set_kb docs fix * custom warning for set_kb mistake
This commit is contained in:
parent
cca8651fc8
commit
ba5a50f62b
|
@ -486,6 +486,9 @@ class Errors:
|
||||||
E202 = ("Unsupported alignment mode '{mode}'. Supported modes: {modes}.")
|
E202 = ("Unsupported alignment mode '{mode}'. Supported modes: {modes}.")
|
||||||
|
|
||||||
# New errors added in v3.x
|
# New errors added in v3.x
|
||||||
|
|
||||||
|
E885 = ("entity_linker.set_kb received an invalid 'kb_loader' argument: expected "
|
||||||
|
"a callable function, but got: {arg_type}")
|
||||||
E886 = ("Can't replace {name} -> {tok2vec} listeners: path '{path}' not "
|
E886 = ("Can't replace {name} -> {tok2vec} listeners: path '{path}' not "
|
||||||
"found in config for component '{name}'.")
|
"found in config for component '{name}'.")
|
||||||
E887 = ("Can't replace {name} -> {tok2vec} listeners: the paths to replace "
|
E887 = ("Can't replace {name} -> {tok2vec} listeners: the paths to replace "
|
||||||
|
|
|
@ -146,6 +146,9 @@ class EntityLinker(TrainablePipe):
|
||||||
def set_kb(self, kb_loader: Callable[[Vocab], KnowledgeBase]):
|
def set_kb(self, kb_loader: Callable[[Vocab], KnowledgeBase]):
|
||||||
"""Define the KB of this pipe by providing a function that will
|
"""Define the KB of this pipe by providing a function that will
|
||||||
create it using this object's vocab."""
|
create it using this object's vocab."""
|
||||||
|
if not callable(kb_loader):
|
||||||
|
raise ValueError(Errors.E885.format(arg_type=type(kb_loader)))
|
||||||
|
|
||||||
self.kb = kb_loader(self.vocab)
|
self.kb = kb_loader(self.vocab)
|
||||||
self.cfg["entity_vector_length"] = self.kb.entity_vector_length
|
self.cfg["entity_vector_length"] = self.kb.entity_vector_length
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,7 @@ with the current vocab.
|
||||||
> kb.add_alias(...)
|
> kb.add_alias(...)
|
||||||
> return kb
|
> return kb
|
||||||
> entity_linker = nlp.add_pipe("entity_linker")
|
> entity_linker = nlp.add_pipe("entity_linker")
|
||||||
> entity_linker.set_kb(lambda: [], nlp=nlp, kb_loader=create_kb)
|
> entity_linker.set_kb(create_kb)
|
||||||
> ```
|
> ```
|
||||||
|
|
||||||
| Name | Description |
|
| Name | Description |
|
||||||
|
|
Loading…
Reference in New Issue
Block a user