RAG and Vector Search · Exercise 1 of 5Next
Beginner
Analyse text into terms
Write tokenize(text): the lower-cased runs of letters and digits, in order.
Write stem(word): if the word ends in ies and is longer than 4 letters, replace ies with y. Otherwise, if it is longer than 3 letters, ends in s and does not end in ss, drop the final s. Otherwise return it unchanged.
Write analyze(text, stop): tokenise, remove the words in the set stop, then stem the rest. Return the list.
What Check tests
tokenizelower-cases and splits- Plural
sis removed iesbecomesy- Short words and
sswords survive analyzeremoves stop words, then stems
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.