From 4ce7d24fd561890946d85f1d67dfc8575f9a0dd7 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 22 Jan 2018 20:18:38 +0100 Subject: [PATCH] Add test for #1799: Set left and right edges (and thus sentences) in non-projective parses. --- spacy/tests/regression/test_issue1799.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 spacy/tests/regression/test_issue1799.py diff --git a/spacy/tests/regression/test_issue1799.py b/spacy/tests/regression/test_issue1799.py new file mode 100644 index 000000000..3a2ff5ba7 --- /dev/null +++ b/spacy/tests/regression/test_issue1799.py @@ -0,0 +1,19 @@ +'''Test sentence boundaries are deserialized correctly, +even for non-projective sentences.''' + +import pytest +import numpy +from ... tokens import Doc +from ... vocab import Vocab +from ... attrs import HEAD, DEP + + +def test_issue1799(): + problem_sentence = 'Just what I was looking for.' + heads_deps = numpy.asarray([[1, 397], [4, 436], [2, 426], [1, 402], + [0, 8206900633647566924], [18446744073709551615, 440], + [18446744073709551614, 442]], dtype='uint64') + doc = Doc(Vocab(), words='Just what I was looking for .'.split()) + doc.vocab.strings.add('ROOT') + doc = doc.from_array([HEAD, DEP], heads_deps) + assert len(list(doc.sents)) == 1