I am trying to split a paragraph into sentences but it is not working. I feel like this should be an easy thing, and like I must be making a stupid mistake. I am getting it to work with string split, but want to figure out the regex.
Example:
lorem <- "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
strsplit(lorem, "[.]")
[1] "Lorem Ipsum is simply dummy text of the printing and typesetting industry"
[2] " Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book"
[3] " It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged"
[4] " It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum"
But when I use regex:
grep("[^\\.\\!\\?]*[\\.\\!\\?]", lorem, value=TRUE, perl=TRUE )
[1] "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
It just pops out the original input