<commit_before>output$data_transform <- renderUI({
  list(
    sidebarLayout(
      sidebarPanel(
        checkboxInput("data_transform_checkbox_makelower", "Make lowercase?", value=TRUE),
        checkboxInput("data_transform_checkbox_rempunct", "Remove punctuation?", value=TRUE),
        checkboxInput("data_transform_checkbox_remnum", "Remove numbers?", value=FALSE),
        checkboxInput("data_transform_checkbox_remws", "Remove extra whitespace?", value=FALSE),
        checkboxInput("data_transform_checkbox_stem", "Stem?", value=FALSE),
        selectizeInput("data_stopwords_lang", "Stopwords Language", stopwords_list, "english"),
        checkboxInput("data_transform_checkbox_remstop", "Remove stopwords?", value=TRUE),
        actionButton("button_data_transform", "Transform"),
        render_helpfile("Transform", "data/transform.md")
      ),
      mainPanel(
        htmlOutput("data_transform_buttonaction")
      )
    )
  )
})



output$data_transform_buttonaction <- renderUI({
  temp <- eventReactive(input$button_data_transform, {
    withProgress(message='Processing...', value=0, {
      
      n <- input$data_transform_checkbox_makelower + 
           input$data_transform_checkbox_rempunct + 
           input$data_transform_checkbox_remnum + 
           input$data_transform_checkbox_remws + 
           input$data_transform_checkbox_stem + 
           input$data_transform_checkbox_remstop
      
      runtime <- system.time({
        if (input$data_transform_checkbox_makelower)
        {
          incProgress(0, message="Setting to lowercase...")
          localstate$corpus <- tm::tm_map(localstate$corpus, tm::content_transformer(tolower))
          incProgress(1/n)
        }
        if (input$data_transform_checkbox_rempunct)
        {
          incProgress(0, message="Removing punctuation...")
          localstate$corpus <- tm::tm_map(localstate$corpus, tm::removePunctuation)
          incProgress(1/n)
        }
        if (input$data_transform_checkbox_remnum)
        {
          incProgress(0, message="Removing numbers...")
          localstate$corpus <- tm::tm_map(localstate$corpus, tm::removeNumbers)
          incProgress(1/n)
        }
        if (input$data_transform_checkbox_remws)
        {
          incProgress(0, message="Stripping whitespace...")
          localstate$corpus <- tm::tm_map(localstate$corpus, tm::stripWhitespace)
          incProgress(1/n)
        }
        if (input$data_transform_checkbox_stem)
        {
          incProgress(0, message="Stemming...")
          localstate$corpus <- tm::tm_map(localstate$corpus, tm::stemDocument)
          incProgress(1/n)
        }
        if (input$data_transform_checkbox_remstop)
        {
          incProgress(0, message="Removing stopwords...")
          localstate$corpus <- tm::tm_map(localstate$corpus, tm::removeWords, tm::stopwords(input$data_stopwords_lang))
          incProgress(1/n)
        }
        
        localstate$tdm <- tm::TermDocumentMatrix(localstate$corpus)
        localstate$wordcount_table <- sort(rowSums(as.matrix(localstate$tdm)), decreasing=TRUE)
      })
      
      setProgress(1)
    })
    
    paste("Processing finished in", round(runtime[3], roundlen), "seconds.")
  })
  
  temp()
})

<commit_msg>more clarity in transformation progress bar<commit_after>output$data_transform <- renderUI({
  list(
    sidebarLayout(
      sidebarPanel(
        checkboxInput("data_transform_checkbox_makelower", "Make lowercase?", value=TRUE),
        checkboxInput("data_transform_checkbox_rempunct", "Remove punctuation?", value=TRUE),
        checkboxInput("data_transform_checkbox_remnum", "Remove numbers?", value=TRUE),
        checkboxInput("data_transform_checkbox_remws", "Remove extra whitespace?", value=TRUE),
        checkboxInput("data_transform_checkbox_stem", "Stem?", value=FALSE),
        selectizeInput("data_stopwords_lang", "Stopwords Language", stopwords_list, "english"),
        checkboxInput("data_transform_checkbox_remstop", "Remove stopwords?", value=TRUE),
        actionButton("button_data_transform", "Transform"),
        render_helpfile("Transform", "data/transform.md")
      ),
      mainPanel(
        htmlOutput("data_transform_buttonaction")
      )
    )
  )
})



output$data_transform_buttonaction <- renderUI({
  temp <- eventReactive(input$button_data_transform, {
    withProgress(message='Processing...', value=0, {
      
      n <- input$data_transform_checkbox_makelower + 
           input$data_transform_checkbox_rempunct + 
           input$data_transform_checkbox_remnum + 
           input$data_transform_checkbox_remws + 
           input$data_transform_checkbox_stem + 
           input$data_transform_checkbox_remstop
      
      runtime <- system.time({
        if (input$data_transform_checkbox_makelower)
        {
          incProgress(0, message="Setting to lowercase...")
          localstate$corpus <- tm::tm_map(localstate$corpus, tm::content_transformer(tolower))
          incProgress(1/n/2)
        }
        if (input$data_transform_checkbox_rempunct)
        {
          incProgress(0, message="Removing punctuation...")
          localstate$corpus <- tm::tm_map(localstate$corpus, tm::removePunctuation)
          incProgress(1/n/2)
        }
        if (input$data_transform_checkbox_remnum)
        {
          incProgress(0, message="Removing numbers...")
          localstate$corpus <- tm::tm_map(localstate$corpus, tm::removeNumbers)
          incProgress(1/n/2)
        }
        if (input$data_transform_checkbox_remws)
        {
          incProgress(0, message="Stripping whitespace...")
          localstate$corpus <- tm::tm_map(localstate$corpus, tm::stripWhitespace)
          incProgress(1/n/2)
        }
        if (input$data_transform_checkbox_stem)
        {
          incProgress(0, message="Stemming...")
          localstate$corpus <- tm::tm_map(localstate$corpus, tm::stemDocument)
          incProgress(1/n/2)
        }
        if (input$data_transform_checkbox_remstop)
        {
          incProgress(0, message="Removing stopwords...")
          localstate$corpus <- tm::tm_map(localstate$corpus, tm::removeWords, tm::stopwords(input$data_stopwords_lang))
          incProgress(1/n/2)
        }
        
        incProgress(0, message="Updating tdm...")
        localstate$tdm <- tm::TermDocumentMatrix(localstate$corpus)
        setProgress(3/4, message="Updating wordcounts...")
        localstate$wordcount_table <- sort(rowSums(as.matrix(localstate$tdm)), decreasing=TRUE)
      })
      
      setProgress(1)
    })
    
    paste("Processing finished in", round(runtime[3], roundlen), "seconds.")
  })
  
  temp()
})


{'fraction_non_alphanumeric': 0.11807951987997, 'fraction_numerical': 0.005851462865716429, 'mean_word_length': 3.0180831826401446, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3089055', 'n_tokens_mistral': 2019, 'n_tokens_neox': 1957, 'n_words': 257}