← Course overview

Oct. 2 · Bag of words, document-term matrices, and TF-IDF

Session 3 · Descriptive Patterns

Counts describe what is common. TF-IDF helps identify what is distinctive within a corpus.

Objective

By the end of class, you can represent texts as counts and TF-IDF weights, and use simple visuals to describe the corpus.

Before class

See all R-foundation deadlines and marks →

What you bring from Session 2

The speeches, the course script, and the stopword file in your data/ folder, and your Demo 2 workflow. It ends with clean nouns from Preprocess Text. Session 3 starts from that workflow.

What this session is about

Session 2 turned text into clean tokens. Session 3 turns those tokens into numbers.

We compare what raw counts and TF-IDF show about the same speeches.

Laptop demonstration

Standard track · Orange

Extend your Demo 2 workflow with two branches after Preprocess Text, one for counts and one for TF-IDF.

… → Preprocess Text → Word Cloud → Data Table → Bar Plot (counts)

… → Preprocess Text → Bag of Words → Word Cloud → Data Table → Bar Plot (TF-IDF)

Each branch ends in a word cloud and a top-ten bar chart. The settings for each widget are on the slides. Save the four images under the names in Demo 3 below.

BA2 review track · R

Complete this assignment in R. Orange is not permitted for assessed work. You build an R script that counts the nouns in each speech, weights them with TF-IDF, and saves the two word clouds and the two top-ten bar charts. The README has the same reflection as the Orange track.

Demo 3 · Compare counts and TF-IDF

Due Oct. 9 at 09:15

Use (or create) demos/03-descriptive-patterns/ with the following files.

Reflection

Write one or two paragraphs in the README. Use your two bar charts.

In Orange, type a word in the search box of Corpus Viewer to find the speeches that use it. The Document Count column in the Data Table shows how many speeches contain it.

Before you submit

The score records whether these items are complete. It does not reward a more sophisticated interpretation.