spaCy/spacy/ml
Paul O'Leary McCann d61e742960
Handle Docs with no entities in EntityLinker (#11640)
* Handle docs with no entities

If a whole batch contains no entities it won't make it to the model, but
it's possible for individual Docs to have no entities. Before this
commit, those Docs would cause an error when attempting to concatenate
arrays because the dimensions didn't match.

It turns out the process of preparing the Ragged at the end of the span
maker forward was a little different from list2ragged, which just uses
the flatten function directly. Letting list2ragged do the conversion
avoids the dimension issue.

This did not come up before because in NEL demo projects it's typical
for data with no entities to be discarded before it reaches the NEL
component.

This includes a simple direct test that shows the issue and checks it's
resolved. It doesn't check if there are any downstream changes, so a
more complete test could be added. A full run was tested by adding an
example with no entities to the Emerson sample project.

* Add a blank instance to default training data in tests

Rather than adding a specific test, since not failing on instances with
no entities is basic functionality, it makes sense to add it to the
default set.

* Fix without modifying architecture

If the architecture is modified this would have to be a new version, but
this change isn't big enough to merit that.
2022-10-28 10:25:34 +02:00
..
models Handle Docs with no entities in EntityLinker (#11640) 2022-10-28 10:25:34 +02:00
__init__.py Auto-format code with black (#9530) 2021-10-22 13:03:10 +02:00
_character_embed.py 🏷 Add Mypy check to CI and ignore all existing Mypy errors (#9167) 2021-10-14 15:21:40 +02:00
_precomputable_affine.py Fix compatibility with CuPy 9.x (#11194) 2022-07-26 10:52:01 +02:00
callbacks.py Fix config validation failures caused by NVTX pipeline wrappers (#11460) 2022-09-12 14:55:41 +02:00
extract_ngrams.py 🏷 Add Mypy check to CI and ignore all existing Mypy errors (#9167) 2021-10-14 15:21:40 +02:00
extract_spans.py Fix entity linker batching (#9669) 2022-03-04 09:17:36 +01:00
featureextractor.py Fix import 2020-10-02 01:12:34 +02:00
parser_model.pxd Parser: use C saxpy/sgemm provided by the Ops implementation (#10773) 2022-05-27 11:20:52 +02:00
parser_model.pyx precompute_hiddens/Parser: do not look up CPU ops (3.4) (#11069) 2022-07-05 10:53:42 +02:00
staticvectors.py Fix issues for Mypy 0.950 and Pydantic 1.9.0 (#10786) 2022-05-25 09:33:54 +02:00
tb_framework.py TransitionBasedParser.v1 to legacy (#8586) 2021-07-06 15:26:45 +02:00