A similar-bug finder
Why it matters Half the bugs filed this week were filed before. A finder that shows "these three old reports look like yours" saves triage time and links fixes that were already made.
The bug tracker has 8,000 closed reports. When someone types a new report, the form should suggest the three most similar old ones, live, on a small server with a step budget. Similarity is word overlap, which is easy to explain to the people reading the suggestions.
The scoring rule
- Words: lowercase the text and take the runs of letters and digits (
re.findall(r"[a-z0-9]+", text.lower())), as a set, without the stop words given in the starter. - Score of a report: shared words divided by the number of words in either (
len(q & r) / len(q | r), the Jaccard index). - Return the ids of the
kbest reports with a score above 0, best first; ties go to the smaller id (ids are strings: compare them as strings).
idx = BugIndex([("BUG-1", "Checkout crash when the cart is empty"), ...])
idx.similar("crash in checkout with an empty cart") # -> ["BUG-1", "BUG-3"]Write a class BugIndex(reports), where reports is a list of (id, text), with a method similar(text, k=3) that applies the scoring rule. Use the STOP_WORDS from the starter. Budget: building the index over 8,000 reports and answering 150 queries may take at most 1,000,000 steps of your own code. Memory is not limited.
Spotted a problem in this lesson? Report it · Ask about this lesson
This exercise opens soon
Finish the lesson before it and this one unlocks. The whole course is free, no account needed, and you can read this lesson right now.
This browser is blocking cookies for learn.floati.life, so lessons you finished here cannot open in order. Allow cookies for this site and reload.