Here is a shorter version. This will give you a data structure with every single sentence and every token in the sentence. I prefer TweetTokenizer for a dirty, real world. A sentence fragment is considered worthy, but be careful not to omit the phrase before this step, as this may affect the accuracy of detecting the boundaries of a messy text.
from nltk.tokenize import TweetTokenizer, sent_tokenize tokenizer_words = TweetTokenizer() tokens_sentences = [tokenizer_words.tokenize(t) for t in nltk.sent_tokenize(input_text)] print(tokens_sentences)
This is what the output I cleaned up looks like, so the structure stands out:
[ ['This', 'thing', 'seemed', 'to', 'overpower', 'and', 'astonish', 'the', 'little', 'dark-brown', 'dog', ',', 'and', 'wounded', 'him', 'to', 'the', 'heart', '.'], ['He', 'sank', 'down', 'in', 'despair', 'at', 'the', "child's", 'feet', '.'], ['When', 'the', 'blow', 'was', 'repeated', ',', 'together', 'with', 'an', 'admonition', 'in', 'childish', 'sentences', ',', 'he', 'turned', 'over', 'upon', 'his', 'back', ',', 'and', 'held', 'his', 'paws', 'in', 'a', 'peculiar', 'manner', '.'], ['At', 'the', 'same', 'time', 'with', 'his', 'ears', 'and', 'his', 'eyes', 'he', 'offered', 'a', 'small', 'prayer', 'to', 'the', 'child', '.'] ]