mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-26 01:46:28 +03:00
* Use parse tree for sbd in Tokens.sents
This commit is contained in:
parent
ba1e91189b
commit
de772088e6
|
@ -212,20 +212,22 @@ cdef class Tokens:
|
|||
def sents(self):
|
||||
"""This is really only a place-holder for a proper solution."""
|
||||
cdef int i
|
||||
sentences = []
|
||||
cdef Tokens sent = Tokens(self.vocab, self._string[self.data[0].idx:])
|
||||
cdef attr_t period = self.vocab.strings['.']
|
||||
cdef attr_t question = self.vocab.strings['?']
|
||||
cdef attr_t exclamation = self.vocab.strings['!']
|
||||
#cdef attr_t period = self.vocab.strings['.']
|
||||
#cdef attr_t question = self.vocab.strings['?']
|
||||
#cdef attr_t exclamation = self.vocab.strings['!']
|
||||
spans = []
|
||||
start = None
|
||||
for i in range(self.length):
|
||||
if start is None:
|
||||
start = i
|
||||
if self.data[i].lex.orth == period or self.data[i].lex.orth == exclamation or \
|
||||
self.data[i].lex.orth == question:
|
||||
if self.data[i].sent_end:
|
||||
spans.append((start, i+1))
|
||||
start = None
|
||||
#if self.data[i].lex.orth == period or self.data[i].lex.orth == exclamation or \
|
||||
# self.data[i].lex.orth == question:
|
||||
# spans.append((start, i+1))
|
||||
# start = None
|
||||
if start is not None:
|
||||
spans.append((start, self.length))
|
||||
return spans
|
||||
|
|
Loading…
Reference in New Issue
Block a user