Command Palette

Search for a command to run...

Hectal
Phase 0: Start Here: What RAG Is and What You Will Build
RAG and Vector Search · Exercise 1 of 5Next
Beginner

Score passages by shared words

Write tokenize(text) that returns the lower-cased runs of letters and digits in text, in order (so "Shops open at 7 AM!" gives ["shops", "open", "at", "7", "am"]).

Write score(question, text) that returns how many different words the two texts share. A word repeated in either text counts once.

What Check tests

  1. tokenize lower-cases and drops punctuation
  2. tokenize("") is an empty list
  3. Shared words are counted
  4. Repeated words count once
  5. Case does not matter

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

main.py
Sign in to run your code.

Output

Press Run to see what your program prints.