So you want to train your knowledge on irregular verbs or your child is learning all forms of the verbs or you are getting prepared for post-covid travel a crash-course of grammar would not hurt.

Yes, this useless function will help you get back in shape.

Run the code train for brains and watch the results. The function is straightforward:

 learnVerbs <- function() {          #         # populate the list of irregular verbs         #         df <- data.frame(verb=c( "alight","arise","awake")                                   ,past=c("alighted","arose","awoke")                                   ,past_perfect=c( "alighted","arisen","awoken")         )                  # to exit the loop type: ex                         exit <- "ex"         correct <- 0         wrong <- 0           repeat {           cat("\014")           randomWord <- df[sample(nrow(df), 1), ]           randomWord[1]           formW <- sample(c("past","past_perfect"), 1)           promptText <- paste0("Find the __", formW, "__ form for the verb >>", toupper(randomWord[1,1]),"<< : ")           #promptText           inputW <- toupper(readline(prompt=promptText))           if (inputW == toupper(randomWord[1,formW])) {             print("bravo")             correct <- correct + 1             barplot(table(as.character(c(replicate(correct, "correct"), replicate(wrong, "wrong")))), main = "correct vs. wrong", ylab="Number of words")             randomWord <- ""                    } else {             if (inputW == toupper(exit)){               #wrong <- wrong -  1               break               #barplot(table(as.character(c(replicate(correct, "correct"), replicate(wrong, "wrong")))))             } else {             print("naaah")             wrong <- wrong +  1             barplot(table(as.character(c(replicate(correct, "correct"), replicate(wrong, "wrong")))), main = "correct vs. wrong", ylab="Number of words")             randomWord <- ""           }         }         } }  

and simply run the function:

 # Run the function learnVerbs()  

In console pane enter the verb in asked form and get lucky.

and once you are super annoyed and fed up with this useless game, just type "ex" to exit the loop.

As always, code is available in at the Github in same Useless_R_function repository. The complete list of irregular verbs is also included on Github.

And not to mention, the function is language agnostic, which means that you can use it for german, Spanish or any other crazy language that have more than two tenses and gazillion of irregular verbs.

Happy R-coding!


This post is ad-supported