From the course: Python: Programming Efficiently
Unlock the full course today
Join today to access over 22,700 courses taught by industry experts or purchase this course individually.
Challenge: Inverted index - Python Tutorial
From the course: Python: Programming Efficiently
Challenge: Inverted index
(bright upbeat music) - [Instructor] For your challenge, I'd like you to build an inverted index of the words in Shakespeare's sonnets. Using multi processing pool, to spread the work across multiple process source. This is a toy version of the MapReduce pipelines used by search engines to index the web. The inverted index should look like this. That is, every word across the collection of all sonnets should have its own line, listing all the sonnets they included with the line at which it appears. The sonnets are all included in your exercise files, here's one. To help you out, I'm going to give you a code that makes it partial and sorted index out of one file. Here's what we get for the 15th sonnet. It's okay that the same word appears in multiple lines, you need to reduce those instances into a single line, when you combine the files for multiple sonnets. Another hint, you can use the module glob, to list all the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
Computer architecture and optimization techniques1m 38s
-
(Locked)
Time profiling8m 19s
-
(Locked)
Memory profiling6m 42s
-
(Locked)
Algorithm complexity3m 24s
-
(Locked)
Introduction to parallel programming3m 49s
-
(Locked)
Challenge: Inverted index2m 18s
-
(Locked)
Solution: Inverted index1m 39s
-
(Locked)
-