Exam-style question
Try this first
A dictionary is used for information retrieval from the document "The green, green grass grows". Explain how the dictionary {"grass": 1, "green": 2, "grows": 1, "the": 1} represents the document, and explain how the key "green" can be used to retrieve information.
Model answer
What a good answer should say
- The dictionary contains one key for each distinct word in the document.
- The values record the number of occurrences of those words: "the" occurs once, "green" occurs twice, "grass" occurs once and "grows" occurs once.
- Letter case is ignored, so "The" is represented by the key "the".
- Using the key "green" accesses the value 2, showing that the word occurs twice.
Explanation
Why this works
This demonstrates both the key-value structure and a simple information retrieval application. A word is used as a key, and its associated count is retrieved as the value.
Common mistake
No common mistake is linked to this question yet.
