Press "Enter" to skip to content

Return a Vector of Each Word Found Before the End of a Sentence

This little function returns the vector of each word found before the end of a sentence. I ended up writing this for a pet project to help with the babble function within the ngrams R package.

It can be used to find the best spot to terminate sentences from the resulting babbles and adjusted to fit your needs.

The stringr package also has similar functionality, str_extract to work the way I wanted. Probably just me though.

Sharing is caring!

Be First to Comment

    Leave a Reply

    Your email address will not be published. Required fields are marked *