Retrieving the start and end character indices in the original document, for those sentences returned by Spacy
<p>I am using something similar to the following pattern to retrieve the start and end indices of Spacy's sentences in the original document:</p>

<pre><code>nlp = spacy.en.English()
doc = nlp(fulltext)

tot = 0
prev_end=0
for sent in doc.sents:
    x = re.search(re.escape(sent.text), fulltext)
    print (x.start(), x.end(), "&gt;&gt;&gt;", sent.text)
    tot += (x.end()-prev_end)
    prev_end = x.end()

if len(fulltext) == tot: print ("works")
</code></pre>

<p>This seems to work for those few test docs I used. But worried if I am overlooking any 'gotchas' like spacy sometimes stripping off some characters that I am not aware of . Am I?</p>

<p>PS: If it helps, I need these indices to compare with indices I have from Brat's annotation file.</p>