Table of Contents
- Problem
- Can you tell how an actor behaves from what their characters say? Type "romantic scenes", get the actors who live there.
- What we built
- A pipeline that parses IMSDb scripts into per-actor dialogue, an emotion classifier, and a vector space model that ranks actors against your query.
- Stack
- Python, FastAPI, BERT, PostgreSQL, Prisma, Next.js, NextUI, Docker, Azure
- Team
- Lukas Welker, Patrik Lytschmann and me, for an NLP and IR course
- Outcome
- It works end to end, but the scores are honest: max F1 of 0.033, because the script corpus was too small.
Can dialogue rank actors?
The question that started this project: if you only know what an actor's characters say, can you rank them by theme? Type "heartbreaking roles" and get the actors whose dialogue actually breaks hearts, not just the famous ones.
We answered it with a five-step pipeline: scrape movie scripts from IMSDb and metadata from IMDb, split scripts into role-plus-dialogue, classify every line with an emotion model, average that into a vector per actor, then rank actors against a classified query in a vector space. Everything is exposed through a FastAPI backend and a small Next.js UI, deployed on Azure.
Scripts in, structured data out
The data model has five entities (ActorClassifier, Movie, Actor, Role, Script) because the whole idea hangs on one join: which actor said which line.
Crawling IMSDb's "all scripts" page with BeautifulSoup gave us a dataset of 1,192 movies. The hard part was the parser: every script has its own formatting and made-up character names, so scene-change detection and role extraction had to filter out everything that is not dialogue. Figure 2 shows what the raw text looks like.

The last step maps each (movie, role, line) to the IMDb actor behind the role. After this, "127 Hours / ARON / Nearly missed it!" becomes "James Franco, imdb 0290556", and every actor owns a corpus of lines.
Six emotions per line
For classification we used zbnsl/bert-base-uncased-emotionsModified, a BERT base model fine-tuned on the go_emotions dataset. Given any text it returns six scores: love, joy, fear, anger, sadness and surprise.
We run it twice on purpose: once over every script part for every actor, and once over the user's query. Both sides end up in the same six-dimensional space, which is what makes them comparable.

Ranking by similarity and fame
Each actor becomes the average of their classified script parts, a single vector in the emotion space. Cosine similarity between that vector and the query vector gives a first ranking.
That alone has a flaw we caught early: an actor with one perfectly matching line scores near 1.0 and outranks actors with hundreds of relevant lines. So the final score adds a "fame" coefficient proportional to how much dialogue an actor actually has: similarity carries most of the weight, involvement breaks the tie. The dictionary of weighted scores is sorted descending and the top k comes back.
API and interface
The ranking is exposed through FastAPI so any client can query it, and a Next.js/NextUI frontend wraps it for interactive search. The full app ships as a Docker image on Azure App Service.
Search Classifier Actor
Search Token Actor

The honest verdict
We evaluated against hand-built ground truth: six queries, each with a top-20 actor list compiled from IMDb lists and other sources, scored on precision, recall and F1 with a 15% fame weight.

The scores are low: mean recall 0.042, mean precision 0.008, best F1 0.033. That is the honest result, and the reason is data, not math. Our corpus simply lacks scripts: Henry Cavill has not a single line of dialogue in the database, so he cannot rank no matter how well the model works.
What I take from it: the pipeline is sound, the ingredients were thin. A bigger script corpus, fine-tuning the classifier on movie dialogue, and more than six emotion dimensions would all move the numbers. The 15% fame weight itself is a knob we set by hand; an evolutionary search over factor weights was the obvious next step we did not have time for.