Programming, problem solving, and algorithms

CPSC 203, 2025 W2

April 7, 2026

Announcements

Text as Data

One Last Project

Suppose we’d like to understand the bonds between pairs of people in a book!

  • How can we find characters in a story?
  • How can we infer connections between characters?
  • How can we draw a graph?

Friends?

Given the text from a novel, how can we infer interaction or connections between characters? Discuss this question, and write down your ideas.

________________________________________

 

________________________________________

 

________________________________________

 

________________________________________

We Are Not the First

Starting From the Goal

 

The social network graph will have…

 

Vertices:

 

Edges:

Edges

We could consider every pair of people and check every paragraph for their presence.

  • Do you like this plan?

OR, we could

Edges

"I'm glad," said Anne quickly. "I couldn't really feel proud of keeping head of little boys and girls of just nine or ten. I got up yesterday spelling 'ebullition.' Josie Pye was head and, mind you, she peeped in her book. Mr. Phillips didn't see her—he was looking at Prissy Andrews—but I did. I just swept her a look of freezing scorn and she got as red as a beet and spelled it wrong after all."

  • What names appear?
  • What pairs should be tallied?
  • General observations:

Moving to the Middle

 

Given [[AS, JP, MP], [MP, PA], [AS, JP]],

  1. Could you create [AS, JP, MP, PA]?


  1. and {(AS,JP):2, (AS,MP):1, (JP,MP):1, (MP,PA):1}?

Demo

In the PL activity, load socnet_nb.py.