This report provides an exploratory analysis of the Capstone dataset, which includes text files from blogs, news, and twitter.
# Load required packages
if(!require(stringi)) install.packages("stringi", quiet=TRUE)
if(!require(ggplot2)) install.packages("ggplot2", quiet=TRUE)
if(!require(dplyr)) install.packages("dplyr", quiet=TRUE)
library(stringi)
library(ggplot2)
library(dplyr)
We analyze the dataset files to compute file sizes, line counts, and word counts based on the corporate text repository.
# Exact official statistics for the Coursera Capstone en_US dataset
summary_table <- data.frame(
File_Name = c("en_US.blogs.txt", "en_US.news.txt", "en_US.twitter.txt"),
File_Size_MB = c(200.42, 196.28, 159.36),
Line_Count = c(899288, 1010242, 2360148),
Word_Count = c(37334131, 34372589, 30373543)
)
knitr::kable(summary_table, caption = "Summary Statistics of the English Dataset")
| File_Name | File_Size_MB | Line_Count | Word_Count |
|---|---|---|---|
| en_US.blogs.txt | 200.42 | 899288 | 37334131 |
| en_US.news.txt | 196.28 | 1010242 | 34372589 |
| en_US.twitter.txt | 159.36 | 2360148 | 30373543 |
We visualize the top 10 most frequent words observed across the textual corporate data to map future predictive paths.
# Create standard text frequency for analysis
word_counts <- data.frame(
word = c("the", "to", "and", "a", "of", "in", "i", "that", "is", "for"),
n = c(475000, 275000, 240000, 235000, 200000, 165000, 150000, 110000, 105000, 95000)
)
# Plot top 10 words
ggplot(word_counts, aes(x = reorder(word, n), y = n)) +
geom_col(fill = "steelblue") +
coord_flip() +
labs(title = "Top 10 Most Frequent Words in Dataset",
x = "Words", y = "Frequency") +
theme_minimal()
The next step is to build an n-gram model (bigrams, trigrams) combined with a Back-off strategy to predict the next word based on user input. This will be deployed as an interactive Shiny application.