spaCy/spacy/tests/parser
kadarakos 1bb87f35bc
Detect cycle during projectivize (#10877)
* detect cycle during projectivize

* not complete test to detect cycle in projectivize

* boolean to int type to propagate error

* use unordered_set instead of set

* moved error message to errors

* removed cycle from test case

* use find instead of count

* cycle check: only perform one lookup

* Return bool again from _has_head_as_ancestor

Communicate presence of cycles through an output argument.

* Switch to returning std::pair to encode presence of a cycle

The has_cycle pointer is too easy to misuse. Ideally, we would have a
sum type like Rust's `Result` here, but C++ is not there yet.

* _is_non_proj_arc: clarify what we are returning

* _has_head_as_ancestor: remove count

We are now explicitly checking for cycles, so the algorithm must always
terminate. Either we encounter the head, we find a root, or a cycle.

* _is_nonproj_arc: simplify condition

* Another refactor using C++ exceptions

* Remove unused error code

* Print graph with cycle on exception

* Include .hh files in source package

* Add FIXME comment

* cycle detection test

* find cycle when starting from problematic vertex

Co-authored-by: Daniël de Kok <me@danieldk.eu>
2022-06-08 19:34:11 +02:00
..
__init__.py Revert #4334 2019-09-29 17:32:12 +02:00
test_add_label.py Support negative examples in partial NER annotations (#8106) 2021-06-17 17:33:00 +10:00
test_arc_eager_oracle.py Migrate regression tests into the main test suite (#9655) 2021-12-04 20:34:48 +01:00
test_ner.py Migrate regression tests into the main test suite (#9655) 2021-12-04 20:34:48 +01:00
test_neural_parser.py Update config resolution to use new Thinc 2020-09-27 22:21:31 +02:00
test_nn_beam.py Tidy up and auto-format 2021-01-05 13:41:53 +11:00
test_nonproj.py Detect cycle during projectivize (#10877) 2022-06-08 19:34:11 +02:00
test_parse_navigate.py Raise error if deps not provided with heads (#8335) 2021-06-15 13:23:32 +02:00
test_parse.py Add test for old architectures (#10751) 2022-05-10 08:24:42 +02:00
test_preset_sbd.py Support negative examples in partial NER annotations (#8106) 2021-06-17 17:33:00 +10:00
test_space_attachment.py Tidy up tests and docs 2020-09-21 20:43:54 +02:00
test_state.py Tidy up and auto-format 2021-01-05 13:41:53 +11:00