Little useless-useful R functions – Useless interface for learning irregular verbs

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!

Tagged with: , , ,
Posted in Uncategorized, Useless R functions
2 comments on “Little useless-useful R functions – Useless interface for learning irregular verbs
  1. […] by data_admin [This article was first published on R – TomazTsql, and kindly contributed to R-bloggers]. (You can report issue about the content on this page […]

    Liked by 1 person

  2. […] article was first published on R – TomazTsql, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here) […]

    Liked by 1 person

Leave a comment

Follow TomazTsql on WordPress.com
Programs I Use: SQL Search
Programs I Use: R Studio
Programs I Use: Plan Explorer
Rdeči Noski – Charity

Rdeči noski

100% of donations made here go to charity, no deductions, no fees. For CLOWNDOCTORS - encouraging more joy and happiness to children staying in hospitals (http://www.rednoses.eu/red-noses-organisations/slovenia/)

€2.00

Top SQL Server Bloggers 2018
TomazTsql

Tomaz doing BI and DEV with SQL Server and R, Python, Power BI, Azure and beyond

Discover WordPress

A daily selection of the best content published on WordPress, collected for you by humans who love to read.

Revolutions

Tomaz doing BI and DEV with SQL Server and R, Python, Power BI, Azure and beyond

Reeves Smith's SQL & BI Blog

A blog about SQL Server and the Microsoft Business Intelligence stack with some random Non-Microsoft tools thrown in for good measure.

SQL Server

for Application Developers

Business Analytics 3.0

Data Driven Business Models

SQL Database Engine Blog

Tomaz doing BI and DEV with SQL Server and R, Python, Power BI, Azure and beyond

Search Msdn

Tomaz doing BI and DEV with SQL Server and R, Python, Power BI, Azure and beyond

R-bloggers

Tomaz doing BI and DEV with SQL Server and R, Python, Power BI, Azure and beyond

Data Until I Die!

Data for Life :)

Paul Turley's SQL Server BI Blog

sharing my experiences with the Microsoft data platform, SQL Server BI, Data Modeling, SSAS Design, Power Pivot, Power BI, SSRS Advanced Design, Power BI, Dashboards & Visualization since 2009

Grant Fritchey

Intimidating Databases and Code

Madhivanan's SQL blog

A modern business theme

Alessandro Alpi's Blog

DevOps could be the disease you die with, but don’t die of.

Paul te Braak

Business Intelligence Blog

Sql Insane Asylum (A Blog by Pat Wright)

Information about SQL (PostgreSQL & SQL Server) from the Asylum.

Gareth's Blog

A blog about Life, SQL & Everything ...

SQLPam's Blog

Life changes fast and this is where I occasionally take time to ponder what I have learned and experienced. A lot of focus will be on SQL and the SQL community – but life varies.

William Durkin

William Durkin a blog on SQL Server, Replication, Performance Tuning and whatever else.

$hell Your Experience !!!

As aventuras de um DBA usando o Poder do $hell

Design a site like this with WordPress.com
Get started