Skip to content
NLP/Playground

COMP90042 · Natural Language Processing · 2024 Semester 1

NLP Playground.

Two University of Melbourne coursework notebooks, rebuilt as three demos that run in your browser. Segment hashtags, guess where a tweet came from, and watch n-gram models play Hangman. Every algorithm is a direct TypeScript port of the original Python and is tested against the notebooks' own output. The results now come with confidence intervals, paired tests and decision records, and an optional LLM evaluation runs on your own API key.

Watch the tourthree captioned walkthroughs, about three minutes in all

Three demos

Pick a playground

Each demo runs entirely client-side, from small artefacts produced by re-running the original notebooks.

The brief, paraphrased

What the coursework asked

Two individual notebooks (eight and seven marked questions) with strict rules: Python 3.8, only the standard scientific stack, and output left in the notebook for marking.

Assignment 1 · 9% of the subject

Preprocessing and text classification

  1. 01Tokenise 943 tweets with NLTK's TweetTokenizer, lowercase them, drop tokens without letters and stop words, and build bags of words.
  2. 02Split hashtags into words with MaxMatch over NLTK's word list, using WordNet lemmas to match inflected forms.
  3. 03Run MaxMatch again from right to left and score both outputs with an add-one smoothed Brown unigram model.
  4. 04Make a stratified 70/15/15 split, then tune Naive Bayes and Logistic Regression on the development set only.
  5. 05Compare both models on the test set (accuracy and macro-F1) and inspect the top features for each country.

Assignment 2 · 8% of the subject

Language modelling in Hangman

  1. 01Split the alphabetic word types of the Brown corpus into a training set and a 1,000-word test set.
  2. 02Write a random baseline, then a unigram guesser and a guesser conditioned on word length.
  3. 03Build a character bigram model that scores each blank by its left neighbour.
  4. 04Design a better player with fewer than 7.6 mistakes on average for full marks, then explain the approach.

Key results

What the original notebooks reported

All figures come from the submitted notebooks. Re-running Assignment 1 reproduces every one of them. Assignment 2's train/test split depends on Python's hash seed, so its re-run lands within a few tenths, and the browser port matches that re-run word for word.
Tweet geolocation · 142 test tweets
ModelAccuracyMacro-F1
Naive Bayesalpha = 0.0530.3%[23.2%, 38.0%]0.303[0.220, 0.376]
Logistic RegressionC = 531.0%[23.2%, 38.7%]0.282[0.208, 0.346]

Brackets: 95% bootstrap intervals over the 142 test tweets. McNemar's exact test finds no evidence of a difference between the models (p = 1.00).

Hangman · average mistakes on 1,000 unseen words
Random16.20
Unigram10.14
Length-conditioned unigram10.09
Bigram8.67
My context n-gram (Q6)7.49

Submitted averages. The notebook kept no per-word results, so they have no interval. The reproducible re-run of my model averages 7.37, 95% confidence interval 7.13 to 7.62.

How it was revived

From notebook to browser

Accuracy was not tuned at all. The aim was to run the exact original methods somewhere people can try them.
  1. step 1

    Original notebooks

    The submitted .ipynb files, untouched in coursework/.

  2. step 2

    uv re-run scripts

    Run every notebook cell verbatim with pinned NLTK and scikit-learn, then check each cell's output against the submission.

  3. step 3

    Small artefacts

    Lexicon, WordNet exceptions, model weights and n-gram counts (about 2 MB, with no raw tweets).

  4. step 4

    TypeScript ports

    Tokeniser, lemmatiser, MaxMatch, classifiers and guessers, each with parity tests that compare against Python output.

About this project

Coursework, revived

These were individual assignments, written and submitted by Sunchuangyu (Rin) Huang for COMP90042 Natural Language Processing at the University of Melbourne in 2024 Semester 1. The original notebooks are kept unchanged in the repository for reference, which is private for now.

Academic integrity: please don't submit any part of this work as your own. The assignment specifications and the course-provided tweet dataset are not published here.

Subject
COMP90042 Natural Language Processing
University
University of Melbourne
When
2024 Semester 1 · Assignments 1 & 2
Author
Sunchuangyu (Rin) Huang (individual work)
Original stack
Python 3.8, NLTK, scikit-learn, NumPy, Jupyter
Revived stack
Next.js 16, React 19, TypeScript, Tailwind CSS 4, shadcn/ui, Vitest, uv