From Mouth to Mind:
An Introduction

Data Science and Text Analysis, CAMS, CityU

Yue Hu

Department of Political Science

Tsinghua University

Who am I

Experience

  • PhD. of Poli. Sci., U of Iowa
    • Grad. Certificate in Informatics
  • Deputy director of Computational Social Science Lab, THU
  • Founder of Learning R with Dr. Hu and His Friends
  • Creator of 100k-download packages

Method specialty:

  • W. data science
    • Lab and survey experiments
    • Latent variable, network, spatial
    • Text analysis, data visualization

Research Areas

  • W. psychology
    • Political cognition (attitudes, behaviors, memory)
    • Political communication (state media, youth)
    • Identity politics (urban/rural, Hong Kong, Judiciary)
  • W. economics
    • Macro economy → micro cognition → meso-policy
    • Economic inequality
  • W. linguistics
    • Language planning and policies
    • How the language you speak shapes the mind of politics

Warm-up questions

  1. Why did you get up early today? 😝
  2. Without understanding what a person says, how can you tell s/he is a leader and how much power does s/he have?
  3. “King” − “man” + “woman” ≈ “Queen”? Can word meaning really do arithmetic?
  4. (Sharper) Do you still need to learn natural language processing in the age of large language model (LLM)?
  5. (Even sharper) Do you still need to learn programming in the age of LLM?

Let’s learn how to figure them out!

Plan of the course

A three-part journey: talk to the computerteach the computer to readteach the computer to “understand”

Programming Basic

  1. R Basics
  2. Data visualization

Text-As-Data Preparation

  1. Theory
  2. Data scraping
    • Regular expression*
    • Text Preprocessing

Text Analysis in Practice

  1. Word frequency analysis
  2. Classification
  3. Clustering
  4. Beyond “BOW”*

Prerequisite

  • You’ll learn the course a little more easily, if you’ve known
    • A little bit econometrics
    • A little bit programming
    • But you don’t have to

Why Taking the Course Now

“Can’t I just ask ChatGPT?”

LLMs already write code and read texts for me. Why should I, a liberal arts student, still learn programming and natural language processing?

The answer depends on your answers to two questions.

Your choice?

Q1: To get by, or to get strong?

  • Asking AI for code can complete a basic task — enough to get by.
  • But LLM-generated code (from ChatGPT & DeepSeek to Copilot) is still often
    • Incomplete or buggy;
    • Written in outdated syntax rather than today’s best solution.
  • Judging, fixing, and improving that code requires exactly what it was supposed to replace: your own programming ability.

Q2: To use AI, or to be used by AI?

  • Over half of college students already use generative AI regularly (闫伊乔 2025) — but in two very different ways:
    • Active users own the knowledge and can evaluate what the model returns; for them AI is an assistant.
    • Passive users merely relay answers from the chat box to the code box; for them AI is the teacher — no different from believing whatever the early internet said.
  • Knowing how programs run and how machines “read” text is what puts you on the active side: shaping the digital world instead of merely accepting it.

The one who uses AI, or the one used by AI — which will you be?

“But I’m a liberal arts student…”

Three misconceptions (based on interviews with students at universities across the country):

  • “Programming = math.”
    • Most data work needs only basic math — the computer does the calculating;
    • The core is logic: decomposing a complex problem into clear, ordered steps — a liberal arts strength.
  • “What can I even do with it?”
    • Without a goal, most learners quit after a few commands;
    • This course anchors every technique to real research questions.
  • “Recite V-E-C-T-O-R, vector…”
    • A language is never mastered by memorization but by use — so we practice from day one.

Three advantages you already have

  • A pure liberal arts student can go far
    • I majored in political science because it seemed math-free; now computational political science is my main field.
  1. Language sense: a programming language is an artificial language — far simpler than any natural language you have mastered; modern R reads almost like plain English.
  2. Imagination: reframe coding from mechanical operation to conversation (next slide).
  3. Problem-driven learning: you don’t need to become an engineer — keep asking “what can this do for my research?” and you’ll learn faster with less.

Programming as a conversation

  • Not typing commands at a machine, but talking with “little R”: a three-year-old genius
    • Computes anything, draws beautifully — but speaks only English, in short sentences;
    • Understands you only when every logical step is spelled out.
  • A “3-yr-old genius” theory
    • Errors are not failures — just a child saying “I don’t understand yet.”

      Errors are not failures — just a child saying “I don’t understand yet.”

Why R

What’s R

  • A high-level programming language (object-oriented programming)

What can R do

Statistics and econometrics.

Crunching almost any sizes of data.

Editing and running code from Excel, STATA, Python, C++, …

Scrape data from local files, websites, databases, pdf…

Create webpages

Write academic articles, books, or dissertations in html, pdf, or docx

Create presentation slides

Sending emails
……

What’s R good at

Analysis

Visualization

Set Up

Installation

Core

Integrated development environment (IDE)

Packages

Installation

install.packages("drhurCourse_1.0.0.tar.gz", repos = NULL, type = "win.binary")

Use

library(drhur) # or require(drhur)

drhur::drhur("algebra")

drhur

  • Software Installation
drhur(module, language = "en")
  • Programming module
    • Released version (2.0.0)
      • algebra
      • play
      • visual_basic
  • Text analysis (CAMS module)
    1. scrap
    2. regex*
    3. preprocess
    4. frequency
    5. classify

CAMS Module

  1. Download the files from the shared folder (see the link in the email)
  2. Install the source package in the shared folder by the following code
install.packages(<the_package_file>, type="source")

Reference

闫伊乔. 2025. “当大学生遇上大模型——人工智能会成为‘偷懒神器’吗.” 人民日报.