mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-11 12:18:04 +03:00
f111b228e0
If a Doc object had been previously parsed, it was possible for invalid parses to be added. There were two problems: 1) The parse was only being partially erased 2) The RightArc action was able to create a 1-cycle. This patch fixes both errors, and avoids resetting the parse if one is present. In theory this might allow a better parse to be predicted by running the parser twice. Closes #1253.
21 lines
409 B
Python
21 lines
409 B
Python
from __future__ import unicode_literals
|
|
import pytest
|
|
import spacy
|
|
|
|
|
|
def ss(tt):
|
|
for i in range(len(tt)-1):
|
|
for j in range(i+1, len(tt)):
|
|
tt[i:j].root
|
|
|
|
|
|
@pytest.mark.models('en')
|
|
def test_access_parse_for_merged():
|
|
nlp = spacy.load('en_core_web_sm')
|
|
t_t = nlp.tokenizer("Highly rated - I'll definitely")
|
|
nlp.tagger(t_t)
|
|
nlp.parser(t_t)
|
|
nlp.parser(t_t)
|
|
ss(t_t)
|
|
|