RAG and Vector Search · Exercise 1 of 6Next
Beginner
Rewrite a question with rules
Write rewrite_query(question, drop, fix) that lower-cases the question, splits it into runs of letters and digits, removes every word in drop, replaces words found in the dict fix, and joins the rest with single spaces.
A question that is all dropped words returns an empty string.
What Check tests
- Drops filler and fixes a typo
- Lower-cases and drops punctuation
- Nothing to drop, nothing to fix
- All words dropped gives an empty string
- Fixes are applied after dropping
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.