RAG and Vector Search · Exercise 5 of 5 Previous
Advanced
Flag sentences the source does not support
words(text) and STOP are given. Write unsupported(sentences, source, cutoff=70) returning the list of sentences that should be flagged, in the original order.
A sentence is flagged when its support is below cutoff, or when it contains a number (a word of only digits) that does not appear in the source. Support is 100 * hits // total, where total is the number of its content words (words not in STOP) and hits is how many of those appear in the source's words. A sentence with no content words is never flagged.
What Check tests
- Supported sentences are not flagged
- A sentence with no overlap is flagged
- A wrong number is flagged even with high overlap
- The full result keeps the original order
- The cutoff is a parameter
- A sentence without content words is never flagged
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.