Wolfram Language

Text & Language Processing

Sherlock vs. Watson

Retrieve some novels of Arthur Conan Doyle featuring Sherlock Holmes.

In[1]:=
Click for copyable input
novels = {Entity["Book", "TheSignOfTheFour1890"], Entity["Book", "TheAdventuresOfSherlockHolmes"], Entity["Book", "TheHoundOfTheBaskervilles"], Entity["Book", "TheReturnOfSherlockHolmes1904"]};
In[2]:=
Click for copyable input
texts = EntityValue[novels, "Plaintext"];

Find the number of times the two main characters are mentioned.

In[3]:=
Click for copyable input
counts = WordCounts /@ texts;
In[4]:=
Click for copyable input
watson = counts[[All, "Watson"]]; holmes = counts[[All, "Holmes"]];

Plot the results, using the new Callout functionality.

In[5]:=
Click for copyable input
callouts = Callout @@@ Transpose[{Transpose[{holmes, watson}], novels}];
In[6]:=
Click for copyable input
ListPlot[callouts, AxesLabel -> {"Holmes", "Watson"}, AspectRatio -> Automatic, AxesOrigin -> {0, 0}]
Out[6]=

Related Examples

de es fr ja ko pt-br ru zh