ホームズ対ワトソン
シャーロック・ホームズ(Sherlock Holmes)が主人公のアーサー・コナン・ドイル(Arthur Conan Doyle)の小説をいくつか取り出す.
In[1]:=
![Click for copyable input](assets.ja/sherlock-vs-watson/In_69.png)
novels = {Entity["Book", "TheSignOfTheFour1890"],
Entity["Book", "TheAdventuresOfSherlockHolmes"],
Entity["Book", "TheHoundOfTheBaskervilles"],
Entity["Book", "TheReturnOfSherlockHolmes1904"]};
In[2]:=
![Click for copyable input](assets.ja/sherlock-vs-watson/In_70.png)
texts = EntityValue[novels, "Plaintext"];
2人の主人公が言及された回数を求める.
In[3]:=
![Click for copyable input](assets.ja/sherlock-vs-watson/In_71.png)
counts = WordCounts /@ texts;
In[4]:=
![Click for copyable input](assets.ja/sherlock-vs-watson/In_72.png)
watson = counts[[All, "Watson"]];
holmes = counts[[All, "Holmes"]];
新たな機能のCalloutを使って結果をプロットする.
In[5]:=
![Click for copyable input](assets.ja/sherlock-vs-watson/In_73.png)
callouts =
Callout @@@ Transpose[{Transpose[{holmes, watson}], novels}];
In[6]:=
![Click for copyable input](assets.ja/sherlock-vs-watson/In_74.png)
ListPlot[callouts, AxesLabel -> {"Holmes", "Watson"},
AspectRatio -> Automatic, AxesOrigin -> {0, 0}]
Out[6]=
![](assets.ja/sherlock-vs-watson/O_52.png)