Challenge: Fuzzy Match Product Names
Swipe to start coding
You are given two lists of product names:
catalog_names— the official catalog entries;incoming_names— names provided by an external supplier with slight variations.
Your goal is to assign each supplier product name to the closest matching catalog name using the difflib library from the Python standard library.
Follow these steps:
- For each element of
incoming_names, compare it with every element ofcatalog_names. - Use the
SequenceMatcherclass from thedifflibmodule to calculate similarity scores. - For each incoming name, find the catalog entry with the highest similarity score.
- Store all matches in a dictionary named
matched_products, where keys are supplier names and values are the closest catalog names.
Make sure that the variable matched_products is declared and contains the correct matches.
Løsning
Tak for dine kommentarer!
single
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat
Can you explain this in simpler terms?
What are the main benefits or drawbacks?
Can you give me a real-world example?
Fantastisk!
Completion rate forbedret til 8.33
Challenge: Fuzzy Match Product Names
Stryg for at vise menuen
Swipe to start coding
You are given two lists of product names:
catalog_names— the official catalog entries;incoming_names— names provided by an external supplier with slight variations.
Your goal is to assign each supplier product name to the closest matching catalog name using the difflib library from the Python standard library.
Follow these steps:
- For each element of
incoming_names, compare it with every element ofcatalog_names. - Use the
SequenceMatcherclass from thedifflibmodule to calculate similarity scores. - For each incoming name, find the catalog entry with the highest similarity score.
- Store all matches in a dictionary named
matched_products, where keys are supplier names and values are the closest catalog names.
Make sure that the variable matched_products is declared and contains the correct matches.
Løsning
Tak for dine kommentarer!
single