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
tokenizelower-cases and drops punctuationtokenize("")is an empty list- Shared words are counted
- Repeated words count once
- 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.