2018-12-29 20:02:26 +03:00
|
|
|
# coding: utf-8
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
from ..util import get_doc
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
import numpy
|
|
|
|
|
2018-12-30 16:27:04 +03:00
|
|
|
|
2019-02-07 22:54:07 +03:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
"sentence,heads,matrix",
|
|
|
|
[
|
|
|
|
(
|
|
|
|
"She created a test for spacy",
|
|
|
|
[1, 0, 1, -2, -1, -1],
|
|
|
|
numpy.array(
|
|
|
|
[
|
|
|
|
[0, 1, 1, 1, 1, 1],
|
|
|
|
[1, 1, 1, 1, 1, 1],
|
|
|
|
[1, 1, 2, 3, 3, 3],
|
|
|
|
[1, 1, 3, 3, 3, 3],
|
|
|
|
[1, 1, 3, 3, 4, 4],
|
|
|
|
[1, 1, 3, 3, 4, 5],
|
|
|
|
],
|
|
|
|
dtype=numpy.int32,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2019-01-06 21:07:50 +03:00
|
|
|
def test_issue2396(en_tokenizer, sentence, heads, matrix):
|
|
|
|
tokens = en_tokenizer(sentence)
|
|
|
|
doc = get_doc(tokens.vocab, [t.text for t in tokens], heads=heads)
|
2018-12-29 20:02:26 +03:00
|
|
|
span = doc[:]
|
2018-12-29 20:02:26 +03:00
|
|
|
assert (doc.get_lca_matrix() == matrix).all()
|
|
|
|
assert (span.get_lca_matrix() == matrix).all()
|