Executive Summary

This report presents the initial exploratory analysis of the US English text dataset (en_US) for the predictive text capstone project. It covers data loading, basic file and word summaries, key text patterns, and the plan for the prediction algorithm and Shiny web application.


1. Data Ingestion & Basic Summaries

The dataset contains three text sources: blogs, news, and Twitter. The table below summarizes file sizes, line counts, word counts, and average line lengths.

Summary Statistics of the US English Corpus
Source File_Size_MB Line_Count Word_Count Avg_Words_Per_Line Max_Words_Per_Line
Blogs 200.42 899,288 37,546,806 41.8 6,726
News 196.28 1,010,242 34,762,658 34.4 1,796
Twitter 159.36 2,360,148 30,096,690 12.8 47

Line Length Distribution by Source

Key Observations

  • Large Corpus Size: The three files together contain over 4.2 million lines and 100 million words, making sampling practical for rapid exploration and model prototyping.
  • Style Differences Across Sources: Twitter lines are short and capped by character limits (~12.8 words/line), while blogs and news exhibit long-tailed distributions with substantially longer sentences.

2. Exploratory Data Analysis (N-Gram Frequencies)

To inspect common word and phrase patterns without requiring external C++ dependencies, a 2% random sample from each file was combined, normalized to lowercase, stripped of URLs, punctuation, and digits, and tokenized into unigrams (1-word), bigrams (2-word), and trigrams (3-word).

Top N-Grams by Frequency

Top 10 N-Grams Comparison Table

Top 10 Most Frequent Unigrams, Bigrams, and Trigrams
Rank Unigram Bigram Trigram
1 the (95,460) of the (8,516) one of the (640)
2 to (55,275) in the (8,278) a lot of (618)
3 a (48,518) to the (4,363) thanks for the (498)
4 and (48,079) for the (3,992) to be a (365)
5 of (40,311) on the (3,914) going to be (347)
6 i (34,944) to be (3,337) i want to (327)
7 in (33,289) at the (2,887) out of the (311)
8 for (22,114) and the (2,553) as well as (288)
9 is (21,434) in a (2,404) it was a (285)
10 that (20,920) with the (2,121) some of the (278)

Interesting Findings

  • Function Words Drive Next-Word Context: High-frequency words and phrases like the, to, and, and of sit near the top. Retaining them is important for natural phrase completion.
  • Long-Tail Sparsity: Many rare words and one-off phrases appear only once or twice in the sample, offering clear candidates for pruning to keep the model compact.