# An introduction to dictionaries (associative arrays) in MATLAB

Posted by **Mike Croucher**,

350 views (last 30 days) |
0 Likes |
38 comments

Dictionaries are one of the many new features of MATLAB R2022b which was released yesterday. Today I'll take a look at some of the details of this new datatype in MATLAB.

### A dictionary is a collection of key-value pairs.

A dictionary (also known as an associative array in some programming languages), is a collection of key-value pairs where each unique key maps onto a value. For example, imagine I am keeping track of the weight of three people called Mike, Dave and Bob and I want to use a dictionary called gym to do this. How would I create this in MATLAB?

names = ["Mike","Dave","Bob"];

weights = [89,75,68]; % weight in kilograms

gym = dictionary(names,weights) % Vectorised constructor. Performs elementwise mapping.

gym =

dictionary (

**string**⟼**double**) with 3 entries: "Mike" ⟼ 89 "Dave" ⟼ 75 "Bob" ⟼ 68Now I have this dictionary object, I can look up the weight of any entry by supplying the relevant key, which in this case is a person's name.

gym("Dave")

ans = 75

gym("Bob")

ans = 68

This look-up operation, which relies on unique keys rather than position, is the key (no pun intended!) to the usefulness of dictionaries. They are completely optimised for fast look-up and do so in constant time (or O(1) if you are familiar with big O notation) which essentially means that it's as fast to look up an item in a 10 element dictionary as it is in a 10 million element dictionary (in theory at least!).

It is vital to understand that keys in a dictionary are unique. If I make another assignment to "Bob" in this dictionary, it will overwrite the value that "Bob" used to map to rather than creating a second entry called "Bob".

There can be only one of each key!

gym("Bob")=110

gym =

dictionary (

**string**⟼**double**) with 3 entries: "Mike" ⟼ 89 "Dave" ⟼ 75 "Bob" ⟼ 110### What if a key does not exist in a dictionary?

We can check to see if a key exists in a dictionary using the isKey() function. For example, the key "Michelle" does not exist in the dictionary gym and this is confirmed by isKey()

isKey(gym,"Michelle")

ans = logical

0

Attempting to look up a key that does not exist results in an error.

gym("Michelle")

Error using ()

Key not found.

Key not found.

However, assigning to a key that does not exist will insert that key-value pair into the dictionary and return the result.

gym("Michelle") = 70

gym =

dictionary (

**string**⟼**double**) with 4 entries: "Mike" ⟼ 89 "Dave" ⟼ 75 "Bob" ⟼ 110 "Michelle" ⟼ 70### Returning all of the keys and values of a dictionary as arrays

We can get all of the keys out of a dictionary using the keys function. In this case, since our keys were strings, the result is an array of strings.

gymkeys = keys(gym)

gymkeys = 4×1 string

"Mike"

"Dave"

"Bob"

"Michelle"

"Dave"

"Bob"

"Michelle"

gymvalues = values(gym)

gymvalues = 4×1

89
75
110
70

Note that each element of the gymkeys array corresponds to each element of the gymvalues array. For example, "Bob" is the 3rd element of gymkeys and his weight is the 3rd element of gymvalues. Furthermore, keys and values are returned in the same order that they were inserted into the dictionary. In theory, a dictionary is an unordered object but in MATLAB's implementation, insertion order is maintained.

### 3 ways of creating dictionaries in MATLAB

There are currently three ways of creating a dictionary in MATLAB. We've already seen the first one, which is a very MATLAB-y, vectorised way of doing it. The idea is to create an array of keys then an array of values and pass them both to dictionary() which then forms a dictionary from the set of elementwise pairs.

Vectorised dictionary creation

fruits = ["Apple","Pear","Banana"];

colours = ["Red","Green","Yellow"];

d1 = dictionary(fruits,colours)

d1 =

dictionary (

**string**⟼**string**) with 3 entries: "Apple" ⟼ "Red" "Pear" ⟼ "Green" "Banana" ⟼ "Yellow"Dictionary creation using interleaved keys and values

An alternative method is to interleave keys and values like this

d2 = dictionary("Apple","Red", ...

"Pear","Green", ...

"Banana","Yellow")

d2 =

dictionary (

**string**⟼**string**) with 3 entries: "Apple" ⟼ "Red" "Pear" ⟼ "Green" "Banana" ⟼ "Yellow"The line breaks were just for readability, I could just have easily done this:

d2 = dictionary("Apple","Red","Pear","Green","Banana","Yellow")

d2 =

dictionary (

**string**⟼**string**) with 3 entries: "Apple" ⟼ "Red" "Pear" ⟼ "Green" "Banana" ⟼ "Yellow"Dictionary creation starting from an empty dictionary

The final method is to start with an empty dictionary

d3 = dictionary()

d3 =

dictionary with unset key and value types.

and then add key-value pairs, one at a time

d3("Apple") = "Red"

d3 =

dictionary (

**string**⟼**string**) with 1 entry: "Apple" ⟼ "Red"d3("Pear") = "Green"

d3 =

dictionary (

**string**⟼**string**) with 2 entries: "Apple" ⟼ "Red" "Pear" ⟼ "Green"d3("Banana") = "Yellow"

d3 =

dictionary (

**string**⟼**string**) with 3 entries: "Apple" ⟼ "Red" "Pear" ⟼ "Green" "Banana" ⟼ "Yellow"All of these methods give equivalent results although performance might vary.

### Counting the number of entries in a dictionary: (Hint - You don't use numel)

numEntries(d3)

ans = 3

When I first starting using dictionaries in MATLAB, I tried to use numel instead and was rather suprised by the result

numel(d3)

ans = 1

I actually reported this as a bug when I used early versions of dictionary but its all consistent. The thinking here is that you only have one dictionary, d3, which itself contains the entries.

To expand on this a little further, MathWorks think that the size, numel, isempty, indexing, and cat functions should be consistent and follow normal MATLAB array behavior. This isn't possible with dictionary since the set of entries doesn't have a shape and duplicate values overwrite.

### More about empty dictionaries: isConfigured()

Let's look closer at an empty dictionary.

newDict = dictionary()

newDict =

dictionary with unset key and value types.

Not only is newDict empty but the key and value types are both unset. We say that this dictionary is both empty and unconfigured. We can check configuration status using the isConfigured() function.

isConfigured(newDict)

ans = logical

0

You may ask "Why does this matter?". Well, there are certain things you can't do with unconfigured dictionaries. You can't ask if a key exists for example

isKey(newDict,"SomeKey")

Error using isKey

Unable to perform a lookup in a dictionary with unset key and value types. Add

entries to the dictionary.

Unable to perform a lookup in a dictionary with unset key and value types. Add

entries to the dictionary.

To configure an empty dictionary in R2022b, you simply add an entry.

newDict(datetime("06-Sep-2022")) = "today"

newDict =

dictionary (

**datetime**⟼**string**) with 1 entry: 06-Sep-2022 ⟼ "today"This has added a single entry and configured newDict dictionary so that its keys are of type datetime and values are of type string. isConfigured now returns true.

isConfigured(newDict)

ans = logical

1

The next question you might ask is, how can I have an empty but configured dictionary? In R2022b, the answer is to create the dictionary with empty arrays of the types you want

emptyAndConfigured = dictionary(string.empty,double.empty)

emptyAndConfigured =

dictionary (

**string**⟼**double**) with no entries.isConfigured(emptyAndConfigured)

ans = logical

1

### Dictionaries are vectorised

"Of course they are vectorised, this is MATLAB!" was the answer I got from development when I asked the question. Let's see what this means.

We've already seen vectorised construction of dictionaries

names = ["Mike","Dave","Bob"];

weights = [89,75,68]; % weight in kilograms

gym = dictionary(names,weights) % Vectorised constructor. Performs elementwise mapping.

gym =

dictionary (

**string**⟼**double**) with 3 entries: "Mike" ⟼ 89 "Dave" ⟼ 75 "Bob" ⟼ 68We can also perform vectorised assignment. Let's change Mike's and Bob's weights simultaneously

gym(["Mike","Bob"]) = [80,73]

gym =

dictionary (

**string**⟼**double**) with 3 entries: "Mike" ⟼ 80 "Dave" ⟼ 75 "Bob" ⟼ 73Scalar expansion also works. Two twins join the gym and since they have the same weight, I only need to supply the value once

gym(["Twin 1","Twin 2"]) = 100

gym =

dictionary (

**string**⟼**double**) with 5 entries: "Mike" ⟼ 80 "Dave" ⟼ 75 "Bob" ⟼ 73 "Twin 1" ⟼ 100 "Twin 2" ⟼ 100It's also possible to do vectorised look up. The shape of the returned values array will be the same as the same of the keys queries

gym(["Mike","Bob";"Twin 1","Dave"])

ans = 2×2

80 73
100 75

This naturally leads to the question: "What happens if any one of the input keys does not exist?".

gym(["Mike","Bob";"DoesNotExist","Dave"])

Element 2 of the key array not found.

We get an error and no results are returned.

### Exporting and converting dictionaries

Like many other MATLAB objects, dictionaries can be serialised in a .mat file. All you need to do is save it as you would a matrix or whatever

%Save the dictionary called gym to a file called mydictionary.mat

save("mydictionary",'gym')

If you wanted to export your dictionary to a .csv file, the workflow is to first convert it to a table and then export that.

The entries function provides conversion functionality from dictionaries to tables, structures or cells. Here, we use a table.

gymTable = entries(gym,"table")

gymTable = 3×2 table

Key | Value | |
---|---|---|

1 | "Mike" | 89 |

2 | "Dave" | 75 |

3 | "Bob" | 110 |

Note that the entries of the table are in the order they were inserted in the original dictionary. Let's now write this to a .csv file

writetable(gymTable,"gym.csv")

### An example application for dictionaries: counting word occurrences

One of the classical uses for dictionaries is to count occurrences of words in a file. Let's do this using the sonnets.txt file that ships with MATLAB that contains 'The Sonnets' by William Shakespeare.

First we load the text, get rid of unnecessary punctuation and convert everything to lowercase.

sonnets = string(fileread('sonnets.txt'));

punctuationCharacters = ["." "?" "!" "," ";" ":"];

sonnets = replace(sonnets,punctuationCharacters," ");

sonnets = lower(sonnets);

Split the string into an array of words

words = split(sonnets);

Let's see how many words we have and how many of them are unique

numberOfWords = numel(words)

numberOfWords = 17712

numberOfUniqueWords = numel(unique(words))

numberOfUniqueWords = 3436

To count the number of occurrences of each word, we first create a suitable empty dictionary where the keys are strings and the values are doubles

d = dictionary(string.empty,double.empty);

Now iterate over all of the words. For each word, we check to see if it already exists in our dictionary. If it does, increase the value by one. If it doesn't, create a new entry with the value of 1.

for word = words'

if isKey(d,word) % If this word exists in the dictionary

d(word) = d(word) +1; % Increment the value associated with that word by 1.

else

d(word) = 1; % Initialise a new word in the dictionary with the value set to 1.

end

end

d

d =

dictionary (

**string**⟼**double**) with 3436 entries: "the" ⟼ 436 "sonnets" ⟼ 1 "by" ⟼ 94 "william" ⟼ 1 "shakespeare" ⟼ 1 "i" ⟼ 341 "from" ⟼ 81 "fairest" ⟼ 5 "creatures" ⟼ 2 "we" ⟼ 15 "desire" ⟼ 11 "increase" ⟼ 4 "that" ⟼ 320 "thereby" ⟼ 2 "beauty's" ⟼ 18 "rose" ⟼ 6 "might" ⟼ 26 "never" ⟼ 15 "die" ⟼ 12 "but" ⟼ 163 "as" ⟼ 121 "riper" ⟼ 2 "should" ⟼ 44 "time" ⟼ 53 "decease" ⟼ 3 "his" ⟼ 107 "tender" ⟼ 7 "heir" ⟼ 3 "bear" ⟼ 12 "memory" ⟼ 8 "thou" ⟼ 233 "contracted" ⟼ 2 "to" ⟼ 409 "thine" ⟼ 44 "own" ⟼ 30 "bright" ⟼ 11 "eyes" ⟼ 51 "feed'st" ⟼ 1 "thy" ⟼ 280 "light's" ⟼ 1 "flame" ⟼ 3 "with" ⟼ 181 "self-substantial" ⟼ 1 "fuel" ⟼ 1 "making" ⟼ 12 "a" ⟼ 163 "famine" ⟼ 1 "where" ⟼ 41 "abundance" ⟼ 4 "lies" ⟼ 12 "self" ⟼ 36 "foe" ⟼ 1 "sweet" ⟼ 55 "too" ⟼ 18 "cruel" ⟼ 8 "art" ⟼ 51 "now" ⟼ 45 "world's" ⟼ 5 "fresh" ⟼ 7 "ornament" ⟼ 5 "and" ⟼ 490 "only" ⟼ 6 "herald" ⟼ 1 "gaudy" ⟼ 1 "spring" ⟼ 5 "within" ⟼ 11 "bud" ⟼ 2 "buriest" ⟼ 1 "content" ⟼ 2 "churl" ⟼ 2 "mak'st" ⟼ 2 "waste" ⟼ 7 "in" ⟼ 321 "niggarding" ⟼ 1 "pity" ⟼ 8 "world" ⟼ 26 "or" ⟼ 79 "else" ⟼ 5 "this" ⟼ 103 "glutton" ⟼ 1 "be" ⟼ 141 "eat" ⟼ 3 "due" ⟼ 6 "grave" ⟼ 3 "thee" ⟼ 162 "ii" ⟼ 1 "when" ⟼ 106 "forty" ⟼ 1 "winters" ⟼ 2 "shall" ⟼ 59 "besiege" ⟼ 2 "brow" ⟼ 8 "dig" ⟼ 1 "deep" ⟼ 8 "trenches" ⟼ 1 "field" ⟼ 1 "youth's" ⟼ 1 "proud" ⟼ 12 "livery" ⟼ 1 "so" ⟼ 145 "gazed" ⟼ 1 "on" ⟼ 80 "will" ⟼ 54 "tatter'd" ⟼ 2 "weed" ⟼ 3 "of" ⟼ 370 "small" ⟼ 2 "worth" ⟼ 18 "held" ⟼ 2 "then" ⟼ 73 "being" ⟼ 32 "asked" ⟼ 1 "all" ⟼ 116 "beauty" ⟼ 52 "treasure" ⟼ 9 "lusty" ⟼ 2 "days" ⟼ 17 "say" ⟼ 28 "sunken" ⟼ 1 "were" ⟼ 29 "an" ⟼ 17 "all-eating" ⟼ 1 "shame" ⟼ 10 "thriftless" ⟼ 1 "praise" ⟼ 28 "how" ⟼ 40 "much" ⟼ 17 "more" ⟼ 64 "deserv'd" ⟼ 1 "use" ⟼ 13 "if" ⟼ 68 "couldst" ⟼ 1 "answer" ⟼ 3 "'this" ⟼ 2 "fair" ⟼ 41 "child" ⟼ 8 "mine" ⟼ 63 "sum" ⟼ 4 "my" ⟼ 371 "count" ⟼ 4 "make" ⟼ 43 "old" ⟼ 22 "excuse" ⟼ 7 "'" ⟼ 16 "proving" ⟼ 1 "succession" ⟼ 1 "new" ⟼ 22 "made" ⟼ 19 "see" ⟼ 35 "blood" ⟼ 8 "warm" ⟼ 1 "feel'st" ⟼ 1 "it" ⟼ 104 "cold" ⟼ 7 "iii" ⟼ 1 "look" ⟼ 22 "glass" ⟼ 10 "tell" ⟼ 15 "face" ⟼ 19 "viewest" ⟼ 1 "is" ⟼ 168 "form" ⟼ 11 "another" ⟼ 9 "whose" ⟼ 19 "repair" ⟼ 3 "not" ⟼ 166 "renewest" ⟼ 1 "dost" ⟼ 29 "beguile" ⟼ 1 "unbless" ⟼ 1 "some" ⟼ 31 "mother" ⟼ 2 "for" ⟼ 171 "she" ⟼ 33 "unear'd" ⟼ 1 "womb" ⟼ 2 "disdains" ⟼ 1 "tillage" ⟼ 1 "husbandry" ⟼ 2 "who" ⟼ 29 "he" ⟼ 43 "fond" ⟼ 2 "tomb" ⟼ 5 "self-love" ⟼ 3 "stop" ⟼ 2 "posterity" ⟼ 3 "mother's" ⟼ 3 "calls" ⟼ 5 "back" ⟼ 9 "lovely" ⟼ 8 "april" ⟼ 3 "her" ⟼ 51 "prime" ⟼ 4 "through" ⟼ 6 "windows" ⟼ 3 "age" ⟼ 15 "shalt" ⟼ 11 "despite" ⟼ 6 "wrinkles" ⟼ 5 "golden" ⟼ 5 "live" ⟼ 29 "remember'd" ⟼ 3 "single" ⟼ 4 "image" ⟼ 4 "dies" ⟼ 1 "iv" ⟼ 1 "unthrifty" ⟼ 1 "loveliness" ⟼ 1 "why" ⟼ 25 "spend" ⟼ 5 "upon" ⟼ 29 "legacy" ⟼ 1 "nature's" ⟼ 6 "bequest" ⟼ 1 "gives" ⟼ 8 "nothing" ⟼ 19 "doth" ⟼ 88 "lend" ⟼ 5 "frank" ⟼ 1 "lends" ⟼ 4 "those" ⟼ 33 "are" ⟼ 69 "free" ⟼ 4 "beauteous" ⟼ 9 "niggard" ⟼ 2 "abuse" ⟼ 3 "bounteous" ⟼ 2 "largess" ⟼ 1 "given" ⟼ 4 "give" ⟼ 26 "profitless" ⟼ 1 "usurer" ⟼ 2 "great" ⟼ 10 "sums" ⟼ 1 "yet" ⟼ 51 "canst" ⟼ 7 "having" ⟼ 6 "traffic" ⟼ 1 "alone" ⟼ 19 "deceive" ⟼ 2 "nature" ⟼ 10 "gone" ⟼ 9 "what" ⟼ 70 "acceptable" ⟼ 1 "audit" ⟼ 3 "leave" ⟼ 10 "unused" ⟼ 4 "must" ⟼ 21 "tombed" ⟼ 1 "which" ⟼ 108 "used" ⟼ 1 "lives" ⟼ 9 "th'" ⟼ 2 "executor" ⟼ 1 "v" ⟼ 1 "hours" ⟼ 12 "gentle" ⟼ 14 "work" ⟼ 3 "did" ⟼ 26 "frame" ⟼ 4 "gaze" ⟼ 2 "every" ⟼ 30 "eye" ⟼ 37 "dwell" ⟼ 6 "play" ⟼ 5 "tyrants" ⟼ 1 "very" ⟼ 7 "same" ⟼ 6 "unfair" ⟼ 1 "fairly" ⟼ 1 "excel" ⟼ 1 "never-resting" ⟼ 1 "leads" ⟼ 2 "summer" ⟼ 8 "hideous" ⟼ 2 "winter" ⟼ 5 "confounds" ⟼ 3 "him" ⟼ 38 "there" ⟼ 18 "sap" ⟼ 2 "checked" ⟼ 2 "frost" ⟼ 1 "leaves" ⟼ 8 "quite" ⟼ 5 "o'er-snowed" ⟼ 1 "bareness" ⟼ 2 "summer's" ⟼ 11 "distillation" ⟼ 1 "left" ⟼ 5 "liquid" ⟼ 1 "prisoner" ⟼ 1 "pent" ⟼ 2 "walls" ⟼ 2 "effect" ⟼ 3 "bereft" ⟼ 1 "nor" ⟼ 52 "no" ⟼ 77 "remembrance" ⟼ 2 "was" ⟼ 29 "flowers" ⟼ 8 "distill'd" ⟼ 3 "though" ⟼ 32 "they" ⟼ 52 "meet" ⟼ 2 "leese" ⟼ 1 "their" ⟼ 62 "show" ⟼ 23 "substance" ⟼ 4 "still" ⟼ 41 "vi" ⟼ 1 "let" ⟼ 26 "winter's" ⟼ 3 "ragged" ⟼ 1 "hand" ⟼ 17 "deface" ⟼ 1 "ere" ⟼ 6 "vial" ⟼ 1 "place" ⟼ 10 "self-kill'd" ⟼ 1 "forbidden" ⟼ 1 "usury" ⟼ 1 "happies" ⟼ 1 "pay" ⟼ 3 "willing" ⟼ 2 "loan" ⟼ 1 "that's" ⟼ 1 "breed" ⟼ 2 "ten" ⟼ 7 "times" ⟼ 9 "happier" ⟼ 3 "one" ⟼ 43 "than" ⟼ 48 "refigur'd" ⟼ 1 "could" ⟼ 10 "death" ⟼ 15 "do" ⟼ 84 "shouldst" ⟼ 6 "depart" ⟼ 2 "leaving" ⟼ 1 "living" ⟼ 7 "self-will'd" ⟼ 1 "death's" ⟼ 4 "conquest" ⟼ 3 "worms" ⟼ 4 "vii" ⟼ 1 "lo" ⟼ 3 "orient" ⟼ 1 "gracious" ⟼ 5 "light" ⟼ 6 "lifts" ⟼ 1 "up" ⟼ 15 "burning" ⟼ 1 "head" ⟼ 6 "each" ⟼ 15 "under" ⟼ 6 "homage" ⟼ 1 "new-appearing" ⟼ 1 "sight" ⟼ 17 "serving" ⟼ 2 "looks" ⟼ 13 "sacred" ⟼ 2 "majesty" ⟼ 2 "climb'd" ⟼ 1 "steep-up" ⟼ 1 "heavenly" ⟼ 3 "hill" ⟼ 1 "resembling" ⟼ 2 "strong" ⟼ 9 "youth" ⟼ 15 "middle" ⟼ 1 "mortal" ⟼ 5 "adore" ⟼ 1 "attending" ⟼ 2 "pilgrimage" ⟼ 2 "highmost" ⟼ 1 "pitch" ⟼ 2 "weary" ⟼ 4 "car" ⟼ 1 "like" ⟼ 34 "feeble" ⟼ 1 "reeleth" ⟼ 1 "day" ⟼ 25 "'fore" ⟼ 1 "duteous" ⟼ 1 "converted" ⟼ 2 "low" ⟼ 1 "tract" ⟼ 1 "way" ⟼ 6 "thyself" ⟼ 7 "outgoing" ⟼ 1 "noon" ⟼ 1 "unlook'd" ⟼ 2 "diest" ⟼ 1 "unless" ⟼ 6 "get" ⟼ 1 "son" ⟼ 3 "viii" ⟼ 1 "music" ⟼ 6 "hear" ⟼ 6 "hear'st" ⟼ 1 "sadly" ⟼ 1 "sweets" ⟼ 6 "war" ⟼ 6 "joy" ⟼ 8 "delights" ⟼ 2 "lov'st" ⟼ 6 "receiv'st" ⟼ 2 "gladly" ⟼ 1 "pleasure" ⟼ 11 "annoy" ⟼ 1 "true" ⟼ 37 "concord" ⟼ 2 "well-tuned" ⟼ 1 "sounds" ⟼ 2 "unions" ⟼ 1 "married" ⟼ 2 "offend" ⟼ 1 "ear" ⟼ 3 "sweetly" ⟼ 2 "chide" ⟼ 5 "singleness" ⟼ 1 "parts" ⟼ 7 "mark" ⟼ 4 "string" ⟼ 1 "husband" ⟼ 3 "strikes" ⟼ 1 "mutual" ⟼ 2 "ordering" ⟼ 1 "sire" ⟼ 1 "happy" ⟼ 11 "pleasing" ⟼ 2 "note" ⟼ 2 "sing" ⟼ 7 "speechless" ⟼ 2 "song" ⟼ 4 "many" ⟼ 13 "seeming" ⟼ 4 "sings" ⟼ 2 "'thou" ⟼ 1 "wilt" ⟼ 14 "prove" ⟼ 12 "none" ⟼ 13 "ix" ⟼ 1 "fear" ⟼ 8 "wet" ⟼ 1 "widow's" ⟼ 1 "consum'st" ⟼ 1 "life" ⟼ 23 "ah" ⟼ 7 "issueless" ⟼ 1 "hap" ⟼ 1 "wail" ⟼ 2 "makeless" ⟼ 1 "wife" ⟼ 1 "widow" ⟼ 2 "weep" ⟼ 3 "hast" ⟼ 16 "behind" ⟼ 4 "private" ⟼ 1 "well" ⟼ 22 "may" ⟼ 29 "keep" ⟼ 9 "children's" ⟼ 1 "husband's" ⟼ 1 "shape" ⟼ 5 "mind" ⟼ 16 "unthrift" ⟼ 1 "shifts" ⟼ 1 "enjoys" ⟼ 1 "hath" ⟼ 43 "end" ⟼ 10 "kept" ⟼ 3 "user" ⟼ 1 "destroys" ⟼ 1 "love" ⟼ 160 "toward" ⟼ 1 "others" ⟼ 11 "bosom" ⟼ 2 "sits" ⟼ 1 "himself" ⟼ 2 "such" ⟼ 30 "murd'rous" ⟼ 1 "commits" ⟼ 2 "x" ⟼ 1 "deny" ⟼ 2 "bear'st" ⟼ 1 "any" ⟼ 10 "unprovident" ⟼ 1 "grant" ⟼ 4 "belov'd" ⟼ 3 "most" ⟼ 27 "evident" ⟼ 1 "possess'd" ⟼ 2 "murderous" ⟼ 2 "hate" ⟼ 13 "'gainst" ⟼ 6 "stick'st" ⟼ 1 "conspire" ⟼ 1 "seeking" ⟼ 1 "roof" ⟼ 1 "ruinate" ⟼ 1 "chief" ⟼ 2 "o" ⟼ 50 "change" ⟼ 12 "thought" ⟼ 18 "fairer" ⟼ 3 "lodg'd" ⟼ 1 "presence" ⟼ 2 "kind" ⟼ 11 "at" ⟼ 26 "least" ⟼ 5 "kind-hearted" ⟼ 1 "me" ⟼ 164 "xi" ⟼ 1 "fast" ⟼ 5 "wane" ⟼ 1 "grow'st" ⟼ 3 "departest" ⟼ 1 "youngly" ⟼ 1 "bestow'st" ⟼ 1 "mayst" ⟼ 12 "call" ⟼ 10 "convertest" ⟼ 1 "herein" ⟼ 1 "wisdom" ⟼ 1 "without" ⟼ 8 "folly" ⟼ 1 "decay" ⟼ 9 "minded" ⟼ 1 "cease" ⟼ 1 "threescore" ⟼ 1 "year" ⟼ 5 "would" ⟼ 21 "away" ⟼ 18 "whom" ⟼ 12 "store" ⟼ 9 "harsh" ⟼ 1 "featureless" ⟼ 1 "rude" ⟼ 4 "barrenly" ⟼ 1 "perish" ⟼ 1 "best" ⟼ 23 "endow'd" ⟼ 1 "gave" ⟼ 5 "gift" ⟼ 5 "bounty" ⟼ 2 "cherish" ⟼ 1 "carv'd" ⟼ 1 "seal" ⟼ 1 "meant" ⟼ 1 "print" ⟼ 1 "copy" ⟼ 2 "xii" ⟼ 1 "clock" ⟼ 2 "tells" ⟼ 2 "brave" ⟼ 3 "sunk" ⟼ 1 "night" ⟼ 22 "behold" ⟼ 7 "violet" ⟼ 2 "past" ⟼ 9 "sable" ⟼ 1 "curls" ⟼ 1 "silvered" ⟼ 1 "o'er" ⟼ 6 "white" ⟼ 7 "lofty" ⟼ 2 "trees" ⟼ 1 "barren" ⟼ 5 "erst" ⟼ 1 "heat" ⟼ 4 "canopy" ⟼ 2 "herd" ⟼ 1 "green" ⟼ 5 "girded" ⟼ 1 "sheaves" ⟼ 1 "borne" ⟼ 2 "bier" ⟼ 1 "bristly" ⟼ 1 "beard" ⟼ 1 "question" ⟼ 2 "among" ⟼ 3 "wastes" ⟼ 2 "go" ⟼ 6 "since" ⟼ 23 "beauties" ⟼ 4 "themselves" ⟼ 6 "forsake" ⟼ 2 "grow" ⟼ 8 "time's" ⟼ 16 "scythe" ⟼ 4 "can" ⟼ 44 "defence" ⟼ 3 "save" ⟼ 9 "takes" ⟼ 3 "hence" ⟼ 6 "xiii" ⟼ 1 "you" ⟼ 111 "your" ⟼ 92 "longer" ⟼ 6 "yours" ⟼ 5 "here" ⟼ 4 "against" ⟼ 18 "coming" ⟼ 2 "prepare" ⟼ 2 "semblance" ⟼ 1 "other" ⟼ 16 "hold" ⟼ 13 "lease" ⟼ 4 "find" ⟼ 16 "determination" ⟼ 1 "yourself" ⟼ 7 "again" ⟼ 10 "after" ⟼ 10 "yourself's" ⟼ 1 "issue" ⟼ 2 "lets" ⟼ 1 "house" ⟼ 1 "fall" ⟼ 3 "honour" ⟼ 7 "uphold" ⟼ 1 "stormy" ⟼ 1 "gusts" ⟼ 1 "rage" ⟼ 5 "eternal" ⟼ 6 "unthrifts" ⟼ 1 "dear" ⟼ 20 "know" ⟼ 17 "had" ⟼ 15 "father" ⟼ 2 "xiv" ⟼ 1 "stars" ⟼ 5 "judgement" ⟼ 2 "pluck" ⟼ 4 "methinks" ⟼ 4 "have" ⟼ 75 "astronomy" ⟼ 1 "good" ⟼ 15 "evil" ⟼ 4 "luck" ⟼ 1 "plagues" ⟼ 1 "dearths" ⟼ 1 "seasons'" ⟼ 1 "quality" ⟼ 1 "fortune" ⟼ 6 "brief" ⟼ 3 "minutes" ⟼ 4 "pointing" ⟼ 1 "thunder" ⟼ 1 "rain" ⟼ 3 "wind" ⟼ 2 "princes" ⟼ 2 "oft" ⟼ 5 "predict" ⟼ 1 "heaven" ⟼ 13 "knowledge" ⟼ 3 "derive" ⟼ 1 "constant" ⟼ 3 "them" ⟼ 17 "read" ⟼ 5 "'truth" ⟼ 2 "together" ⟼ 1 "thrive" ⟼ 2 "wouldst" ⟼ 3 "convert'" ⟼ 1 "prognosticate" ⟼ 1 "'thy" ⟼ 1 "truth's" ⟼ 1 "doom" ⟼ 5 "date" ⟼ 5 "xv" ⟼ 1 "consider" ⟼ 1 "thing" ⟼ 11 "grows" ⟼ 4 "holds" ⟼ 5 "perfection" ⟼ 2 "little" ⟼ 2 "moment" ⟼ 1 "huge" ⟼ 2 "stage" ⟼ 2 "presenteth" ⟼ 1 "nought" ⟼ 3 "shows" ⟼ 6 "whereon" ⟼ 3 "secret" ⟼ 1 "influence" ⟼ 2 "comment" ⟼ 2 "perceive" ⟼ 1 "men" ⟼ 15 "plants" ⟼ 1 "cheered" ⟼ 1 "even" ⟼ 24 "self-same" ⟼ 1 "sky" ⟼ 1 "vaunt" ⟼ 1 "youthful" ⟼ 2 "height" ⟼ 3 "decrease" ⟼ 1 "wear" ⟼ 3 "state" ⟼ 14 "out" ⟼ 16 "conceit" ⟼ 3 "inconstant" ⟼ 2 "stay" ⟼ 9 "sets" ⟼ 2 "rich" ⟼ 10 "before" ⟼ 15 "wasteful" ⟼ 2 "debateth" ⟼ 1 "sullied" ⟼ 1 "engraft" ⟼ 1 "xvi" ⟼ 1 "wherefore" ⟼ 4 "mightier" ⟼ 1 "bloody" ⟼ 3 "tyrant" ⟼ 3 "fortify" ⟼ 2 "means" ⟼ 3 "blessed" ⟼ 7 "rhyme" ⟼ 4 "stand" ⟼ 8 "top" ⟼ 1 "maiden" ⟼ 3 "gardens" ⟼ 1 "unset" ⟼ 1 "virtuous" ⟼ 3 "wish" ⟼ 5 "liker" ⟼ 1 "painted" ⟼ 5 "counterfeit" ⟼ 2 "lines" ⟼ 8 "pencil" ⟼ 2 "pupil" ⟼ 1 "pen" ⟼ 10 "neither" ⟼ 2 "inward" ⟼ 4 "outward" ⟼ 7 "keeps" ⟼ 5 "drawn" ⟼ 3 "skill" ⟼ 8 "xvii" ⟼ 1 "believe" ⟼ 4 "verse" ⟼ 15 "come" ⟼ 15 "fill'd" ⟼ 3 "high" ⟼ 4 "deserts" ⟼ 2 "knows" ⟼ 11 "hides" ⟼ 1 "half" ⟼ 3 "write" ⟼ 10 "numbers" ⟼ 4 "number" ⟼ 3 "graces" ⟼ 5 "poet" ⟼ 2 "touches" ⟼ 4 "ne'er" ⟼ 3 "touch'd" ⟼ 1 "earthly" ⟼ 1 "faces" ⟼ 2 "papers" ⟼ 1 "yellow'd" ⟼ 1 "scorn'd" ⟼ 1 "less" ⟼ 7 "truth" ⟼ 21 "tongue" ⟼ 11 "rights" ⟼ 1 "term'd" ⟼ 1 "poet's" ⟼ 2 "stretched" ⟼ 1 "metre" ⟼ 1 "antique" ⟼ 5 "alive" ⟼ 2 "twice" ⟼ 2 "--in" ⟼ 1 "xviii" ⟼ 1 "compare" ⟼ 5 "temperate" ⟼ 1 "rough" ⟼ 1 "winds" ⟼ 2 "shake" ⟼ 3 "darling" ⟼ 1 "buds" ⟼ 4 "short" ⟼ 4 "sometime" ⟼ 6 "hot" ⟼ 3 "shines" ⟼ 2 "often" ⟼ 2 "gold" ⟼ 2 "complexion" ⟼ 3 "dimm'd" ⟼ 1 "declines" ⟼ 1 "chance" ⟼ 1 "changing" ⟼ 2 "course" ⟼ 3 "untrimm'd" ⟼ 1 "fade" ⟼ 2 "lose" ⟼ 9 "possession" ⟼ 2 "ow'st" ⟼ 1 "brag" ⟼ 1 "wander'st" ⟼ 1 "shade" ⟼ 4 "long" ⟼ 11 "breathe" ⟼ 2 "xix" ⟼ 1 "devouring" ⟼ 1 "blunt" ⟼ 3 "lion's" ⟼ 1 "paws" ⟼ 1 "earth" ⟼ 12 "devour" ⟼ 1 "brood" ⟼ 1 "keen" ⟼ 2 "teeth" ⟼ 1 "fierce" ⟼ 2 "tiger's" ⟼ 1 "jaws" ⟼ 1 "burn" ⟼ 3 "long-liv'd" ⟼ 1 "phoenix" ⟼ 1 "glad" ⟼ 2 "sorry" ⟼ 1 "seasons" ⟼ 2 "fleets" ⟼ 1 "whate'er" ⟼ 2 "swift-footed" ⟼ 1 "wide" ⟼ 6 "fading" ⟼ 2 "forbid" ⟼ 3 "heinous" ⟼ 1 "crime" ⟼ 4 "carve" ⟼ 1 "love's" ⟼ 27 "draw" ⟼ 3 "untainted" ⟼ 1 "allow" ⟼ 2 "pattern" ⟼ 2 "succeeding" ⟼ 1 "worst" ⟼ 7 "wrong" ⟼ 6 "ever" ⟼ 11 "young" ⟼ 4 "xx" ⟼ 1 "woman's" ⟼ 3 "master" ⟼ 2 "mistress" ⟼ 4 "passion" ⟼ 1 "heart" ⟼ 50 "acquainted" ⟼ 2 "shifting" ⟼ 1 "false" ⟼ 18 "women's" ⟼ 3 "fashion" ⟼ 2 "theirs" ⟼ 2 "rolling" ⟼ 1 "gilding" ⟼ 2 "object" ⟼ 1 "whereupon" ⟼ 1 "gazeth" ⟼ 1 "man" ⟼ 5 "hue" ⟼ 5 "'hues'" ⟼ 1 "controlling" ⟼ 1 "steals" ⟼ 1 "men's" ⟼ 5 "souls" ⟼ 1 "amazeth" ⟼ 1 "woman" ⟼ 3 "wert" ⟼ 3 "first" ⟼ 12 "created" ⟼ 2 "till" ⟼ 14 "wrought" ⟼ 2 "fell" ⟼ 5 "a-doting" ⟼ 1 "addition" ⟼ 2 "defeated" ⟼ 1 "adding" ⟼ 1 "purpose" ⟼ 5 "prick'd" ⟼ 1 "xxi" ⟼ 1 "muse" ⟼ 16 "stirr'd" ⟼ 1 "itself" ⟼ 7 "rehearse" ⟼ 4 "couplement" ⟼ 1 "compare'" ⟼ 1 "sun" ⟼ 11 "moon" ⟼ 3 "sea's" ⟼ 1 "gems" ⟼ 1 "april's" ⟼ 1 "first-born" ⟼ 1 "things" ⟼ 14 "rare" ⟼ 4 "heaven's" ⟼ 6 "air" ⟼ 4 "rondure" ⟼ 1 "hems" ⟼ 1 "truly" ⟼ 5 "candles" ⟼ 1 "fix'd" ⟼ 2 "hearsay" ⟼ 1 "sell" ⟼ 1 "xxii" ⟼ 1 "persuade" ⟼ 1 "am" ⟼ 35 "furrows" ⟼ 1 "expiate" ⟼ 1 "cover" ⟼ 3 "seemly" ⟼ 1 "raiment" ⟼ 1 "breast" ⟼ 7 "elder" ⟼ 1 "therefore" ⟼ 17 "wary" ⟼ 1 "myself" ⟼ 20 "bearing" ⟼ 3 "chary" ⟼ 1 "nurse" ⟼ 1 "babe" ⟼ 4 "faring" ⟼ 1 "ill" ⟼ 18 "presume" ⟼ 1 "slain" ⟼ 2 "gav'st" ⟼ 3 "xxiii" ⟼ 1 "unperfect" ⟼ 1 "actor" ⟼ 1 "put" ⟼ 7 "beside" ⟼ 2 "part" ⟼ 20 "replete" ⟼ 2 "strength's" ⟼ 1 "weakens" ⟼ 1 "trust" ⟼ 5 "forget" ⟼ 2 "perfect" ⟼ 2 "ceremony" ⟼ 1 "rite" ⟼ 1 "strength" ⟼ 5 "seem" ⟼ 12 "o'ercharg'd" ⟼ 1 "burthen" ⟼ 2 "eloquence" ⟼ 1 "dumb" ⟼ 6 "presagers" ⟼ 1 "speaking" ⟼ 4 "plead" ⟼ 2 "recompense" ⟼ 1 "express'd" ⟼ 3 "learn" ⟼ 2 "silent" ⟼ 2 "writ" ⟼ 6 "belongs" ⟼ 2 "fine" ⟼ 2 "wit" ⟼ 6 "xxiv" ⟼ 1 "play'd" ⟼ 1 "painter" ⟼ 2 "stell'd" ⟼ 1 "table" ⟼ 1 "body" ⟼ 4 "wherein" ⟼ 5 "'tis" ⟼ 11 "perspective" ⟼ 1 "painter's" ⟼ 1 "pictur'd" ⟼ 1 "bosom's" ⟼ 2 "shop" ⟼ 1 "hanging" ⟼ 1 "glazed" ⟼ 1 "turns" ⟼ 4 "done" ⟼ 5 "where-through" ⟼ 1 "peep" ⟼ 1 "therein" ⟼ 3 "cunning" ⟼ 3 "want" ⟼ 4 "grace" ⟼ 11 "xxv" ⟼ 1 "favour" ⟼ 3 "public" ⟼ 4 "titles" ⟼ 1 "boast" ⟼ 5 "whilst" ⟼ 13 "triumph" ⟼ 3 "bars" ⟼ 2 "princes'" ⟼ 1 "favourites" ⟼ 1 "spread" ⟼ 1 "marigold" ⟼ 1 "sun's" ⟼ 1 "pride" ⟼ 11 "buried" ⟼ 5 "frown" ⟼ 3 "glory" ⟼ 8 "painful" ⟼ 1 "warrior" ⟼ 1 "famoused" ⟼ 1 "fight" ⟼ 3 "thousand" ⟼ 3 "victories" ⟼ 1 "once" ⟼ 10 "foil'd" ⟼ 1 "book" ⟼ 6 "razed" ⟼ 1 "rest" ⟼ 6 "forgot" ⟼ 4 "toil'd" ⟼ 1 "remove" ⟼ 2 "remov'd" ⟼ 3 "xxvi" ⟼ 1 "lord" ⟼ 1 "vassalage" ⟼ 1 "merit" ⟼ 5 "duty" ⟼ 3 "strongly" ⟼ 2 "knit" ⟼ 1 "send" ⟼ 2 "written" ⟼ 1 "embassage" ⟼ 1 "witness" ⟼ 3 "poor" ⟼ 15 "bare" ⟼ 4 "wanting" ⟼ 2 "words" ⟼ 10 "hope" ⟼ 6 "soul's" ⟼ 2 "naked" ⟼ 1 "bestow" ⟼ 1 "whatsoever" ⟼ 1 "star" ⟼ 3 "guides" ⟼ 1 "moving" ⟼ 2 "points" ⟼ 1 "graciously" ⟼ 1 "aspect" ⟼ 1 "puts" ⟼ 1 "apparel" ⟼ 1 "loving" ⟼ 9 "worthy" ⟼ 5 "respect" ⟼ 4 "dare" ⟼ 4 "xxvii" ⟼ 1 "toil" ⟼ 4 "haste" ⟼ 3 "bed" ⟼ 1 "respose" ⟼ 1 "limbs" ⟼ 2 "travel" ⟼ 2 "tir'd" ⟼ 2 "begins" ⟼ 1 "journey" ⟼ 2 "body's" ⟼ 4 "work's" ⟼ 1 "expired" ⟼ 1 "thoughts--from" ⟼ 1 "far" ⟼ 16 "abide--" ⟼ 1 "intend" ⟼ 1 "zealous" ⟼ 1 "drooping" ⟼ 1 "eyelids" ⟼ 2 "open" ⟼ 2 "looking" ⟼ 3 "darkness" ⟼ 1 "blind" ⟼ 6 "imaginary" ⟼ 1 "presents" ⟼ 1 "shadow" ⟼ 7 "sightless" ⟼ 2 "view" ⟼ 8 "jewel" ⟼ 4 "(hung" ⟼ 1 "ghastly" ⟼ 1 "makes" ⟼ 8 "black" ⟼ 13 "thus" ⟼ 21 "quiet" ⟼ 1 "xxviii" ⟼ 1 "return" ⟼ 6 "plight" ⟼ 1 "debarre'd" ⟼ 1 "benefit" ⟼ 2 "day's" ⟼ 1 "oppression" ⟼ 1 "eas'd" ⟼ 1 "oppress'd" ⟼ 2 "enemies" ⟼ 2 "either's" ⟼ 2 "reign" ⟼ 2 "consent" ⟼ 1 "hands" ⟼ 2 "torture" ⟼ 2 "complain" ⟼ 1 "farther" ⟼ 4 "off" ⟼ 2 "please" ⟼ 4 "clouds" ⟼ 4 "blot" ⟼ 3 "flatter" ⟼ 3 "swart-complexion'd" ⟼ 1 "sparkling" ⟼ 1 "twire" ⟼ 1 "gild'st" ⟼ 1 "daily" ⟼ 3 "sorrows" ⟼ 2 "nightly" ⟼ 2 "grief's" ⟼ 1 "length" ⟼ 1 "stronger" ⟼ 2 "xxix" ⟼ 1 "disgrace" ⟼ 8 "beweep" ⟼ 1 "outcast" ⟼ 1 "trouble" ⟼ 1 "deaf" ⟼ 1 "bootless" ⟼ 1 "cries" ⟼ 2 "curse" ⟼ 2 "fate" ⟼ 1 "wishing" ⟼ 1 "featur'd" ⟼ 1 "friends" ⟼ 3 "desiring" ⟼ 1 "man's" ⟼ 2 "scope" ⟼ 5 "enjoy" ⟼ 1 "contented" ⟼ 3 "these" ⟼ 22 "thoughts" ⟼ 17 "almost" ⟼ 3 "despising" ⟼ 1 "haply" ⟼ 3 "think" ⟼ 15 "--" ⟼ 12 "lark" ⟼ 1 "break" ⟼ 4 "arising" ⟼ 1 "sullen" ⟼ 2 "hymns" ⟼ 2 "gate" ⟼ 1 "wealth" ⟼ 6 "brings" ⟼ 2 "scorn" ⟼ 2 "kings" ⟼ 2 "xxx" ⟼ 1 "sessions" ⟼ 1 "summon" ⟼ 1 "sigh" ⟼ 1 "lack" ⟼ 4 "sought" ⟼ 1 "woes" ⟼ 1 "drown" ⟼ 1 "flow" ⟼ 1 "precious" ⟼ 6 "hid" ⟼ 2 "dateless" ⟼ 2 "afresh" ⟼ 1 "cancell'd" ⟼ 1 "woe" ⟼ 12 "moan" ⟼ 5 "expense" ⟼ 3 "vanish'd" ⟼ 1 "grieve" ⟼ 1 "grievances" ⟼ 1 "foregone" ⟼ 1 "heavily" ⟼ 2 "sad" ⟼ 7 "account" ⟼ 4 "fore-bemoaned" ⟼ 1 "paid" ⟼ 1 "while" ⟼ 6 "friend" ⟼ 14 "losses" ⟼ 1 "restor'd" ⟼ 1 "xxxi" ⟼ 1 "endeared" ⟼ 1 "hearts" ⟼ 4 "lacking" ⟼ 1 "supposed" ⟼ 2 "dead" ⟼ 16 "reigns" ⟼ 1 "holy" ⟼ 4 "obsequious" ⟼ 2 "tear" ⟼ 1 "religious" ⟼ 1 "stol'n" ⟼ 5 "interest" ⟼ 2 "appear" ⟼ 4 "hidden" ⟼ 1 "lie" ⟼ 13 "hung" ⟼ 1 "trophies" ⟼ 1 "lovers" ⟼ 2 "images" ⟼ 1 "lov'd" ⟼ 4 "thou--all" ⟼ 1 "they--hast" ⟼ 1 "xxxii" ⟼ 1 "survive" ⟼ 2 "well-contented" ⟼ 1 "bones" ⟼ 1 "dust" ⟼ 2 "re-survey" ⟼ 1 "deceased" ⟼ 2 "lover" ⟼ 1 "bett'ring" ⟼ 1 "outstripp'd" ⟼ 1 "reserve" ⟼ 2 "exceeded" ⟼ 1 "vouchsafe" ⟼ 2 "'had" ⟼ 1 "friend's" ⟼ 2 "grown" ⟼ 4 "growing" ⟼ 3 "dearer" ⟼ 2 "birth" ⟼ 5 "brought" ⟼ 3 "march" ⟼ 1 "ranks" ⟼ 1 "better" ⟼ 19 "equipage" ⟼ 1 "died" ⟼ 2 "poets" ⟼ 2 "style" ⟼ 3 "i'll" ⟼ 7 "love'" ⟼ 1 "xxxiii" ⟼ 1 "full" ⟼ 13 "glorious" ⟼ 1 "morning" ⟼ 2 "seen" ⟼ 11 "mountain" ⟼ 2 "tops" ⟼ 1 "sovereign" ⟼ 4 "kissing" ⟼ 1 "meadows" ⟼ 1 "pale" ⟼ 2 "streams" ⟼ 1 "alchemy" ⟼ 2 "anon" ⟼ 2 "permit" ⟼ 1 "basest" ⟼ 3 "ride" ⟼ 3 "ugly" ⟼ 1 "rack" ⟼ 1 "celestial" ⟼ 1 "forlorn" ⟼ 1 "visage" ⟼ 1 "hide" ⟼ 5 "stealing" ⟼ 2 "unseen" ⟼ 2 "west" ⟼ 3 "early" ⟼ 1 "morn" ⟼ 2 "shine" ⟼ 4 "triumphant" ⟼ 2 "splendour" ⟼ 1 "alack" ⟼ 3 "hour" ⟼ 4 "region" ⟼ 1 "cloud" ⟼ 2 "mask'd" ⟼ 2 "whit" ⟼ 1 "disdaineth" ⟼ 1 "suns" ⟼ 1 "stain" ⟼ 3 "staineth" ⟼ 1 "xxxiv" ⟼ 1 "didst" ⟼ 3 "promise" ⟼ 1 "forth" ⟼ 7 "cloak" ⟼ 1 "base" ⟼ 5 "o'ertake" ⟼ 1 "hiding" ⟼ 1 "bravery" ⟼ 1 "rotten" ⟼ 2 "smoke" ⟼ 1 "enough" ⟼ 6 "dry" ⟼ 1 "storm-beaten" ⟼ 1 "salve" ⟼ 2 "speak" ⟼ 8 "heals" ⟼ 1 "wound" ⟼ 4 "cures" ⟼ 1 "physic" ⟼ 2 "grief" ⟼ 5 "repent" ⟼ 1 "loss" ⟼ 8 "offender's" ⟼ 1 "sorrow" ⟼ 5 "weak" ⟼ 2 "relief" ⟼ 1 "bears" ⟼ 3 "offence's" ⟼ 1 "cross" ⟼ 3 "tears" ⟼ 5 "pearl" ⟼ 1 "sheds" ⟼ 1 "ransom" ⟼ 2 "deeds" ⟼ 10 "xxxv" ⟼ 1 "griev'd" ⟼ 1 "roses" ⟼ 7 "thorns" ⟼ 3 "silver" ⟼ 1 "fountains" ⟼ 1 "mud" ⟼ 1 "eclipses" ⟼ 2 "both" ⟼ 17 "loathsome" ⟼ 1 "canker" ⟼ 5 "sweetest" ⟼ 5 "faults" ⟼ 8 "authorizing" ⟼ 1 "trespass" ⟼ 2 "corrupting" ⟼ 1 "salving" ⟼ 1 "amiss" ⟼ 3 "excusing" ⟼ 1 "sins" ⟼ 3 "sensual" ⟼ 2 "fault" ⟼ 3 "bring" ⟼ 8 "sense" ⟼ 4 "adverse" ⟼ 1 "party" ⟼ 1 "advocate" ⟼ 1 "lawful" ⟼ 3 "plea" ⟼ 3 "commence" ⟼ 1 "civil" ⟼ 1 "accessary" ⟼ 1 "needs" ⟼ 5 "thief" ⟼ 4 "sourly" ⟼ 2 "robs" ⟼ 2 "xxxvi" ⟼ 1 "confess" ⟼ 1 "two" ⟼ 9 "twain" ⟼ 3 "although" ⟼ 9 "our" ⟼ 18 "undivided" ⟼ 1 "loves" ⟼ 8 "blots" ⟼ 1 "remain" ⟼ 3 "help" ⟼ 4 "separable" ⟼ 1 "spite" ⟼ 5 "alter" ⟼ 1 "sole" ⟼ 1 "steal" ⟼ 6 "delight" ⟼ 8 "evermore" ⟼ 3 "acknowledge" ⟼ 1 "lest" ⟼ 8 "bewailed" ⟼ 1 "guilt" ⟼ 1 "kindness" ⟼ 2 "take" ⟼ 13 "name" ⟼ 17 "sort" ⟼ 2 "report" ⟼ 4 "xxxvii" ⟼ 1 "decrepit" ⟼ 1 "active" ⟼ 1 "lame" ⟼ 2 "fortune's" ⟼ 3 "dearest" ⟼ 3 "comfort" ⟼ 4 "whether" ⟼ 5 "entitled" ⟼ 1 "crowned" ⟼ 1 "sit" ⟼ 2 "engrafted" ⟼ 1 "despis'd" ⟼ 1 "suffic'd" ⟼ 1 "xxxviii" ⟼ 1 "subject" ⟼ 5 "invent" ⟼ 2 "pour'st" ⟼ 1 "into" ⟼ 5 "argument" ⟼ 6 "excellent" ⟼ 1 "vulgar" ⟼ 3 "paper" ⟼ 1 "thanks" ⟼ 1 "aught" ⟼ 2 "perusal" ⟼ 1 "who's" ⟼ 1 "cannot" ⟼ 10 "invention" ⟼ 5 "tenth" ⟼ 1 "nine" ⟼ 1 "rhymers" ⟼ 1 "invocate" ⟼ 1 "outlive" ⟼ 3 "slight" ⟼ 2 "curious" ⟼ 1 "pain" ⟼ 5 "xxxix" ⟼ 1 "manners" ⟼ 3 "is't" ⟼ 2 "us" ⟼ 2 "divided" ⟼ 1 "separation" ⟼ 1 "deserv'st" ⟼ 1 "absence" ⟼ 5 "torment" ⟼ 3 "sour" ⟼ 2 "leisure" ⟼ 4 "entertain" ⟼ 1Our dictionary has 3436 entries which is equal to the number of unique words we found earlier. This gives us some confidence that we are heading in the right direction. As another check, we could sum all of the values and see that they equal the total number of words we found earlier

numberOfWords=sum(values(d))

numberOfWords = 17712

It turns out that Mr Shakespeare talked about love a lot more than hate!

d("love")

ans = 160

d("hate")

ans = 13

### Next time

That's it for our first look at this new datatype in MATLAB. This is the first of three posts on the subject of dictionaries. In the next two posts I'll take a deep dive into the different types you can use in dictionaries, including user-defined classes and will also compare the new functionality with the venerable containers.map. Let me know what you think and enjoy playing with the new version of MATLAB.

## Comments

To leave a comment, please click here to sign in to your MathWorks Account or create a new one.