Command Palette

Search for a command to run...

Hectal
Phase 1: Search Before Vectors
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

  1. tokenize lower-cases and splits
  2. Plural s is removed
  3. ies becomes y
  4. Short words and ss words survive
  5. analyze removes 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.