Command Palette

Search for a command to run...

Hectal
Phase 8: Generation with Sources
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

  1. Supported sentences are not flagged
  2. A sentence with no overlap is flagged
  3. A wrong number is flagged even with high overlap
  4. The full result keeps the original order
  5. The cutoff is a parameter
  6. 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.