Exercise 3 SOLUTION: The Map-Reduce Pattern of Parallelism


This exercise aims to illustrate the characteristics of the Map-Reduce parallel pattern by means of the Spark programming model.

Prelude: Introduction to Spark

Spark is a framework for parallel distributed data processing on a set of commodity machines. It frees the user from duties like task scheduling, data transfer and fault tolerance, so that they can focus on programming.

The Spark programming model uses the Map-Reduce model as a basis, simplifying its usage and extending it with more functionality. The following are two basic concepts in Spark:

  • Resilient Distributed Datasets (RDDs): an RDD is a distributed collection of items. The collection is divided in partitions, and these partitions are the units of parallelism.
  • Transformations and actions: the user can apply either transformations or actions on RDDs. Transformations are lazy, they are not applied right away, unlike actions. In other words, one can apply a chain of transformations to an RDD, but only when appending an action to that chain the whole computation graph will start executing. map is an example of a transformation, while reduce is an action. However, Spark is not limited to just map and reduce: it offers a rich variety of functional-style operators. Although we will not use all those operators in this exercise, you can find a complete list here.

As for the language, Spark programs can be developed in Scala, Java and Python. The latter will be used in this exercise.

1. Map-Reduce on a collection of elements

Map-Reduce is a combination of two patterns of parallelism:

  • Map: given a collection of elements of type $X$, apply a function $F_{map}$ to each element that returns a single element of type $Y$.
  • Reduce: given a collection of elements of type $Y$, combine its elements into an element of type $Y$ using a function $F_{reduce}$.

These two patterns can be chained to obtain a single result from a collection of elements:

$(X_{1},~X_{2},~...,~X_{n})~\xrightarrow{F_{map}}~(Y_{1},~Y_{2},~...,~Y_{n})~\xrightarrow{F_{reduce}}~Y_{result}$

Spark implements these patterns via two operators, map and reduce. Both receive a function as parameter; in the case of map, the function must receive one parameter of type $X$ and return a value of type $Y$; regarding reduce, the function must receive two parameters of type $Y$ and return a value of type $Y$.

First example

Let's start with a simple example of how to run a Map-Reduce chain with Spark.

First we will perform some initialisation of the Spark library. In particular, we will create a SparkContext object that we will use later.

In [1]:
from pyspark import SparkContext
sc = SparkContext()

Next we will create our first RDD, i.e. a collection of elements in Spark. In this case, the collection is a list of numbers.

In [2]:
rdd = sc.parallelize([1, 2, 4, 8])

Let's now map a function to our collection to increment each of its elements. We will first define such function:

In [3]:
def increment(x):
    return x + 1

We can now apply the increment function to every element in our collection via the map operator.

In [4]:
incrementedRDD = rdd.map(increment)

You can actually check the incremented values with the collect function of Spark. Note that with the statement above you just scheduled a calculation which is not executed by the Spark runtime: map is indeed a transformation. The actual work is triggered by an action, such as collect or reduce.

In [5]:
incrementedRDD.collect()
Out[5]:
[2, 3, 5, 9]

Let's suppose we would like to obtain the sum of all the numbers in the collection. For that purpose, we can use reduce and a function that returns the sum of two numbers.

In [6]:
def add(x, y):
    return x + y

Spark's reduce functionality will apply add to our collection, adding its elements two by two until calculating the total sum.

In [7]:
totalSum = incrementedRDD.reduce(add)
totalSum
Out[7]:
19

Note that you can also do the same calculation in a single Map-Reduce chain:

In [8]:
rdd.map(increment).reduce(add)
Out[8]:
19

Exercise to complete

Now that you became familiar with the Map-Reduce pattern and its implementation in Spark, we propose you an exercise to apply what you just learned to a different problem.

In this case, our collection will be a list of town names:

In [9]:
names = sc.parallelize(['Madrid', 'Geneva', 'Barcelona', 'Milano', 'Mamungkukumpurangkuntjunya'])

Suppose we would like to know the length of the longest name in our list.

First, we need a function that receives a string and returns its length (hint: you can use the len Python function).

In [10]:
def length(s):
    return len(s)

Now define another function that, given two numbers, returns the maximum.

In [11]:
def maximum(x, y):
    return max(x, y)

Finally, combine the two functions you just defined in a Map-Reduce chain to obtain the desired result.

In [12]:
names.map(length).reduce(maximum)
Out[12]:
26

2. Map-Reduce on text files: Word Count

A typical real-life example where the Map-Reduce pattern is applied is the processing of text files like, for instance, logs generated by a web server.

In this second part of the exercise, you will process a text file and count the occurrences of each word in it.

Prepare input data

First we will download the input file for this exercise, which corresponds to the Complete Works of William Shakespeare, offered by Project Gutenberg.

In [13]:
!curl  -o 100.zip https://swanserver.web.cern.ch/swanserver/csc/100.zip
!unzip -o 100.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1988k  100 1988k    0     0   230k      0  0:00:08  0:00:08 --:--:--  251k
Archive:  100.zip
  inflating: 100.txt                 

Next we will use Spark to create a collection out of this text file. In the collection, every line of the file will be an element.

In [14]:
textFile = sc.textFile('100.txt')

textFile is a collection where each element is a string corresponding to a line in the text file.

Introducing new operations

The Map-Reduce chain to count the ocurrences of each word in the file is a bit more complicated than what we have seen so far. The chain will contain two map operations and one reduce. In addition, you will have to use some new operators, which are a slight variation of the map and reduce you already know:

  • flatMap: if the user function $F_{map}$ returns a collection of values instead of single value, flatMap decomposes the collection into individual elements in the final result.


  • reduceByKey: like in the case of reduce, the function $F_{reduce}$ passed as parameter of reduceByKey receives two elements of type $Y$ and returns an element of the same type. However, reduceByKey is applied on collections of key-value pairs, that is, $( ~(key_{1},val_{x}),~(key_{2},val_{y}),~(key_{1},val_{z}),~...~)$, and the output is the reduction of the values for each key $( ~(key_{1}, red_{1}),~(key_{2},red_{2}),~...~)$.

Functions

Let's now define the functions that will be applied in the Map-Reduce chain. First, you will need a function that splits a line of the text file in a list of words (hint: you can use the split Python function and return words with non alphanumeric characters).

In [15]:
def splitWords(line):
    return line.split()

The second function you will need receives a word and returns a key-value pair, where the key is the word and the value is 1 (its partial count).

In [16]:
def count(word):
    return (word, 1)

Finally, you will need a function that receives two numbers and returns their sum.

In [17]:
def add(x, y):
    return x + y

Map-Reduce chain

To finish this exercise, combine the three functions you just defined in a chain to get the counts per word in the file.

In [18]:
wordCounts = textFile.flatMap(splitWords).map(count).reduceByKey(add)

Let's see if you got it right...

In [19]:
wordCounts.collect()
Out[19]:
[(u'fawn', 11),
 (u'considered-', 1),
 (u'Fame,', 3),
 (u'mustachio', 1),
 (u'protested,', 1),
 (u'sending.', 3),
 (u'offendeth', 1),
 (u'instant;', 1),
 (u'scold', 4),
 (u'Sergeant.', 1),
 (u'nunnery', 1),
 (u'Sergeant,', 2),
 (u'swoopstake', 1),
 (u'unnecessarily', 1),
 (u'whither?', 3),
 (u'out-night', 1),
 (u"'Fiend,'", 1),
 (u'Retreat', 2),
 (u'Love-thoughts', 1),
 (u'spider.', 1),
 (u'spider,', 4),
 (u'chameleon,', 1),
 (u'Remorse?', 1),
 (u"suck'd.", 1),
 (u'slandered,', 1),
 (u"imagin'd", 6),
 (u'Officer.]', 3),
 (u"cropp'd", 4),
 (u'wooden', 8),
 (u'ha!-hey', 1),
 (u'Sack', 2),
 (u'abatements', 1),
 (u'laments,', 2),
 (u'animals!', 1),
 (u'chin;', 1),
 (u'groats;', 1),
 (u'helm?', 1),
 (u'consenting', 2),
 (u'nature,', 61),
 (u'nature.', 31),
 (u"madman's", 4),
 (u'accessed,', 1),
 (u'nature:', 1),
 (u'crouch', 2),
 (u'chins', 2),
 (u'fire-', 2),
 (u'chine', 1),
 (u'titles,', 5),
 (u"fear?'", 1),
 (u'titles.', 1),
 (u"sluic'd", 1),
 (u'meteors?', 1),
 (u'SPIRITS,', 1),
 (u'letters-this', 1),
 (u'discretion?', 1),
 (u'clapper-de-claw', 1),
 (u'error:', 1),
 (u'Tubal.', 3),
 (u'error,', 7),
 (u'error.', 4),
 (u'circumstance,', 7),
 (u'castaways,', 1),
 (u'circumstance.', 5),
 (u'him-no', 1),
 (u'popular?', 1),
 (u'Pantheon.', 1),
 (u'circumstance:', 1),
 (u'befits,', 1),
 (u"'Thisne,", 1),
 (u'Love-news,', 1),
 (u'oft;', 2),
 (u'sternest', 1),
 (u'oft?', 1),
 (u'Indeed,', 50),
 (u'vicegerent', 1),
 (u'leading,', 1),
 (u'Vernon', 2),
 (u'music', 83),
 (u'oft-', 1),
 (u'mutinies', 3),
 (u"oft'", 1),
 (u'Biddy,', 1),
 (u'ability,', 3),
 (u'pregnantly', 1),
 (u'stumps', 4),
 (u'unpack', 1),
 (u'prophecies', 3),
 (u'locked', 1),
 (u'degrees;', 1),
 (u'degrees?', 1),
 (u'Boys.', 2),
 (u'Boys,', 3),
 (u'familiarity-', 1),
 (u'turtle-doves', 1),
 (u'rocks.', 2),
 (u'wand', 1),
 (u'reported.', 3),
 (u'husband;', 15),
 (u'Varro.]', 1),
 (u'want', 109),
 (u"by'r", 8),
 (u'slavery,', 1),
 (u"by't", 1),
 (u'well-armed', 1),
 (u"Vouchsaf'd", 1),
 (u'rites?', 1),
 (u'Turk!', 1),
 (u"unhang'd", 1),
 (u'travel', 20),
 (u'passable.', 1),
 (u'Hyrcania.', 1),
 (u'Promise', 2),
 (u'canaries', 1),
 (u'cadence', 1),
 (u'Voice,', 1),
 (u'arch-villain', 1),
 (u'L.', 1),
 (u'wood,', 13),
 (u'halloing', 2),
 (u"greatness,'-", 1),
 (u'wrong', 112),
 (u'scornfully.', 1),
 (u'wood.', 7),
 (u"engag'd", 8),
 (u'pint,', 1),
 (u'ruled.', 1),
 (u'whore?', 4),
 (u'Hyrcanian', 2),
 (u'prophesier.', 1),
 (u'hair]', 1),
 (u'effect.', 8),
 (u'whore;', 3),
 (u'effect,', 9),
 (u'halfpence.', 1),
 (u'whizzing', 1),
 (u'fowls', 1),
 (u'crave-', 1),
 (u'Rogues,', 1),
 (u'shears', 4),
 (u"tam'd", 4),
 (u'ostent,', 1),
 (u'welcomer', 1),
 (u'Hit', 1),
 (u'lovers.', 1),
 (u'fit', 123),
 (u'bringing', 14),
 (u'fix', 3),
 (u'worms.', 2),
 (u'worms,', 5),
 (u'Hid', 1),
 (u'Hydra-headed', 1),
 (u'welcome,', 54),
 (u'welcome.', 61),
 (u'backing!', 1),
 (u'whore!', 3),
 (u'twits', 1),
 (u"faults.'", 2),
 (u'peu,', 1),
 (u'Will!', 1),
 (u'Nurture', 1),
 (u'Genitive:', 1),
 (u'bankrupt,', 2),
 (u'truant!', 1),
 (u'troublous', 4),
 (u'seven;', 1),
 (u'arrow', 5),
 (u'Combine', 2),
 (u'Abbot,', 2),
 (u'Wales.', 13),
 (u'Wales,', 19),
 (u'windmill', 2),
 (u'Perchance', 19),
 (u'correct,', 1),
 (u'Dorothy;', 1),
 (u"Qu'ai", 1),
 (u'allay', 9),
 (u'Beget', 1),
 (u'love-song.', 1),
 (u'self-', 3),
 (u'self)', 1),
 (u'persisted', 1),
 (u'gradation', 1),
 (u'self?', 2),
 (u'encourage', 3),
 (u'hobby-horse,', 2),
 (u"stock'd", 1),
 (u'ALENCON,', 11),
 (u'sheep', 16),
 (u"Express'd", 2),
 (u'wreaks,', 1),
 (u"endur'd!", 2),
 (u'Sneak.', 1),
 (u"endur'd;", 1),
 (u'sheet', 6),
 (u'revolutions.', 1),
 (u'numbness,', 1),
 (u'giglets', 1),
 (u'nuncle.', 2),
 (u'nuncle,', 11),
 (u'Italy-', 1),
 (u'ANTHONY', 2),
 (u'fruit,', 4),
 (u'guardians,', 1),
 (u'Italy?', 1),
 (u'Musicians.', 4),
 (u'Italy;', 6),
 (u"'cerns", 1),
 (u'disfigured', 1),
 (u'maladies', 2),
 (u'lusts;', 1),
 (u'clamorous', 11),
 (u'Deepvow,', 1),
 (u'reward,', 4),
 (u'reward.', 9),
 (u'service', 110),
 (u"sentenc'd-", 1),
 (u"Sinon's", 1),
 (u'lisping,', 1),
 (u'master', 202),
 (u'DOLABELLA,', 3),
 (u'DOLABELLA.', 23),
 (u"perturb'd", 1),
 (u'positively', 1),
 (u"displac'd;", 1),
 (u'Barnardine', 6),
 (u'old;', 6),
 (u'old?', 2),
 (u'old!', 1),
 (u'idle', 57),
 (u'sheen', 1),
 (u'Prologue,', 1),
 (u'Bassanio', 13),
 (u'Prologue.', 1),
 (u'SPEED', 7),
 (u'heads!', 2),
 (u'longs', 8),
 (u'Generally', 1),
 (u'Eve,', 3),
 (u'targe', 1),
 (u'undutiful.', 1),
 (u'meekness,', 1),
 (u'thaw', 2),
 (u'heads?', 1),
 (u'Thump,', 1),
 (u'Thump.', 1),
 (u'poorest,', 2),
 (u'wholesome', 28),
 (u'Thee', 14),
 (u'They', 490),
 (u'willing,', 5),
 (u'willing.', 2),
 (u'long;', 17),
 (u'long?', 7),
 (u'withdraw', 15),
 (u'pelting', 6),
 (u'sights;', 2),
 (u"scann'd.", 2),
 (u'toil', 13),
 (u"scann'd,", 1),
 (u'mouth', 64),
 (u'[Locking', 1),
 (u'reverence', 20),
 (u'blanks,', 2),
 (u'long!', 3),
 (u'Encore', 1),
 (u'expound', 3),
 (u'singer', 1),
 (u'unripe,', 1),
 (u"whosoe'er", 1),
 (u'nettle', 2),
 (u'inseparable,', 1),
 (u'ache,', 3),
 (u'heads]', 2),
 (u'habiliments,', 1),
 (u'affair.', 7),
 (u"sepulchre!'", 1),
 (u'affair,', 1),
 (u'hermitage,', 2),
 (u'serving-man', 4),
 (u'gives.', 2),
 (u'plat,', 1),
 (u'tempter', 2),
 (u'audacity?', 1),
 (u'fennel', 1),
 (u'ulcer', 1),
 (u'hooded,', 1),
 (u'tempted', 10),
 (u"father's?", 2),
 (u'starlight.', 1),
 (u'chirurgeonly.', 1),
 (u'kerns', 4),
 (u"baby's", 1),
 (u'neighs', 2),
 (u'bliss', 5),
 (u'fortitude,', 2),
 (u'Senator,', 1),
 (u'Mark,', 7),
 (u'Mark.', 2),
 (u'moated', 2),
 (u'affronted', 1),
 (u'Sardians,', 1),
 (u'FLORENCE', 1),
 (u'nicely', 7),
 (u'eyelids', 11),
 (u'Rid', 2),
 (u'neigh!', 1),
 (u"shak'd;", 1),
 (u"knock'd", 9),
 (u"tarr'd", 1),
 (u'weird', 6),
 (u'Meetest', 1),
 (u'Bullen!', 2),
 (u'murky.', 1),
 (u'plaintful', 1),
 (u'droven', 1),
 (u"Clapp'd", 3),
 (u'advantaged,', 1),
 (u'Here;', 3),
 (u'wage', 7),
 (u'pardoned,', 1),
 (u'extend', 14),
 (u'visions;', 1),
 (u'embracement', 1),
 (u'Perchance?', 1),
 (u'crystals.', 1),
 (u'Jarteer-have', 1),
 (u'extent', 5),
 (u'Here!', 4),
 (u'lot;', 1),
 (u'Near!', 1),
 (u'fifth', 7),
 (u'incense', 9),
 (u'Advance,', 1),
 (u"compil'd,", 1),
 (u'Bullens', 1),
 (u'Lamentings', 1),
 (u'mortified', 4),
 (u'doubt,', 32),
 (u'doubt.', 9),
 (u"Maintain'd", 1),
 (u'Mantuan,', 1),
 (u'charnel', 2),
 (u"Archdeacon's", 1),
 (u'surname', 1),
 (u"whoso'er", 1),
 (u'doubt:', 1),
 (u'sixteen,', 1),
 (u'union', 5),
 (u'fro', 3),
 (u'cue', 5),
 (u'Leonatus,', 3),
 (u'muck', 1),
 (u'-they', 1),
 (u'Christopher', 2),
 (u'Ingrateful,', 1),
 (u"'Anon", 1),
 (u"follow'd", 17),
 (u'wags', 2),
 (u'spit', 20),
 (u"Wash'd", 1),
 (u'right-hand;', 1),
 (u'back-wounding', 1),
 (u'spin', 3),
 (u'such-like', 5),
 (u'Shave', 1),
 (u'Beware', 8),
 (u'crupper', 1),
 (u'employ', 19),
 (u'misconstrued', 2),
 (u'Call', 108),
 (u'south;', 1),
 (u'consent,', 24),
 (u'Launces', 1),
 (u'Sword', 1),
 (u'consent:', 1),
 (u'Sworn', 1),
 (u'title-leaf,', 1),
 (u'bricklayer', 1),
 (u'memorial', 3),
 (u"accomplish'd;", 2),
 (u'Harsh,', 1),
 (u'visitations', 1),
 (u'Lucetta.', 1),
 (u'Lucetta,', 5),
 (u'Launce!', 2),
 (u'marches', 5),
 (u"disclos'd,", 3),
 (u"disclos'd.", 1),
 (u"scal'd", 1),
 (u"'Hermione,", 1),
 (u'Launce?', 1),
 (u'masters--', 1),
 (u'differences,', 2),
 (u'differences.', 1),
 (u'provincial.', 1),
 (u'visitation-', 1),
 (u'brine,', 2),
 (u'Unbuckling', 1),
 (u'visitation;', 1),
 (u'stillness', 5),
 (u'visitation?', 1),
 (u'stringless', 1),
 (u'corporate', 1),
 (u'AEDILE', 6),
 (u'jointure', 1),
 (u'elder.', 5),
 (u'elder,', 4),
 (u'Eternity', 1),
 (u'Blame', 1),
 (u'Basting.', 1),
 (u'had', 1222),
 (u'speeches?', 2),
 (u'beloved', 22),
 (u'hap', 18),
 (u'marring.', 1),
 (u'confection', 1),
 (u'continuantly', 1),
 (u'Deputing', 1),
 (u'wag!', 1),
 (u'shadow', 46),
 (u'lass,', 1),
 (u'joineth', 1),
 (u'ha,', 21),
 (u'stanze,', 1),
 (u"resolv'd!", 1),
 (u'executing,', 1),
 (u"resolv'd;", 2),
 (u'upon?', 4),
 (u'espouse.', 2),
 (u'beneficial', 3),
 (u'disdain,', 6),
 (u'crowd', 3),
 (u'Macduff,', 10),
 (u'scathe', 4),
 (u'crown', 120),
 (u'cheeks.', 10),
 (u'disdain:', 2),
 (u'Call!', 1),
 (u'treaty.-', 1),
 (u'speeches-', 1),
 (u'haste-post-haste', 1),
 (u'perchance', 21),
 (u'fencing,', 2),
 (u'soon.-', 1),
 (u'Calls', 6),
 (u'crow.', 4),
 (u'crow,', 7),
 (u'Mislead', 1),
 (u"reach'd.", 1),
 (u"incorps'd", 1),
 (u'commends;', 1),
 (u'JULIET.', 7),
 (u'bencher', 1),
 (u'OCTAVIA]', 1),
 (u'ingenious?', 2),
 (u'sodden-witted', 1),
 (u'Incite', 1),
 (u'Aaron', 9),
 (u'dites-moi', 1),
 (u'shoots', 5),
 (u'SUFFOLK,', 14),
 (u'SUFFOLK.', 138),
 (u'due.', 6),
 (u'due,', 8),
 (u'serving,', 1),
 (u'suffice', 5),
 (u'humble,', 2),
 (u'humble.', 3),
 (u'fore-goers.', 1),
 (u"spleen.'", 1),
 (u'Count;', 3),
 (u'shoot]', 1),
 (u'rook.', 1),
 (u'Count?', 3),
 (u'rapes', 1),
 (u'footman,', 3),
 (u'revenues,', 2),
 (u'revenues.', 2),
 (u'being!', 1),
 (u'Kept', 3),
 (u'footman.', 1),
 (u'being-', 1),
 (u"hallow'd", 4),
 (u'perfumed', 4),
 (u'Roast', 1),
 (u'being;', 1),
 (u'groom,', 1),
 (u'groom.', 7),
 (u'humbled', 7),
 (u'rape-', 1),
 (u'County', 18),
 (u'Armagnac?', 1),
 (u'Counts', 1),
 (u'despise;', 1),
 (u'crown]', 4),
 (u'Garden,', 1),
 (u'disgrace', 30),
 (u"ancient'st", 1),
 (u'palm?', 1),
 (u'palm;', 1),
 (u'extenuates', 1),
 (u'Striding', 1),
 (u'superficially.', 1),
 (u'paperwork', 1),
 (u"Paul's", 2),
 (u'minds!', 3),
 (u'minds-', 2),
 (u"as's", 1),
 (u'crowns', 23),
 (u'tamely', 1),
 (u'sunset', 3),
 (u'minds;', 1),
 (u"prick-ear'd", 1),
 (u"gone.'", 1),
 (u'Semiramis.', 1),
 (u'intend', 40),
 (u'palms', 2),
 (u'palmy', 1),
 (u'Harfleur,', 2),
 (u'intent', 26),
 (u'variable', 4),
 (u'crown?', 15),
 (u'Samingo.', 1),
 (u"between's.", 2),
 (u'palm]', 1),
 (u'commended,', 1),
 (u'crown-', 1),
 (u'crown!', 2),
 (u'penance.', 3),
 (u"happ'd!", 1),
 (u'chain', 30),
 (u'stay,', 34),
 (u'scalps', 1),
 (u'stay.', 37),
 (u'chivalry!', 1),
 (u'chivalry?', 1),
 (u"berhym'd", 1),
 (u'chivalry;', 2),
 (u'by-peeping', 1),
 (u"conceit's", 1),
 (u'chair', 16),
 (u'stay:', 2),
 (u'foaming', 5),
 (u'cook;', 1),
 (u'cook?', 2),
 (u"squand'ring", 1),
 (u"'fool'--a", 1),
 (u'disgracious', 2),
 (u'cook-', 1),
 (u'apt!', 1),
 (u'child:', 1),
 (u'just;', 4),
 (u'By,', 1),
 (u'Barren', 2),
 (u'exact', 6),
 (u'minute', 25),
 (u'honour:', 2),
 (u'cooks', 1),
 (u'just?', 2),
 (u'Tax', 1),
 (u'pursue', 20),
 (u'continuate', 2),
 (u'formally', 1),
 (u'Tan', 1),
 (u'supply.', 1),
 (u'Maccabaeus.', 2),
 (u'Maccabaeus,', 1),
 (u"MASTER'S", 1),
 (u'brows!', 2),
 (u'Silvia', 23),
 (u'chopping', 1),
 (u'if-Lord', 1),
 (u"measur'd", 8),
 (u'Gaunt;', 1),
 (u'dust;', 3),
 (u'Count-Cardinal', 1),
 (u'dust?', 3),
 (u'grief-shot', 1),
 (u'wayward', 10),
 (u'celebrates', 1),
 (u'Me', 19),
 (u'Ma', 2),
 (u'shirt.', 3),
 (u'Julius!', 1),
 (u'shirt,', 3),
 (u'Dew,', 2),
 (u'Europe;', 1),
 (u'madame,', 1),
 (u'madame.', 5),
 (u'Europe!', 1),
 (u'trail,', 2),
 (u'My', 1631),
 (u'climb]', 1),
 (u'dusty', 2),
 (u'cette', 1),
 (u'accomplished', 1),
 (u'conjectures;', 1),
 (u'rider.', 1),
 (u'taught.', 1),
 (u'Double,', 3),
 (u'READ', 1),
 (u'reaps;', 1),
 (u'Enough', 8),
 (u'betraying', 2),
 (u"be.'", 2),
 (u"recompens'd", 2),
 (u'Cerberus,', 1),
 (u'slept,', 8),
 (u'slept.', 4),
 (u'working', 13),
 (u'untaught', 3),
 (u'Remorseless,', 1),
 (u'vigour', 9),
 (u'Those', 79),
 (u'[dead]', 1),
 (u'bear-baitings.', 1),
 (u'contraries?', 1),
 (u"join'd-stool.", 1),
 (u'Satan?', 2),
 (u'wonders,', 1),
 (u'wonders.', 3),
 (u'Satan!', 1),
 (u'wonders:', 1),
 (u'PERSONAL', 221),
 (u'following', 41),
 (u'heard:', 1),
 (u"head-lugg'd", 1),
 (u"fool'ry.", 1),
 (u"'Alas,", 1),
 (u'heard.', 15),
 (u'parish.', 1),
 (u'heard,', 20),
 (u'meddle.', 1),
 (u'Exton,', 3),
 (u"overpass'd", 1),
 (u'restitution,', 1),
 (u'restitution.', 2),
 (u'pantler,', 1),
 (u'enfranchisement,', 1),
 (u'purple-hued', 1),
 (u"Nature's,", 1),
 (u'thunder.', 6),
 (u'thunder,', 11),
 (u'thanking', 1),
 (u'world--if', 1),
 (u'Bare', 1),
 (u'Readins,', 1),
 (u'meddler', 1),
 (u'lock.', 1),
 (u'Dardanius!', 1),
 (u'Hum,', 1),
 (u'mirror,', 1),
 (u'Corporate', 1),
 (u'admire;', 1),
 (u'temperate', 6),
 (u'doom:', 4),
 (u'accessary.', 1),
 (u'speakest', 4),
 (u'proudly;', 1),
 (u'Cobweb?', 1),
 (u'Cobweb!', 1),
 (u'("the', 1),
 (u'doom,', 6),
 (u'Degenerate', 1),
 (u'skirmish', 2),
 (u'wolves', 9),
 (u"damned'st", 1),
 (u'below!', 2),
 (u'marshalship,', 1),
 (u'confounded,', 2),
 (u'professors', 2),
 (u'yearn', 1),
 (u'unsuitable', 1),
 (u'nymph,', 4),
 (u'below;', 2),
 (u'Messaline;', 1),
 (u'dead;', 31),
 (u'dead?', 36),
 (u"Fancy's", 1),
 (u'compasses,', 1),
 (u'infirmities', 3),
 (u'SCALES.', 2),
 (u'troubles', 9),
 (u'dead-', 7),
 (u'dead!', 29),
 (u'did;', 18),
 (u'year:', 1),
 (u'thine,', 47),
 (u'thine.', 43),
 (u'bashful', 5),
 (u'year,', 17),
 (u'year.', 16),
 (u'Courteous;', 1),
 (u'thine:', 1),
 (u'trouble?', 3),
 (u'tongues?', 3),
 (u'trouble;', 5),
 (u'tongues;', 4),
 (u'tongues-', 1),
 (u'leather', 8),
 (u'tongues!', 1),
 (u'next.', 8),
 (u'presages', 3),
 (u'remembrance', 44),
 (u'Live', 21),
 (u'entering', 2),
 (u'impositions,', 1),
 (u'paper.]', 3),
 (u'learnings', 1),
 (u'Owen,', 1),
 (u'bards,', 1),
 (u'presageth', 3),
 (u'seriously', 3),
 (u'Drums', 2),
 (u'briefly;', 1),
 (u'marl?', 1),
 (u'disaster.', 1),
 (u'(wide', 1),
 (u'curbs', 4),
 (u'Pandarus-', 1),
 (u'foul-play;', 1),
 (u'maypole?', 1),
 (u'inwardly', 2),
 (u'growth,', 1),
 (u'growth.', 3),
 (u'evermore,', 1),
 (u'evermore.', 2),
 (u'voluntaries,', 1),
 (u'workmanship', 1),
 (u'learning;', 1),
 (u'modest', 30),
 (u"wand'rest", 1),
 (u'BEADLES,', 1),
 (u'Since,', 4),
 (u'saving', 9),
 (u'traducement,', 1),
 (u'Ventidius!', 2),
 (u'herd,', 4),
 (u'herd.', 1),
 (u'reprisal', 1),
 (u'Fates', 4),
 (u'WATCHMAN.', 13),
 (u'surge,', 3),
 (u'surge.', 1),
 (u'Elizabeth,', 2),
 (u'affords', 7),
 (u"'almost", 1),
 (u'Monday', 4),
 (u'put-tock,', 1),
 (u'stifled', 3),
 (u'grew.', 1),
 (u'half-caps', 1),
 (u'Polixenes;', 2),
 (u'eaves,', 1),
 (u'on.', 125),
 (u'PRIEST.', 3),
 (u'on,', 168),
 (u'spoke.', 7),
 (u'spoke,', 12),
 (u'didst,', 3),
 (u'Hallowmas,', 1),
 (u'didst.', 2),
 (u'on:', 3),
 (u'afford?', 1),
 (u'afford;', 1),
 (u'Fate;', 1),
 (u'1.E.7', 2),
 (u'garden-house', 1),
 (u'Balthazar;', 1),
 (u'tickle-brain.-', 1),
 (u"Cleopatra's", 3),
 (u'Hubert', 3),
 (u"excellence!'", 1),
 (u'wandering', 4),
 (u'top-branch', 1),
 (u'sumptuous', 3),
 (u'turned', 10),
 (u'jewels', 19),
 (u'balsam', 1),
 (u"o'erflourish'd", 1),
 (u'Themselves', 1),
 (u'jewel]', 1),
 (u'horsemanship.', 2),
 (u'touch;', 6),
 (u'affects.', 2),
 (u'Instance,', 3),
 (u'touch!', 2),
 (u'venue', 1),
 (u'intends', 11),
 (u'Hale', 1),
 (u'Land,', 2),
 (u'frail.', 3),
 (u'Katherina!', 1),
 (u'jewel?', 4),
 (u'jewel;', 3),
 (u'sober-blooded', 1),
 (u'discerning', 1),
 (u'buffet', 4),
 (u'jewel-', 1),
 (u'dishabited,', 1),
 (u'intend!', 1),
 (u"bloody-scepter'd,", 1),
 (u'Hal;', 3),
 (u'Hal?', 8),
 (u'Hal!', 4),
 (u'warrior.', 1),
 (u'warrior,', 4),
 (u'intend;', 2),
 (u'Hal-', 2),
 (u'valleys.', 1),
 (u'booty;', 1),
 (u'sovereignest', 1),
 (u'Juliet.', 14),
 (u'mores,', 1),
 (u'Ursula', 1),
 (u"windpipe's", 1),
 (u'Pless', 3),
 (u"play'd.", 2),
 (u"play'd,", 2),
 (u'rejoice?', 1),
 (u'Forbear', 9),
 (u'try;', 1),
 (u'3', 5),
 (u'Bianca', 15),
 (u'Custalorum.', 1),
 (u'intelligencing', 1),
 (u'Trinculos?', 1),
 (u'tutor.', 2),
 (u'men-"', 1),
 (u'guile,', 1),
 (u'caves,', 1),
 (u'hindmost', 1),
 (u"Overdone's", 2),
 (u'please-man,', 1),
 (u'tilting', 3),
 (u"'rt", 3),
 (u're-view', 1),
 (u'rejoices', 2),
 (u'imagine,', 2),
 (u'halfpence,', 1),
 (u'imagine.', 3),
 (u"dismay'd?", 1),
 (u"dismay'd;", 2),
 (u'Nerissa?', 1),
 (u'ensemble:', 1),
 (u'seeting', 1),
 (u'affairs,', 12),
 (u'vision', 8),
 (u'Stood', 11),
 (u'shipping-', 1),
 (u'marrying,', 1),
 (u"Show'd", 5),
 (u'protestation;', 2),
 (u'Publish', 1),
 (u'Stoop', 6),
 (u"exhal'd", 1),
 (u'commanded,', 2),
 (u"'Beware", 1),
 (u'pent-house', 1),
 (u"capdv'd", 1),
 (u'dexter', 1),
 (u'furniture,', 1),
 (u'Preys', 1),
 (u'furniture.', 1),
 (u'effect:', 1),
 (u'avails', 1),
 (u"affianc'd", 1),
 (u'naked)', 1),
 (u'satiety', 3),
 (u'enjoys', 3),
 (u'96,', 1),
 (u'impression,', 1),
 (u"admir'd.", 1),
 (u'braggarts', 1),
 (u'Sly.', 1),
 (u'awards', 3),
 (u'Jug,', 1),
 (u"join'd-stools,", 1),
 (u'circumference', 1),
 (u'avail?', 1),
 (u'moon,', 29),
 (u'moon.', 18),
 (u'west.', 4),
 (u'west,', 11),
 (u"fulfill'd!", 1),
 (u'enjoy?', 1),
 (u'Worthy.', 2),
 (u"confin'd-", 1),
 (u'ill-seeming,', 1),
 (u"sav'd", 15),
 (u'compels', 1),
 (u'want?', 2),
 (u'reading,', 2),
 (u'reading.', 2),
 (u'geese', 6),
 (u'allies;', 2),
 (u'want-', 2),
 (u'Montague', 11),
 (u"lock'd", 19),
 (u'Caius', 34),
 (u'zounds,', 1),
 (u'bequeath,', 1),
 (u'motives', 5),
 (u'prepare!', 1),
 (u'wants', 33),
 (u'compel;', 1),
 (u'relations', 1),
 (u'vomits', 1),
 (u'feud;', 1),
 (u"questioned'st", 1),
 (u'[Floulish]', 1),
 (u"like'st", 1),
 (u'extant', 2),
 (u'Gentlewoman', 1),
 (u'sufficed,', 1),
 (u'fin', 1),
 (u'pretence', 6),
 (u'provost', 2),
 (u'butchers', 2),
 (u"b'uy,", 1),
 (u'practise.', 1),
 (u'Alb.,', 1),
 (u'herrings-', 1),
 (u'SOLANIO', 6),
 (u'engaged', 4),
 (u'guiled', 1),
 (u'edge.', 3),
 (u'irrevocable.', 1),
 (u'deeply.', 1),
 (u'vlouting-stogs,', 1),
 (u'Frighted,', 1),
 (u'Iago?', 8),
 (u'highest-peering', 1),
 (u'muffled!', 1),
 (u'Iago!', 5),
 (u'deputed', 1),
 (u'Asia;', 1),
 (u'edged', 2),
 (u'OVERDONE]', 1),
 (u'defy', 23),
 (u'pah!', 1),
 (u'advertisement', 2),
 (u"Dauphin's", 10),
 (u'chiders,', 1),
 (u'[Handing', 1),
 (u'plurisy,', 1),
 (u'bends.', 1),
 (u'odorous!', 1),
 (u'masks', 2),
 (u'lullaby;', 1),
 (u'Antium?', 1),
 (u'sum?', 1),
 (u'sum;', 2),
 (u'Lodowick', 2),
 (u'being', 526),
 (u'officers,', 10),
 (u'gesture;', 1),
 (u'sum!', 1),
 (u'Divinest', 1),
 (u'grounded', 4),
 (u'camomile,', 1),
 (u'plumes', 1),
 (u'sorry;', 1),
 (u'bankrupt.', 1),
 (u'Consorted', 1),
 (u'sorry?', 1),
 (u'sums', 15),
 (u'gestures', 1),
 (u'commodity?', 1),
 (u'traffic', 9),
 (u'sorry-', 1),
 (u'giant-dwarf,', 1),
 (u'teach;', 2),
 (u'hunger,', 4),
 (u'plume;', 2),
 (u'Valiant', 4),
 (u'RUGBY]', 1),
 (u"Falstaff's.'", 1),
 (u'standing-bed', 1),
 (u'obstruct', 1),
 (u"'Is", 1),
 (u'grub', 1),
 (u'Obedient', 1),
 (u'Challenger,', 1),
 (u'saidst', 2),
 (u'capers;', 1),
 (u"Disguis'd", 1),
 (u'Gertrude?', 1),
 (u'pelican,', 2),
 (u'plantain.', 1),
 (u'lastly,', 3),
 (u'widower;', 1),
 (u'restoring', 1),
 (u'goose;', 1),
 (u'Chertsey,', 1),
 (u'When?', 4),
 (u"'I'", 1),
 (u"You'll", 45),
 (u'goose!', 2),
 (u"partner'd", 1),
 ...]