# HG changeset patch # User Jeff Hammel # Date 1431835327 25200 # Node ID 1284c99a94faa21205719359b82f7cefcdc0aa2a # Parent 643c8e92e71ecdc46631433708b1fc22fc90b5e8 stubbing diff -r 643c8e92e71e -r 1284c99a94fa tests/test_split.py --- a/tests/test_split.py Sat May 16 20:13:12 2015 -0700 +++ b/tests/test_split.py Sat May 16 21:02:07 2015 -0700 @@ -19,7 +19,12 @@ string = 'a cat, a bat' retval = split.findall(string, 'a') - + self.assertEqual(retval, [0,3,7,10]) + + self.assertEqual(split.findall(string, 't'), + [4, 11]) + + if __name__ == '__main__': unittest.main() diff -r 643c8e92e71e -r 1284c99a94fa textshaper/split.py --- a/textshaper/split.py Sat May 16 20:13:12 2015 -0700 +++ b/textshaper/split.py Sat May 16 21:02:07 2015 -0700 @@ -11,7 +11,7 @@ import sys -def findall(sub, _string): +def findall(_string, sub): """find all occurances of `sub` in _string""" retval = [] @@ -20,10 +20,18 @@ try: index = _string.index(sub, index) retval.append(index) - index += 1 + index += len(sub) except ValueError: return retval +def findindices(_string, values): + """ + returns ordered list of 2-tuples: + (index, value) + """ + +def split_sentences(text, ends='.?!'): + """split a text into sentences""" def split_paragraphs(text):