mirror of
https://github.com/explosion/spaCy.git
synced 2025-08-06 21:30:22 +03:00
Format. Simplify code.
This commit is contained in:
parent
0753742a48
commit
5af8c711b0
|
@ -706,12 +706,13 @@ def test_for_partial_ent_sents():
|
||||||
"""Spans may be associated with multiple sentences. These .sents should always be complete, not partial, sentences,
|
"""Spans may be associated with multiple sentences. These .sents should always be complete, not partial, sentences,
|
||||||
which this tests for.
|
which this tests for.
|
||||||
"""
|
"""
|
||||||
nlp = English()
|
doc = Doc(
|
||||||
text = ["Mahler's", "Symphony", "No.", "8", "was", "beautiful."]
|
English().vocab,
|
||||||
doc = Doc(nlp.vocab, words=text, sent_starts=[1, 0, 0, 1, 0, 0])
|
words=["Mahler's", "Symphony", "No.", "8", "was", "beautiful."],
|
||||||
|
sent_starts=[1, 0, 0, 1, 0, 0],
|
||||||
|
)
|
||||||
doc.set_ents([Span(doc, 1, 4, "WORK")])
|
doc.set_ents([Span(doc, 1, 4, "WORK")])
|
||||||
# The specified entity is associated with both sentences in this doc, so we expect all sentences in the doc to be
|
# The specified entity is associated with both sentences in this doc, so we expect all sentences in the doc to be
|
||||||
# equal to the sentences referenced in ent.sents.
|
# equal to the sentences referenced in ent.sents.
|
||||||
for doc_sent, ent_sent in zip(doc.sents, doc.ents[0].sents):
|
for doc_sent, ent_sent in zip(doc.sents, doc.ents[0].sents):
|
||||||
assert doc_sent == ent_sent
|
assert doc_sent == ent_sent
|
||||||
|
|
||||||
|
|
|
@ -461,7 +461,7 @@ cdef class Span:
|
||||||
if start >= self.end:
|
if start >= self.end:
|
||||||
break
|
break
|
||||||
elif i == self.doc.length - 1:
|
elif i == self.doc.length - 1:
|
||||||
yield Span(self.doc, start, i + 1)
|
yield Span(self.doc, start, self.doc.length)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ents(self):
|
def ents(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user