1. Introduction

The objective of this project is to explore text data collected from blogs, news articles, and Twitter. This analysis is part of the Data Science Capstone project.

The purpose is to understand the datasets and identify patterns that will help develop a text prediction algorithm.

2. Dataset Description

The project uses three English-language datasets:

3. Dataset Summary

file_sizes <- file.info(c( “en_US.blogs.txt”, “en_US.news.txt”, “en_US.twitter.txt” ))$size / (1024^2)

summary_table$Size_MB <- round(file_sizes, 2)

knitr::kable(summary_table)

The following table presents the number of lines and words in each dataset.

summary_table <- data.frame(
  Dataset = c("Blogs", "News", "Twitter"),
  Lines = c(899288, 1010206, 2360148),
  Words = c(37334131, 34371031, 30373543)
)

4. Exploratory Data Analysis

4.1 Word Count Comparison

The following bar chart compares the total number of words in the three datasets.

barplot(
  summary_table$Words / 1000000,
  names.arg = summary_table$Dataset,
  col = c("skyblue", "orange", "lightgreen"),
  main = "Word Count by Dataset",
  xlab = "Dataset",
  ylab = "Words (Millions)"
)

4.2 Line Count Comparison

The following chart compares the number of lines in each dataset.

barplot(
  summary_table$Lines,
  names.arg = summary_table$Dataset,
  col = c("lightblue", "pink", "lightgreen"),
  main = "Number of Lines in Each Dataset",
  xlab = "Dataset",
  ylab = "Number of Lines"
)

4.3 Distribution of Text Lengths

The following histogram shows the distribution of text lengths in a sample of 10,000 lines from each dataset.

set.seed(123)

blogs <- readLines("en_US.blogs.txt", warn = FALSE, encoding = "UTF-8")
news <- readLines("en_US.news.txt", warn = FALSE, encoding = "UTF-8")
twitter <- readLines("en_US.twitter.txt", warn = FALSE, encoding = "UTF-8")

blog_sample <- sample(blogs, 10000)
news_sample <- sample(news, 10000)
twitter_sample <- sample(twitter, 10000)

par(mfrow = c(1, 3))

hist(nchar(blog_sample),
     breaks = 30,
     main = "Blogs",
     xlab = "Characters")

hist(nchar(news_sample),
     breaks = 30,
     main = "News",
     xlab = "Characters")

hist(nchar(twitter_sample),
     breaks = 30,
     main = "Twitter",
     xlab = "Characters")

par(mfrow = c(1, 1))

5. Interesting Findings

The exploratory analysis revealed the following findings:

6. Plans for the Prediction Algorithm

The next stage of the project will focus on developing a text prediction algorithm.

The planned activities include:

7. Plans for the Shiny Application

A Shiny application will be developed to demonstrate the prediction algorithm.

The application will allow users to enter a word or phrase and receive predicted next words.

The interface will be designed to be simple and easy to use.

8. Conclusion

This milestone report presents an exploratory analysis of the SwiftKey English datasets.

The analysis includes dataset summaries, word-count comparisons, line-count comparisons, and a histogram of text lengths.

These findings provide a foundation for the next stage of the project: developing a text prediction algorithm and creating an interactive Shiny application.