Information on syllable counting from Stack Overflow:
library("qdap")
good1 <- c("This is for Tuesday.", "Haiku from the balcony.", "View from the Haiku.")
bad1 <- c("This is a bogus", "Three-line", "Poem")
testHaiku <- function(tt) if (!identical(syllable.sum(tt), c(5, 7, 5))) stop("R's good at counting;",
"It found your haiku wanting;", " this is bad haiku")
testHaiku(good1)
testHaiku(bad1)
## Error: R's good at counting;It found your haiku wanting; this is bad haiku