import marimo as mo
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import spacy
import textwrapTidyTuesday dataset of November 18, 2025
holmes = pd.read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2025/2025-11-18/holmes.csv')
holmes| book | text | line_num | |
|---|---|---|---|
| 0 | A Study In Scarlet | A STUDY IN SCARLET | 1 |
| 1 | A Study In Scarlet | NaN | 2 |
| 2 | A Study In Scarlet | Table of contents | 3 |
| 3 | A Study In Scarlet | NaN | 4 |
| 4 | A Study In Scarlet | Part I | 5 |
| ... | ... | ... | ... |
| 65953 | His Last Bow | See http://sherlock-holm.es for an electronic ... | 755 |
| 65954 | His Last Bow | additional information about it. | 756 |
| 65955 | His Last Bow | NaN | 757 |
| 65956 | His Last Bow | This text comes from the collection's version ... | 758 |
| 65957 | His Last Bow | NaN | 759 |
65958 rows × 3 columns
concatenated = holmes.groupby('book')['text'].apply(lambda x: ' '.join(x.dropna())).reset_index()
concatenated| book | text | |
|---|---|---|
| 0 | A Case of Identity | A CASE OF IDENTITY "My dear fellow," said Sher... |
| 1 | A Scandal in Bohemia | A SCANDAL IN BOHEMIA Table of contents Chapter... |
| 2 | A Study In Scarlet | A STUDY IN SCARLET Table of contents Part I Mr... |
| 3 | His Last Bow | HIS LAST BOW An Epilogue of Sherlock Holmes It... |
| 4 | Silver Blaze | SILVER BLAZE "I am afraid, Watson, that I shal... |
| 5 | The "Gloria Scott" | THE "GLORIA SCOTT" "I have some papers here," ... |
| 6 | The Adventure of Black Peter | THE ADVENTURE OF BLACK PETER I have never know... |
| 7 | The Adventure of Charles Augustus Milverton | THE ADVENTURE OF CHARLES AUGUSTUS MILVERTON It... |
| 8 | The Adventure of Wisteria Lodge | THE ADVENTURE OF WISTERIA LODGE Table of conte... |
| 9 | The Adventure of the Abbey Grange | THE ADVENTURE OF THE ABBEY GRANGE It was on a ... |
| 10 | The Adventure of the Beryl Coronet | THE ADVENTURE OF THE BERYL CORONET "Holmes," s... |
| 11 | The Adventure of the Blue Carbuncle | THE ADVENTURE OF THE BLUE CARBUNCLE I had call... |
| 12 | The Adventure of the Bruce-Partington Plans | THE ADVENTURE OF THE BRUCE-PARTINGTON PLANS In... |
| 13 | The Adventure of the Cardboard Box | THE ADVENTURE OF THE CARDBOARD BOX In choosing... |
| 14 | The Adventure of the Copper Beeches | THE ADVENTURE OF THE COPPER BEECHES "To the ma... |
| 15 | The Adventure of the Dancing Men | THE ADVENTURE OF THE DANCING MEN Holmes had be... |
| 16 | The Adventure of the Devil's Foot | THE ADVENTURE OF THE DEVIL'S FOOT In recording... |
| 17 | The Adventure of the Dying Detective | THE ADVENTURE OF THE DYING DETECTIVE Mrs. Huds... |
| 18 | The Adventure of the Empty House | THE ADVENTURE OF THE EMPTY HOUSE It was in the... |
| 19 | The Adventure of the Engineer's Thumb | THE ADVENTURE OF THE ENGINEER'S THUMB Of all t... |
| 20 | The Adventure of the Golden Pince-Nez | THE ADVENTURE OF THE GOLDEN PINCE-NEZ When I l... |
| 21 | The Adventure of the Missing Three-Quarter | THE ADVENTURE OF THE MISSING THREE-QUARTER We ... |
| 22 | The Adventure of the Noble Bachelor | THE ADVENTURE OF THE NOBLE BACHELOR The Lord S... |
| 23 | The Adventure of the Norwood Builder | THE ADVENTURE OF THE NORWOOD BUILDER "From the... |
| 24 | The Adventure of the Priory School | THE ADVENTURE OF THE PRIORY SCHOOL We have had... |
| 25 | The Adventure of the Red Circle | THE ADVENTURE OF THE RED CIRCLE Table of conte... |
| 26 | The Adventure of the Second Stain | THE ADVENTURE OF THE SECOND STAIN I had intend... |
| 27 | The Adventure of the Six Napoleons | THE ADVENTURE OF THE SIX NAPOLEONS It was no v... |
| 28 | The Adventure of the Solitary Cyclist | THE ADVENTURE OF THE SOLITARY CYCLIST From the... |
| 29 | The Adventure of the Speckled Band | THE ADVENTURE OF THE SPECKLED BAND On glancing... |
| 30 | The Adventure of the Three Students | THE ADVENTURE OF THE THREE STUDENTS It was in ... |
| 31 | The Boscombe Valley Mystery | THE BOSCOMBE VALLEY MYSTERY We were seated at ... |
| 32 | The Crooked Man | THE CROOKED MAN One summer night, a few months... |
| 33 | The Disappearance of Lady Frances Carfax | THE DISAPPEARANCE OF LADY FRANCES CARFAX "But ... |
| 34 | The Final Problem | THE FINAL PROBLEM It is with a heavy heart tha... |
| 35 | The Five Orange Pips | THE FIVE ORANGE PIPS When I glance over my not... |
| 36 | The Greek Interpreter | THE GREEK INTERPRETER During my long and intim... |
| 37 | The Hound of the Baskervilles | THE HOUND OF THE BASKERVILLES Table of content... |
| 38 | The Man with the Twisted Lip | THE MAN WITH THE TWISTED LIP Isa Whitney, brot... |
| 39 | The Musgrave Ritual | THE MUSGRAVE RITUAL An anomaly which often str... |
| 40 | The Naval Treaty | THE NAVAL TREATY The July which immediately su... |
| 41 | The Red-Headed League | THE RED-HEADED LEAGUE I had called upon my fri... |
| 42 | The Reigate Squires | THE REIGATE SQUIRES It was some time before th... |
| 43 | The Resident Patient | THE RESIDENT PATIENT Glancing over the somewha... |
| 44 | The Sign of the Four | THE SIGN OF THE FOUR Table of contents The Sci... |
| 45 | The Stock-Broker's Clerk | THE STOCK-BROKER'S CLERK Shortly after my marr... |
| 46 | The Valley Of Fear | THE VALLEY OF FEAR Table of contents Part I Th... |
| 47 | The Yellow Face | THE YELLOW FACE [In publishing these short ske... |
concatenated['text'].str.count('Holmes').sort_values(ascending=False)37 194
46 153
44 137
2 98
24 86
26 80
40 67
23 64
8 62
12 62
15 61
16 59
27 58
20 58
29 56
7 56
6 55
33 54
41 53
42 53
21 52
4 51
17 50
30 49
28 49
1 48
31 47
0 46
14 43
9 41
18 40
43 39
11 38
22 34
25 31
34 30
38 29
36 29
13 28
10 28
45 26
35 25
3 24
47 19
19 14
32 11
5 8
39 5
Name: text, dtype: int64
import re
def regex_sent_tokenize(text):
return re.split(r'(?<=[.!?])\s+', text)
concatenated['sentences'] = concatenated['text'].apply(regex_sent_tokenize)
sentences_df = concatenated['sentences'].apply(pd.Series)
result1 = pd.concat([concatenated[['book']], sentences_df], axis=1)from spacy.cli import download
download("en_core_web_sm") # installs the model
nlp1 = spacy.load("en_core_web_sm") # load it after install✔ Download and installation successful You can now load the package via spacy.load('en_core_web_sm') ⚠ Restart to reload dependencies If you are in a Jupyter or Colab notebook, you may need to restart Python in order to load all the package's dependencies. You can do this by selecting the 'Restart kernel' or 'Restart runtime' option.
nlp = spacy.load("en_core_web_sm")
def extract_entities(sentence):
doc = nlp(sentence)
return [(ent.text, ent.label_) for ent in doc.ents]
# Apply to your DataFrame
concatenated['entities'] = concatenated['text'].apply(extract_entities)
concatenated.head()| book | text | sentences | entities | |
|---|---|---|---|---|
| 0 | A Case of Identity | A CASE OF IDENTITY "My dear fellow," said Sher... | [A CASE OF IDENTITY "My dear fellow," said She... | [(IDENTITY, ORG), (Holmes, PERSON), (Baker Str... |
| 1 | A Scandal in Bohemia | A SCANDAL IN BOHEMIA Table of contents Chapter... | [A SCANDAL IN BOHEMIA Table of contents Chapte... | [(Chapter 1 Chapter 2 Chapter 3 CHAPTER, LAW),... |
| 2 | A Study In Scarlet | A STUDY IN SCARLET Table of contents Part I Mr... | [A STUDY IN SCARLET Table of contents Part I M... | [(Holmes The Science Of Deduction, PERSON), (J... |
| 3 | His Last Bow | HIS LAST BOW An Epilogue of Sherlock Holmes It... | [HIS LAST BOW An Epilogue of Sherlock Holmes I... | [(Holmes, PERSON), (nine o'clock, TIME), (seco... |
| 4 | Silver Blaze | SILVER BLAZE "I am afraid, Watson, that I shal... | [SILVER BLAZE "I am afraid, Watson, that I sha... | [(Watson, PERSON), (Holmes, PERSON), (one morn... |
# Keep only entities labeled as PERSON
concatenated['persons'] = concatenated['entities'].apply(
lambda ents: [text for text, label in ents if label == "PERSON"]
)concatenated.head()| book | text | sentences | entities | persons | |
|---|---|---|---|---|---|
| 0 | A Case of Identity | A CASE OF IDENTITY "My dear fellow," said Sher... | [A CASE OF IDENTITY "My dear fellow," said She... | [(IDENTITY, ORG), (Holmes, PERSON), (Baker Str... | [Holmes, Holmes, Holmes, Dundas, Irene Adler, ... |
| 1 | A Scandal in Bohemia | A SCANDAL IN BOHEMIA Table of contents Chapter... | [A SCANDAL IN BOHEMIA Table of contents Chapte... | [(Chapter 1 Chapter 2 Chapter 3 CHAPTER, LAW),... | [Holmes, Irene Adler, Irene Adler, Holmes, Hol... |
| 2 | A Study In Scarlet | A STUDY IN SCARLET Table of contents Part I Mr... | [A STUDY IN SCARLET Table of contents Part I M... | [(Holmes The Science Of Deduction, PERSON), (J... | [Holmes The Science Of Deduction, John Rance, ... |
| 3 | His Last Bow | HIS LAST BOW An Epilogue of Sherlock Holmes It... | [HIS LAST BOW An Epilogue of Sherlock Holmes I... | [(Holmes, PERSON), (nine o'clock, TIME), (seco... | [Holmes, Von Bork, Von Bork, Von Herling, Von ... |
| 4 | Silver Blaze | SILVER BLAZE "I am afraid, Watson, that I shal... | [SILVER BLAZE "I am afraid, Watson, that I sha... | [(Watson, PERSON), (Holmes, PERSON), (one morn... | [Watson, Holmes, Dartmoor, Watson, Exeter, Hol... |
len(set(concatenated['persons'][0]))21
from collections import Counter
concatenated['unique_persons'] = concatenated['persons'].apply(lambda x: Counter(x))concatenated| book | text | sentences | entities | persons | unique_persons | |
|---|---|---|---|---|---|---|
| 0 | A Case of Identity | A CASE OF IDENTITY "My dear fellow," said Sher... | [A CASE OF IDENTITY "My dear fellow," said She... | [(IDENTITY, ORG), (Holmes, PERSON), (Baker Str... | [Holmes, Holmes, Holmes, Dundas, Irene Adler, ... | {'Holmes': 45, 'Dundas': 1, 'Irene Adler': 2, ... |
| 1 | A Scandal in Bohemia | A SCANDAL IN BOHEMIA Table of contents Chapter... | [A SCANDAL IN BOHEMIA Table of contents Chapte... | [(Chapter 1 Chapter 2 Chapter 3 CHAPTER, LAW),... | [Holmes, Irene Adler, Irene Adler, Holmes, Hol... | {'Holmes': 43, 'Irene Adler': 11, 'Atkinson': ... |
| 2 | A Study In Scarlet | A STUDY IN SCARLET Table of contents Part I Mr... | [A STUDY IN SCARLET Table of contents Part I M... | [(Holmes The Science Of Deduction, PERSON), (J... | [Holmes The Science Of Deduction, John Rance, ... | {'Holmes The Science Of Deduction': 1, 'John R... |
| 3 | His Last Bow | HIS LAST BOW An Epilogue of Sherlock Holmes It... | [HIS LAST BOW An Epilogue of Sherlock Holmes I... | [(Holmes, PERSON), (nine o'clock, TIME), (seco... | [Holmes, Von Bork, Von Bork, Von Herling, Von ... | {'Holmes': 20, 'Von Bork': 31, 'Von Herling': ... |
| 4 | Silver Blaze | SILVER BLAZE "I am afraid, Watson, that I shal... | [SILVER BLAZE "I am afraid, Watson, that I sha... | [(Watson, PERSON), (Holmes, PERSON), (one morn... | [Watson, Holmes, Dartmoor, Watson, Exeter, Hol... | {'Watson': 13, 'Holmes': 50, 'Dartmoor': 2, 'E... |
| 5 | The "Gloria Scott" | THE "GLORIA SCOTT" "I have some papers here," ... | [THE "GLORIA SCOTT" "I have some papers here,"... | [(THE "GLORIA SCOTT, LAW), (Holmes, PERSON), (... | [Holmes, Watson, Hudson, Holmes, Victor Trevor... | {'Holmes': 8, 'Watson': 7, 'Hudson': 13, 'Vict... |
| 6 | The Adventure of Black Peter | THE ADVENTURE OF BLACK PETER I have never know... | [THE ADVENTURE OF BLACK PETER I have never kno... | [(the year '95, DATE), (Baker Street, FAC), (H... | [Holmes, Cardinal Tosca, His Holiness, Woodman... | {'Holmes': 51, 'Cardinal Tosca': 1, 'His Holin... |
| 7 | The Adventure of Charles Augustus Milverton | THE ADVENTURE OF CHARLES AUGUSTUS MILVERTON It... | [THE ADVENTURE OF CHARLES AUGUSTUS MILVERTON I... | [(CHARLES AUGUSTUS MILVERTON, PERSON), (years,... | [CHARLES AUGUSTUS MILVERTON, Sherlock Holmes, ... | {'CHARLES AUGUSTUS MILVERTON': 1, 'Sherlock Ho... |
| 8 | The Adventure of Wisteria Lodge | THE ADVENTURE OF WISTERIA LODGE Table of conte... | [THE ADVENTURE OF WISTERIA LODGE Table of cont... | [(The Singular Experience, ORG), (John Scott E... | [John Scott Eccles, John Scott Eccles, Holmes,... | {'John Scott Eccles': 3, 'Holmes': 59, 'Watson... |
| 9 | The Adventure of the Abbey Grange | THE ADVENTURE OF THE ABBEY GRANGE It was on a ... | [THE ADVENTURE OF THE ABBEY GRANGE It was on a... | [(morning, TIME), (the winter of '97, DATE), (... | [Holmes, Watson, Holmes, Holmes, Abbey Grange,... | {'Holmes': 40, 'Watson': 18, 'Abbey Grange': 1... |
| 10 | The Adventure of the Beryl Coronet | THE ADVENTURE OF THE BERYL CORONET "Holmes," s... | [THE ADVENTURE OF THE BERYL CORONET "Holmes," ... | [(one morning, TIME), (February morning, TIME)... | [Holmes, Holmes, Holmes, Holmes, Alexander Hol... | {'Holmes': 27, 'Alexander Holder': 1, 'Holder'... |
| 11 | The Adventure of the Blue Carbuncle | THE ADVENTURE OF THE BLUE CARBUNCLE I had call... | [THE ADVENTURE OF THE BLUE CARBUNCLE I had cal... | [(Holmes, PERSON), (the second morning, TIME),... | [Holmes, one"--he, Sherlock Holmes, Irene Adle... | {'Holmes': 37, 'one"--he': 1, 'Sherlock Holmes... |
| 12 | The Adventure of the Bruce-Partington Plans | THE ADVENTURE OF THE BRUCE-PARTINGTON PLANS In... | [THE ADVENTURE OF THE BRUCE-PARTINGTON PLANS I... | [(the third week of November, DATE), (the year... | [Holmes, Watson, Holmes, Holmes, Watson, Holme... | {'Holmes': 50, 'Watson': 22, 'Jove': 2, 'Mycro... |
| 13 | The Adventure of the Cardboard Box | THE ADVENTURE OF THE CARDBOARD BOX In choosing... | [THE ADVENTURE OF THE CARDBOARD BOX In choosin... | [(Holmes, PERSON), (August, DATE), (Baker Stre... | [Holmes, Holmes, Holmes, Watson, Holmes, Poe, ... | {'Holmes': 28, 'Watson': 9, 'Poe': 1, 'Gordon'... |
| 14 | The Adventure of the Copper Beeches | THE ADVENTURE OF THE COPPER BEECHES "To the ma... | [THE ADVENTURE OF THE COPPER BEECHES "To the m... | [(Sherlock Holmes, PERSON), (the Daily Telegra... | [Sherlock Holmes, Watson, Holmes, the King of ... | {'Sherlock Holmes': 1, 'Watson': 7, 'Holmes': ... |
| 15 | The Adventure of the Dancing Men | THE ADVENTURE OF THE DANCING MEN Holmes had be... | [THE ADVENTURE OF THE DANCING MEN Holmes had b... | [(Holmes, PERSON), (some hours, TIME), (Watson... | [Holmes, Watson, Holmes, Watson, Thurston, Wat... | {'Holmes': 60, 'Watson': 12, 'Thurston': 1, 'H... |
| 16 | The Adventure of the Devil's Foot | THE ADVENTURE OF THE DEVIL'S FOOT In recording... | [THE ADVENTURE OF THE DEVIL'S FOOT In recordin... | [(Sherlock Holmes, PERSON), (late years, DATE)... | [Sherlock Holmes, Holmes, Moore Agar, Holmes, ... | {'Sherlock Holmes': 1, 'Holmes': 58, 'Moore Ag... |
| 17 | The Adventure of the Dying Detective | THE ADVENTURE OF THE DYING DETECTIVE Mrs. Huds... | [THE ADVENTURE OF THE DYING DETECTIVE Mrs., Hu... | [(Hudson, PERSON), (Holmes, PERSON), (first, O... | [Hudson, Holmes, Holmes, Watson, Holmes, Watso... | {'Hudson': 4, 'Holmes': 49, 'Watson': 45, 'gau... |
| 18 | The Adventure of the Empty House | THE ADVENTURE OF THE EMPTY HOUSE It was in the... | [THE ADVENTURE OF THE EMPTY HOUSE It was in th... | [(the spring of the year 1894, DATE), (London,... | [Ronald Adair, Holmes, Ronald Adair, Holmes, R... | {'Ronald Adair': 6, 'Holmes': 37, 'the Earl of... |
| 19 | The Adventure of the Engineer's Thumb | THE ADVENTURE OF THE ENGINEER'S THUMB Of all t... | [THE ADVENTURE OF THE ENGINEER'S THUMB Of all ... | [(Sherlock Holmes, PERSON), (the years, DATE),... | [Sherlock Holmes, Hatherley, Warburton, Holmes... | {'Sherlock Holmes': 3, 'Hatherley': 7, 'Warbur... |
| 20 | The Adventure of the Golden Pince-Nez | THE ADVENTURE OF THE GOLDEN PINCE-NEZ When I l... | [THE ADVENTURE OF THE GOLDEN PINCE-NEZ When I ... | [(three, CARDINAL), (the year 1894, DATE), (Cr... | [Crosby, Holmes, Willoughby Smith, Holmes, Wat... | {'Crosby': 1, 'Holmes': 55, 'Willoughby Smith'... |
| 21 | The Adventure of the Missing Three-Quarter | THE ADVENTURE OF THE MISSING THREE-QUARTER We ... | [THE ADVENTURE OF THE MISSING THREE-QUARTER We... | [(Baker Street, FAC), (February morning, TIME)... | [Sherlock Holmes, Overton, Holmes, Overton, Ho... | {'Sherlock Holmes': 3, 'Overton': 8, 'Holmes':... |
| 22 | The Adventure of the Noble Bachelor | THE ADVENTURE OF THE NOBLE BACHELOR The Lord S... | [THE ADVENTURE OF THE NOBLE BACHELOR The Lord ... | [(Simon, PERSON), (four-year-old, DATE), (Holm... | [Simon, Holmes, Holmes, Watson, Sherlock Holme... | {'Simon': 8, 'Holmes': 32, 'Watson': 6, 'Sherl... |
| 23 | The Adventure of the Norwood Builder | THE ADVENTURE OF THE NORWOOD BUILDER "From the... | [THE ADVENTURE OF THE NORWOOD BUILDER "From th... | [(Sherlock Holmes, PERSON), (London, GPE), (Mo... | [Sherlock Holmes, Moriarty, Watson, Holmes, Ve... | {'Sherlock Holmes': 6, 'Moriarty': 1, 'Watson'... |
| 24 | The Adventure of the Priory School | THE ADVENTURE OF THE PRIORY SCHOOL We have had... | [THE ADVENTURE OF THE PRIORY SCHOOL We have ha... | [(Baker Street, FAC), (first, ORDINAL), (Thorn... | [Thorneycroft Huxtable, Holmes, Watson, Holmes... | {'Thorneycroft Huxtable': 2, 'Holmes': 82, 'Wa... |
| 25 | The Adventure of the Red Circle | THE ADVENTURE OF THE RED CIRCLE Table of conte... | [THE ADVENTURE OF THE RED CIRCLE Table of cont... | [(THE RED CIRCLE Table, ORG), (One, CARDINAL),... | [Warren, Holmes, Fairdale Hobbs, Holmes, Warre... | {'Warren': 22, 'Holmes': 30, 'Fairdale Hobbs':... |
| 26 | The Adventure of the Second Stain | THE ADVENTURE OF THE SECOND STAIN I had intend... | [THE ADVENTURE OF THE SECOND STAIN I had inten... | [(SECOND, ORDINAL), (The Adventure of the Abbe... | [Sherlock Holmes, Holmes, Holmes, Holmes, Trel... | {'Sherlock Holmes': 1, 'Holmes': 77, 'Trelawne... |
| 27 | The Adventure of the Six Napoleons | THE ADVENTURE OF THE SIX NAPOLEONS It was no v... | [THE ADVENTURE OF THE SIX NAPOLEONS It was no ... | [(SIX, CARDINAL), (Lestrade, PERSON), (Scotlan... | [Lestrade, Sherlock Holmes, Lestrade, Holmes, ... | {'Lestrade': 33, 'Sherlock Holmes': 7, 'Holmes... |
| 28 | The Adventure of the Solitary Cyclist | THE ADVENTURE OF THE SOLITARY CYCLIST From the... | [THE ADVENTURE OF THE SOLITARY CYCLIST From th... | [(the years 1894 to 1901, DATE), (Sherlock Hol... | [Sherlock Holmes, Holmes, John Vincent Harden,... | {'Sherlock Holmes': 2, 'Holmes': 46, 'John Vin... |
| 29 | The Adventure of the Speckled Band | THE ADVENTURE OF THE SPECKLED BAND On glancing... | [THE ADVENTURE OF THE SPECKLED BAND On glancin... | [(the last eight years, DATE), (Holmes, PERSON... | [Holmes, Surrey, Holmes, Grimesby Roylott, Hol... | {'Holmes': 54, 'Surrey': 3, 'Grimesby Roylott'... |
| 30 | The Adventure of the Three Students | THE ADVENTURE OF THE THREE STUDENTS It was in ... | [THE ADVENTURE OF THE THREE STUDENTS It was in... | [(THE THREE STUDENTS, ORG), (the year '95, DAT... | [Sherlock Holmes, Holmes, Hilton Soames, Soame... | {'Sherlock Holmes': 1, 'Holmes': 46, 'Hilton S... |
| 31 | The Boscombe Valley Mystery | THE BOSCOMBE VALLEY MYSTERY We were seated at ... | [THE BOSCOMBE VALLEY MYSTERY We were seated at... | [(one morning, TIME), (Holmes, PERSON), (a cou... | [Holmes, Sherlock Holmes, Holmes, gaunt, Watso... | {'Holmes': 44, 'Sherlock Holmes': 2, 'gaunt': ... |
| 32 | The Crooked Man | THE CROOKED MAN One summer night, a few months... | [THE CROOKED MAN One summer night, a few month... | [(summer night, TIME), (a few months, DATE), (... | [Holmes, Watson, Watson, Waterloo, Holmes, Wat... | {'Holmes': 11, 'Watson': 14, 'Waterloo': 2, 'E... |
| 33 | The Disappearance of Lady Frances Carfax | THE DISAPPEARANCE OF LADY FRANCES CARFAX "But ... | [THE DISAPPEARANCE OF LADY FRANCES CARFAX "But... | [(Turkish, NORP), (Sherlock Holmes, PERSON), (... | [Sherlock Holmes, Holmes, Holmes, Watson, Holm... | {'Sherlock Holmes': 2, 'Holmes': 50, 'Watson':... |
| 34 | The Final Problem | THE FINAL PROBLEM It is with a heavy heart tha... | [THE FINAL PROBLEM It is with a heavy heart th... | [(Sherlock Holmes, PERSON), (first, ORDINAL), ... | [Sherlock Holmes, James Moriarty, Moriarty, Sh... | {'Sherlock Holmes': 2, 'James Moriarty': 1, 'M... |
| 35 | The Five Orange Pips | THE FIVE ORANGE PIPS When I glance over my not... | [THE FIVE ORANGE PIPS When I glance over my no... | [(FIVE, CARDINAL), (Holmes, PERSON), (82, CARD... | [Holmes, Anderson, Holmes, Holmes, Clark Russe... | {'Holmes': 24, 'Anderson': 1, 'Clark Russell's... |
| 36 | The Greek Interpreter | THE GREEK INTERPRETER During my long and intim... | [THE GREEK INTERPRETER During my long and inti... | [(THE GREEK INTERPRETER During, ORG), (Sherloc... | [Sherlock Holmes, Art, Mycroft, Holmes, Watson... | {'Sherlock Holmes': 2, 'Art': 1, 'Mycroft': 12... |
| 37 | The Hound of the Baskervilles | THE HOUND OF THE BASKERVILLES Table of content... | [THE HOUND OF THE BASKERVILLES Table of conten... | [(Holmes The Curse, PERSON), (Henry Baskervill... | [Holmes The Curse, Henry Baskerville, Watson S... | {'Holmes The Curse': 1, 'Henry Baskerville': 2... |
| 38 | The Man with the Twisted Lip | THE MAN WITH THE TWISTED LIP Isa Whitney, brot... | [THE MAN WITH THE TWISTED LIP Isa Whitney, bro... | [(Elias Whitney, PERSON), (D.D., GPE), (Princi... | [Elias Whitney, Principal, De Quincey's, Kate ... | {'Elias Whitney': 1, 'Principal': 1, 'De Quinc... |
| 39 | The Musgrave Ritual | THE MUSGRAVE RITUAL An anomaly which often str... | [THE MUSGRAVE RITUAL An anomaly which often st... | [(Holmes, PERSON), (one, CARDINAL), (Afghanist... | [Holmes, Bohemianism, Holmes, V. R., Watson, W... | {'Holmes': 5, 'Bohemianism': 1, 'V. R.': 1, 'W... |
| 40 | The Naval Treaty | THE NAVAL TREATY The July which immediately su... | [THE NAVAL TREATY The July which immediately s... | [(THE NAVAL TREATY, ORG), (July, DATE), (three... | [Holmes, Holmes, Fritz von Waldbaum, Percy Phe... | {'Holmes': 64, 'Fritz von Waldbaum': 1, 'Percy... |
| 41 | The Red-Headed League | THE RED-HEADED LEAGUE I had called upon my fri... | [THE RED-HEADED LEAGUE I had called upon my fr... | [(THE RED-HEADED LEAGUE I, ORG), (Sherlock Hol... | [Sherlock Holmes, Holmes, Watson, Wilson, Holm... | {'Sherlock Holmes': 4, 'Holmes': 48, 'Watson':... |
| 42 | The Reigate Squires | THE REIGATE SQUIRES It was some time before th... | [THE REIGATE SQUIRES It was some time before t... | [(Sherlock Holmes, PERSON), (the spring of '87... | [Sherlock Holmes, Maupertuis, Holmes, Hayter, ... | {'Sherlock Holmes': 2, 'Maupertuis': 1, 'Holme... |
| 43 | The Resident Patient | THE RESIDENT PATIENT Glancing over the somewha... | [THE RESIDENT PATIENT Glancing over the somewh... | [(Memoirs, ORG), (Sherlock Holmes, PERSON), (H... | [Sherlock Holmes, Holmes, Charybdis, Holmes, H... | {'Sherlock Holmes': 2, 'Holmes': 37, 'Charybdi... |
| 44 | The Sign of the Four | THE SIGN OF THE FOUR Table of contents The Sci... | [THE SIGN OF THE FOUR Table of contents The Sc... | [(THE FOUR Table, ORG), (The Science of Deduct... | [Holmes Gives, Jonathan Small, Holmes, Watson,... | {'Holmes Gives': 2, 'Jonathan Small': 17, 'Hol... |
| 45 | The Stock-Broker's Clerk | THE STOCK-BROKER'S CLERK Shortly after my marr... | [THE STOCK-BROKER'S CLERK Shortly after my mar... | [(Paddington, ORG), (Farquhar, PERSON), (one, ... | [Farquhar, Holmes, Watson, Watson, Holmes, Hol... | {'Farquhar': 1, 'Holmes': 21, 'Watson': 12, 'H... |
| 46 | The Valley Of Fear | THE VALLEY OF FEAR Table of contents Part I Th... | [THE VALLEY OF FEAR Table of contents Part I T... | [(Holmes Discourses, PERSON), (The Tragedy, PE... | [Holmes Discourses, The Tragedy, Vermissa The ... | {'Holmes Discourses': 2, 'The Tragedy': 1, 'Ve... |
| 47 | The Yellow Face | THE YELLOW FACE [In publishing these short ske... | [THE YELLOW FACE [In publishing these short sk... | [(some half-dozen, CARDINAL), (The Adventure o... | [Holmes, Holmes, I., Holmes, Watson, Holmes, I... | {'Holmes': 19, 'I.': 2, 'Watson': 4, 'Grosveno... |
concatenated['places'] = concatenated['entities'].apply(
lambda ents: [text for text, label in ents if label == "GPE"]
)concatenated['persons_sorted'] = concatenated['unique_persons'].apply(
lambda d: dict(sorted(d.items(), key=lambda item: item[1], reverse=True))
)concatenated['unique_person_count'] = concatenated['persons'].apply(lambda x: len(set(x)))
concatenated['unique_places_count'] = concatenated['places'].apply(lambda x: len(set(x)))concatenated.sort_values(['unique_person_count', 'unique_places_count'], inplace=True, ascending=False)concatenated.reset_index(drop=True, inplace=True)
concatenated| book | text | sentences | entities | persons | unique_persons | places | persons_sorted | unique_person_count | unique_places_count | |
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | The Valley Of Fear | THE VALLEY OF FEAR Table of contents Part I Th... | [THE VALLEY OF FEAR Table of contents Part I T... | [(Holmes Discourses, PERSON), (The Tragedy, PE... | [Holmes Discourses, The Tragedy, Vermissa The ... | {'Holmes Discourses': 2, 'The Tragedy': 1, 'Ve... | [Porlock, Asteroid, Porlock, Porlock, Machiave... | {'McMurdo': 186, 'Holmes': 147, 'Douglas': 97,... | 188 | 51 |
| 1 | The Sign of the Four | THE SIGN OF THE FOUR Table of contents The Sci... | [THE SIGN OF THE FOUR Table of contents The Sc... | [(THE FOUR Table, ORG), (The Science of Deduct... | [Holmes Gives, Jonathan Small, Holmes, Watson,... | {'Holmes Gives': 2, 'Jonathan Small': 17, 'Hol... | [morocco, Jezail, St. Louis, Paris, England, E... | {'Holmes': 118, 'Sholto': 42, 'Jones': 29, 'Mo... | 124 | 45 |
| 2 | A Study In Scarlet | A STUDY IN SCARLET Table of contents Part I Mr... | [A STUDY IN SCARLET Table of contents Part I M... | [(Holmes The Science Of Deduction, PERSON), (J... | [Holmes The Science Of Deduction, John Rance, ... | {'Holmes The Science Of Deduction': 1, 'John R... | [M.D., M.D., Netley, India, Bombay, Maiwand, J... | {'Holmes': 79, 'Drebber': 51, 'Lestrade': 46, ... | 112 | 53 |
| 3 | The Hound of the Baskervilles | THE HOUND OF THE BASKERVILLES Table of content... | [THE HOUND OF THE BASKERVILLES Table of conten... | [(Holmes The Curse, PERSON), (Henry Baskervill... | [Holmes The Curse, Henry Baskerville, Watson S... | {'Holmes The Curse': 1, 'Henry Baskerville': 2... | [Penang, M.R.C.S., C.C., London, M.R.C.S., Lon... | {'Holmes': 176, 'Henry': 130, 'Watson': 110, '... | 101 | 51 |
| 4 | The Adventure of Wisteria Lodge | THE ADVENTURE OF WISTERIA LODGE Table of conte... | [THE ADVENTURE OF WISTERIA LODGE Table of cont... | [(The Singular Experience, ORG), (John Scott E... | [John Scott Eccles, John Scott Eccles, Holmes,... | {'John Scott Eccles': 3, 'Holmes': 59, 'Watson... | [Esher, Kensington, London, London, Spain, Oxs... | {'Holmes': 59, 'Garcia': 29, 'Watson': 19, 'Sc... | 49 | 14 |
| 5 | The Adventure of the Priory School | THE ADVENTURE OF THE PRIORY SCHOOL We have had... | [THE ADVENTURE OF THE PRIORY SCHOOL We have ha... | [(Baker Street, FAC), (first, ORDINAL), (Thorn... | [Thorneycroft Huxtable, Holmes, Watson, Holmes... | {'Thorneycroft Huxtable': 2, 'Holmes': 82, 'Wa... | [M.A., colour, Mackleton, Mackleton, London, K... | {'Holmes': 82, 'Watson': 25, 'Grace': 19, 'Hux... | 39 | 15 |
| 6 | The Adventure of the Empty House | THE ADVENTURE OF THE EMPTY HOUSE It was in the... | [THE ADVENTURE OF THE EMPTY HOUSE It was in th... | [(the spring of the year 1894, DATE), (London,... | [Ronald Adair, Holmes, Ronald Adair, Holmes, R... | {'Ronald Adair': 6, 'Holmes': 37, 'the Earl of... | [London, Australia, Carstairs, Bagatelle, Kens... | {'Holmes': 37, 'Watson': 21, 'Moran': 14, 'Les... | 36 | 21 |
| 7 | The Adventure of the Red Circle | THE ADVENTURE OF THE RED CIRCLE Table of conte... | [THE ADVENTURE OF THE RED CIRCLE Table of cont... | [(THE RED CIRCLE Table, ORG), (One, CARDINAL),... | [Warren, Holmes, Fairdale Hobbs, Holmes, Warre... | {'Warren': 22, 'Holmes': 30, 'Fairdale Hobbs':... | [London, groans, Brixton, London, London, Wats... | {'Holmes': 30, 'Watson': 26, 'Warren': 22, 'Ge... | 36 | 11 |
| 8 | The Adventure of the Blue Carbuncle | THE ADVENTURE OF THE BLUE CARBUNCLE I had call... | [THE ADVENTURE OF THE BLUE CARBUNCLE I had cal... | [(Holmes, PERSON), (the second morning, TIME),... | [Holmes, one"--he, Sherlock Holmes, Irene Adle... | {'Holmes': 37, 'one"--he': 1, 'Sherlock Holmes... | [morocco, St. James's, Echo, China, crisply, H... | {'Holmes': 37, 'Peterson': 11, 'Horner': 10, '... | 35 | 8 |
| 9 | The Five Orange Pips | THE FIVE ORANGE PIPS When I glance over my not... | [THE FIVE ORANGE PIPS When I glance over my no... | [(FIVE, CARDINAL), (Holmes, PERSON), (82, CARD... | [Holmes, Anderson, Holmes, Holmes, Clark Russe... | {'Holmes': 24, 'Anderson': 1, 'Clark Russell's... | [Uffa, London, America, Florida, Sussex, Horsh... | {'Holmes': 24, 'Horsham': 8, 'Openshaw': 5, 'J... | 34 | 21 |
| 10 | The Adventure of the Bruce-Partington Plans | THE ADVENTURE OF THE BRUCE-PARTINGTON PLANS In... | [THE ADVENTURE OF THE BRUCE-PARTINGTON PLANS I... | [(the third week of November, DATE), (the year... | [Holmes, Watson, Holmes, Holmes, Watson, Holme... | {'Holmes': 50, 'Watson': 22, 'Jove': 2, 'Mycro... | [London, London, London, India, Canada, London... | {'Holmes': 50, 'Watson': 22, 'Mycroft': 20, 'L... | 34 | 13 |
| 11 | The Disappearance of Lady Frances Carfax | THE DISAPPEARANCE OF LADY FRANCES CARFAX "But ... | [THE DISAPPEARANCE OF LADY FRANCES CARFAX "But... | [(Turkish, NORP), (Sherlock Holmes, PERSON), (... | [Sherlock Holmes, Holmes, Holmes, Watson, Holm... | {'Sherlock Holmes': 2, 'Holmes': 50, 'Watson':... | [Rufton, Lausanne, Lausanne, London, Lausanne,... | {'Holmes': 50, 'Watson': 23, 'Peters': 10, 'Sh... | 34 | 9 |
| 12 | The Boscombe Valley Mystery | THE BOSCOMBE VALLEY MYSTERY We were seated at ... | [THE BOSCOMBE VALLEY MYSTERY We were seated at... | [(one morning, TIME), (Holmes, PERSON), (a cou... | [Holmes, Sherlock Holmes, Holmes, gaunt, Watso... | {'Holmes': 44, 'Sherlock Holmes': 2, 'gaunt': ... | [England, Boscombe Valley, Afghanistan, Herefo... | {'Holmes': 44, 'McCarthy': 32, 'Lestrade': 24,... | 33 | 13 |
| 13 | Silver Blaze | SILVER BLAZE "I am afraid, Watson, that I shal... | [SILVER BLAZE "I am afraid, Watson, that I sha... | [(Watson, PERSON), (Holmes, PERSON), (one morn... | [Watson, Holmes, Dartmoor, Watson, Exeter, Hol... | {'Watson': 13, 'Holmes': 50, 'Dartmoor': 2, 'E... | [England, Paddington, England, Mapleton, Bayar... | {'Holmes': 50, 'Ross': 17, 'Watson': 13, 'John... | 33 | 12 |
| 14 | The Man with the Twisted Lip | THE MAN WITH THE TWISTED LIP Isa Whitney, brot... | [THE MAN WITH THE TWISTED LIP Isa Whitney, bro... | [(Elias Whitney, PERSON), (D.D., GPE), (Princi... | [Elias Whitney, Principal, De Quincey's, Kate ... | {'Elias Whitney': 1, 'Principal': 1, 'De Quinc... | [D.D., Capital, London, Middlesex, Neville, Ch... | {'Holmes': 28, 'Watson': 15, 'Neville St. Clai... | 32 | 6 |
| 15 | The Adventure of the Noble Bachelor | THE ADVENTURE OF THE NOBLE BACHELOR The Lord S... | [THE ADVENTURE OF THE NOBLE BACHELOR The Lord ... | [(Simon, PERSON), (four-year-old, DATE), (Holm... | [Simon, Holmes, Holmes, Watson, Sherlock Holme... | {'Simon': 8, 'Holmes': 32, 'Watson': 6, 'Sherl... | [Jezail, England, Tudor, Esq, San Francisco, C... | {'Holmes': 32, 'Frank': 19, 'Lestrade': 14, 'S... | 31 | 19 |
| 16 | The Adventure of the Solitary Cyclist | THE ADVENTURE OF THE SOLITARY CYCLIST From the... | [THE ADVENTURE OF THE SOLITARY CYCLIST From th... | [(the years 1894 to 1901, DATE), (Sherlock Hol... | [Sherlock Holmes, Holmes, John Vincent Harden,... | {'Sherlock Holmes': 2, 'Holmes': 46, 'John Vin... | [South Africa, Johannesburg, London, Tudor, Lo... | {'Holmes': 46, 'Woodley': 22, 'Carruthers': 16... | 31 | 7 |
| 17 | The Adventure of the Cardboard Box | THE ADVENTURE OF THE CARDBOARD BOX In choosing... | [THE ADVENTURE OF THE CARDBOARD BOX In choosin... | [(Holmes, PERSON), (August, DATE), (Baker Stre... | [Holmes, Holmes, Holmes, Watson, Holmes, Poe, ... | {'Holmes': 28, 'Watson': 9, 'Poe': 1, 'Gordon'... | [India, Croydon, Croydon, Belfast, Ireland, Be... | {'Holmes': 28, 'Sarah': 23, 'Lestrade': 22, 'C... | 30 | 10 |
| 18 | The Adventure of the Missing Three-Quarter | THE ADVENTURE OF THE MISSING THREE-QUARTER We ... | [THE ADVENTURE OF THE MISSING THREE-QUARTER We... | [(Baker Street, FAC), (February morning, TIME)... | [Sherlock Holmes, Overton, Holmes, Overton, Ho... | {'Sherlock Holmes': 3, 'Overton': 8, 'Holmes':... | [Cambridge, England, Wales, England, Cambridge... | {'Holmes': 46, 'Godfrey Staunton': 18, 'Godfre... | 29 | 12 |
| 19 | The Adventure of the Second Stain | THE ADVENTURE OF THE SECOND STAIN I had intend... | [THE ADVENTURE OF THE SECOND STAIN I had inten... | [(SECOND, ORDINAL), (The Adventure of the Abbe... | [Sherlock Holmes, Holmes, Holmes, Holmes, Trel... | {'Sherlock Holmes': 1, 'Holmes': 77, 'Trelawne... | [London, Britain, England, England, Great Brit... | {'Holmes': 77, 'Watson': 15, 'Lestrade': 10, '... | 29 | 12 |
| 20 | The "Gloria Scott" | THE "GLORIA SCOTT" "I have some papers here," ... | [THE "GLORIA SCOTT" "I have some papers here,"... | [(THE "GLORIA SCOTT, LAW), (Holmes, PERSON), (... | [Holmes, Watson, Hudson, Holmes, Victor Trevor... | {'Holmes': 8, 'Watson': 7, 'Hudson': 13, 'Vict... | [London, Norfolk, Birmingham, New Zealand, Jap... | {'Trevor': 16, 'Hudson': 13, 'Beddoes': 11, 'H... | 28 | 12 |
| 21 | The Adventure of the Six Napoleons | THE ADVENTURE OF THE SIX NAPOLEONS It was no v... | [THE ADVENTURE OF THE SIX NAPOLEONS It was no ... | [(SIX, CARDINAL), (Lestrade, PERSON), (Scotlan... | [Lestrade, Sherlock Holmes, Lestrade, Holmes, ... | {'Lestrade': 33, 'Sherlock Holmes': 7, 'Holmes... | [London, London, London, Pitt Street, Kensingt... | {'Holmes': 51, 'Lestrade': 33, 'Watson': 13, '... | 28 | 12 |
| 22 | The Crooked Man | THE CROOKED MAN One summer night, a few months... | [THE CROOKED MAN One summer night, a few month... | [(summer night, TIME), (a few months, DATE), (... | [Holmes, Watson, Watson, Waterloo, Holmes, Wat... | {'Holmes': 11, 'Watson': 14, 'Waterloo': 2, 'E... | [India, India, Bhurtee, Bhurtee, Darjeeling, P... | {'Barclay': 21, 'Watson': 14, 'Holmes': 11, 'M... | 28 | 6 |
| 23 | The Adventure of Black Peter | THE ADVENTURE OF BLACK PETER I have never know... | [THE ADVENTURE OF BLACK PETER I have never kno... | [(the year '95, DATE), (Baker Street, FAC), (H... | [Holmes, Cardinal Tosca, His Holiness, Woodman... | {'Holmes': 51, 'Cardinal Tosca': 1, 'His Holin... | [London, London, Dundee, Forest Row, Sussex, P... | {'Holmes': 51, 'Peter Carey': 21, 'Hopkins': 2... | 27 | 17 |
| 24 | A Scandal in Bohemia | A SCANDAL IN BOHEMIA Table of contents Chapter... | [A SCANDAL IN BOHEMIA Table of contents Chapte... | [(Chapter 1 Chapter 2 Chapter 3 CHAPTER, LAW),... | [Holmes, Irene Adler, Irene Adler, Holmes, Hol... | {'Holmes': 43, 'Irene Adler': 11, 'Atkinson': ... | [Holland, Scarlet, London, Egria, Bohemia, Boh... | {'Holmes': 43, 'Majesty': 17, 'Irene Adler': 1... | 27 | 13 |
| 25 | The Red-Headed League | THE RED-HEADED LEAGUE I had called upon my fri... | [THE RED-HEADED LEAGUE I had called upon my fr... | [(THE RED-HEADED LEAGUE I, ORG), (Sherlock Hol... | [Sherlock Holmes, Holmes, Watson, Wilson, Holm... | {'Sherlock Holmes': 4, 'Holmes': 48, 'Watson':... | [China, China, China, China, Lebanon, Pennsylv... | {'Holmes': 48, 'Wilson': 13, 'Merryweather': 1... | 27 | 11 |
| 26 | The Naval Treaty | THE NAVAL TREATY The July which immediately su... | [THE NAVAL TREATY The July which immediately s... | [(THE NAVAL TREATY, ORG), (July, DATE), (three... | [Holmes, Holmes, Fritz von Waldbaum, Percy Phe... | {'Holmes': 64, 'Fritz von Waldbaum': 1, 'Percy... | [Paris, Cambridge, Bunsen, England, Italy, Gre... | {'Holmes': 64, 'Phelps': 31, 'Watson': 18, 'Jo... | 26 | 18 |
| 27 | The Stock-Broker's Clerk | THE STOCK-BROKER'S CLERK Shortly after my marr... | [THE STOCK-BROKER'S CLERK Shortly after my mar... | [(Paddington, ORG), (Farquhar, PERSON), (one, ... | [Farquhar, Holmes, Watson, Watson, Holmes, Hol... | {'Farquhar': 1, 'Holmes': 21, 'Watson': 12, 'H... | [St. Vitus's, Birmingham, Birmingham, Birmingh... | {'Holmes': 21, 'Mawson': 15, 'Hall Pycroft': 1... | 26 | 11 |
| 28 | The Adventure of the Copper Beeches | THE ADVENTURE OF THE COPPER BEECHES "To the ma... | [THE ADVENTURE OF THE COPPER BEECHES "To the m... | [(Sherlock Holmes, PERSON), (the Daily Telegra... | [Sherlock Holmes, Watson, Holmes, the King of ... | {'Sherlock Holmes': 1, 'Watson': 7, 'Holmes': ... | [china, Nova Scotia, America, England, Philade... | {'Holmes': 41, 'Rucastle': 34, 'Hunter': 19, '... | 26 | 10 |
| 29 | His Last Bow | HIS LAST BOW An Epilogue of Sherlock Holmes It... | [HIS LAST BOW An Epilogue of Sherlock Holmes I... | [(Holmes, PERSON), (nine o'clock, TIME), (seco... | [Holmes, Von Bork, Von Bork, Von Herling, Von ... | {'Holmes': 20, 'Von Bork': 31, 'Von Herling': ... | [Kaiser, London, Berlin, Berlin, England, Engl... | {'Von Bork': 31, 'Holmes': 20, 'Watson': 16, '... | 25 | 19 |
| 30 | The Adventure of the Abbey Grange | THE ADVENTURE OF THE ABBEY GRANGE It was on a ... | [THE ADVENTURE OF THE ABBEY GRANGE It was on a... | [(morning, TIME), (the winter of '97, DATE), (... | [Holmes, Watson, Holmes, Holmes, Abbey Grange,... | {'Holmes': 40, 'Watson': 18, 'Abbey Grange': 1... | [London, Kentish, Marsham, E.B., Sydenham, Lon... | {'Holmes': 40, 'Watson': 18, 'Lady Brackenstal... | 24 | 13 |
| 31 | The Adventure of the Golden Pince-Nez | THE ADVENTURE OF THE GOLDEN PINCE-NEZ When I l... | [THE ADVENTURE OF THE GOLDEN PINCE-NEZ When I ... | [(three, CARDINAL), (the year 1894, DATE), (Cr... | [Crosby, Holmes, Willoughby Smith, Holmes, Wat... | {'Crosby': 1, 'Holmes': 55, 'Willoughby Smith'... | [Huret, London, Abbey, Chatham, Cambridge, Eng... | {'Holmes': 55, 'Coram': 9, 'Willoughby Smith':... | 24 | 10 |
| 32 | The Reigate Squires | THE REIGATE SQUIRES It was some time before th... | [THE REIGATE SQUIRES It was some time before t... | [(Sherlock Holmes, PERSON), (the spring of '87... | [Sherlock Holmes, Maupertuis, Holmes, Hayter, ... | {'Sherlock Holmes': 2, 'Maupertuis': 1, 'Holme... | [Afghanistan, shreds, England, Acton, London] | {'Holmes': 51, 'Cunningham': 19, 'William': 13... | 24 | 5 |
| 33 | The Musgrave Ritual | THE MUSGRAVE RITUAL An anomaly which often str... | [THE MUSGRAVE RITUAL An anomaly which often st... | [(Holmes, PERSON), (one, CARDINAL), (Afghanist... | [Holmes, Bohemianism, Holmes, V. R., Watson, W... | {'Holmes': 5, 'Bohemianism': 1, 'V. R.': 1, 'W... | [Afghanistan, London, Musgraves, Sussex, Brunt... | {'Musgrave': 15, 'Watson': 13, 'Brunton': 8, '... | 23 | 6 |
| 34 | The Adventure of the Dancing Men | THE ADVENTURE OF THE DANCING MEN Holmes had be... | [THE ADVENTURE OF THE DANCING MEN Holmes had b... | [(Holmes, PERSON), (some hours, TIME), (Watson... | [Holmes, Watson, Holmes, Watson, Thurston, Wat... | {'Holmes': 60, 'Watson': 12, 'Thurston': 1, 'H... | [Thurston, Norfolk, the County of Norfolk, Lon... | {'Holmes': 60, 'Hilton Cubitt': 21, 'Watson': ... | 22 | 14 |
| 35 | The Adventure of the Speckled Band | THE ADVENTURE OF THE SPECKLED BAND On glancing... | [THE ADVENTURE OF THE SPECKLED BAND On glancin... | [(the last eight years, DATE), (Holmes, PERSON... | [Holmes, Surrey, Holmes, Grimesby Roylott, Hol... | {'Holmes': 54, 'Surrey': 3, 'Grimesby Roylott'... | [England, England, England, India, England, Cr... | {'Holmes': 54, 'Roylott': 13, 'Watson': 12, 'M... | 22 | 5 |
| 36 | The Final Problem | THE FINAL PROBLEM It is with a heavy heart tha... | [THE FINAL PROBLEM It is with a heavy heart th... | [(Sherlock Holmes, PERSON), (first, ORDINAL), ... | [Sherlock Holmes, James Moriarty, Moriarty, Sh... | {'Sherlock Holmes': 2, 'James Moriarty': 1, 'M... | [Nimes, France, London, London, London, London... | {'Holmes': 28, 'Watson': 22, 'Moriarty': 11, '... | 21 | 16 |
| 37 | A Case of Identity | A CASE OF IDENTITY "My dear fellow," said Sher... | [A CASE OF IDENTITY "My dear fellow," said She... | [(IDENTITY, ORG), (Holmes, PERSON), (Baker Str... | [Holmes, Holmes, Holmes, Dundas, Irene Adler, ... | {'Holmes': 45, 'Dundas': 1, 'Irene Adler': 2, ... | [Holland, Marseilles, London, Auckland, New Ze... | {'Holmes': 45, 'Hosmer Angel': 15, 'Windibank'... | 21 | 11 |
| 38 | The Adventure of the Devil's Foot | THE ADVENTURE OF THE DEVIL'S FOOT In recording... | [THE ADVENTURE OF THE DEVIL'S FOOT In recordin... | [(Sherlock Holmes, PERSON), (late years, DATE)... | [Sherlock Holmes, Holmes, Moore Agar, Holmes, ... | {'Sherlock Holmes': 1, 'Holmes': 58, 'Moore Ag... | [London, Cornwall, England, London, Cornwall, ... | {'Holmes': 58, 'Watson': 26, 'Mortimer Tregenn... | 21 | 7 |
| 39 | The Adventure of the Norwood Builder | THE ADVENTURE OF THE NORWOOD BUILDER "From the... | [THE ADVENTURE OF THE NORWOOD BUILDER "From th... | [(Sherlock Holmes, PERSON), (London, GPE), (Mo... | [Sherlock Holmes, Moriarty, Watson, Holmes, Ve... | {'Sherlock Holmes': 6, 'Moriarty': 1, 'Watson'... | [London, London, Kensington, Friesland, London... | {'Holmes': 57, 'Lestrade': 51, 'Watson': 23, '... | 20 | 5 |
| 40 | The Adventure of Charles Augustus Milverton | THE ADVENTURE OF CHARLES AUGUSTUS MILVERTON It... | [THE ADVENTURE OF CHARLES AUGUSTUS MILVERTON I... | [(CHARLES AUGUSTUS MILVERTON, PERSON), (years,... | [CHARLES AUGUSTUS MILVERTON, Sherlock Holmes, ... | {'CHARLES AUGUSTUS MILVERTON': 1, 'Sherlock Ho... | [London, Milverton, Milverton, Milverton, Lond... | {'Holmes': 53, 'Milverton': 26, 'Watson': 16, ... | 19 | 6 |
| 41 | The Greek Interpreter | THE GREEK INTERPRETER During my long and intim... | [THE GREEK INTERPRETER During my long and inti... | [(THE GREEK INTERPRETER During, ORG), (Sherloc... | [Sherlock Holmes, Art, Mycroft, Holmes, Watson... | {'Sherlock Holmes': 2, 'Art': 1, 'Mycroft': 12... | [England, London, London, India, India, London... | {'Holmes': 22, 'Melas': 19, 'Mycroft': 12, 'My... | 18 | 11 |
| 42 | The Adventure of the Dying Detective | THE ADVENTURE OF THE DYING DETECTIVE Mrs. Huds... | [THE ADVENTURE OF THE DYING DETECTIVE Mrs., Hu... | [(Hudson, PERSON), (Holmes, PERSON), (first, O... | [Hudson, Holmes, Holmes, Watson, Holmes, Watso... | {'Hudson': 4, 'Holmes': 49, 'Watson': 45, 'gau... | [London, Sumatra, London, Formosa, London, whi... | {'Holmes': 49, 'Watson': 45, 'Culverton Smith'... | 18 | 5 |
| 43 | The Adventure of the Three Students | THE ADVENTURE OF THE THREE STUDENTS It was in ... | [THE ADVENTURE OF THE THREE STUDENTS It was in... | [(THE THREE STUDENTS, ORG), (the year '95, DAT... | [Sherlock Holmes, Holmes, Hilton Soames, Soame... | {'Sherlock Holmes': 1, 'Holmes': 46, 'Hilton S... | [St. Luke's, South Africa, Rhodesia] | {'Holmes': 46, 'Soames': 23, 'Watson': 11, 'Gi... | 15 | 3 |
| 44 | The Adventure of the Beryl Coronet | THE ADVENTURE OF THE BERYL CORONET "Holmes," s... | [THE ADVENTURE OF THE BERYL CORONET "Holmes," ... | [(one morning, TIME), (February morning, TIME)... | [Holmes, Holmes, Holmes, Holmes, Alexander Hol... | {'Holmes': 27, 'Alexander Holder': 1, 'Holder'... | [the City of London, London, England, morocco,... | {'Holmes': 27, 'Arthur': 20, 'Holder': 13, 'Ma... | 14 | 6 |
| 45 | The Resident Patient | THE RESIDENT PATIENT Glancing over the somewha... | [THE RESIDENT PATIENT Glancing over the somewh... | [(Memoirs, ORG), (Sherlock Holmes, PERSON), (H... | [Sherlock Holmes, Holmes, Charybdis, Holmes, H... | {'Sherlock Holmes': 2, 'Holmes': 37, 'Charybdi... | [India, London, Strand, Blessington, England, ... | {'Holmes': 37, 'Trevelyan': 13, 'Blessington':... | 13 | 14 |
| 46 | The Adventure of the Engineer's Thumb | THE ADVENTURE OF THE ENGINEER'S THUMB Of all t... | [THE ADVENTURE OF THE ENGINEER'S THUMB Of all ... | [(Sherlock Holmes, PERSON), (the years, DATE),... | [Sherlock Holmes, Hatherley, Warburton, Holmes... | {'Sherlock Holmes': 3, 'Hatherley': 7, 'Warbur... | [Paddington, lodgings, London, Greenwich, Lond... | {'Holmes': 11, 'Hatherley': 7, 'Lysander Stark... | 13 | 8 |
| 47 | The Yellow Face | THE YELLOW FACE [In publishing these short ske... | [THE YELLOW FACE [In publishing these short sk... | [(some half-dozen, CARDINAL), (The Adventure o... | [Holmes, Holmes, I., Holmes, Watson, Holmes, I... | {'Holmes': 19, 'I.': 2, 'Watson': 4, 'Grosveno... | [London, America, Atlanta, Hebron, America, Mi... | {'Holmes': 19, 'Jack': 12, 'Grant Munro': 6, '... | 12 | 7 |
concatenated["word_count"] = concatenated["text"].apply(
lambda x: f"{len(x.split())/1000:.1f}k" if len(x.split()) >= 1000 else str(len(x.split()))
)
concatenated["book_with_count"] = concatenated.apply(
lambda row: f"{row['book']} ({row['word_count']})", axis=1
)concatenated['unique_places'] = concatenated['places'].apply(lambda x: Counter(x))
concatenated['places_sorted'] = concatenated['unique_places'].apply(
lambda d: dict(sorted(d.items(), key=lambda item: item[1], reverse=True))
)bg_color = '#E8F4EC'
people_color = '#248C54'
places_color = '#89618E'
text_color = '#444444'
sns.set_theme(style="white", rc={
"font.family": "monospace",
"text.color": text_color,
"axes.labelcolor": text_color,
"xtick.color": text_color,
"ytick.color": text_color
})
items = [f"{k} ({v})" for k, v in concatenated.iloc[0]['persons_sorted'].items()][:20]
max_persons = "".join(item + (", " if i % 2 == 0 and i < len(items)-1 else "\n" if i < len(items)-1 else "")
for i, item in enumerate(items))
items2 = [f"{k} ({v})" for k, v in concatenated.iloc[-1]['persons_sorted'].items()]
min_persons = "".join(item + (", " if i % 2 == 0 and i < len(items2)-1 else "\n" if i < len(items2)-1 else "")
for i, item in enumerate(items2))
places_items = [f"{k} ({v})" for k, v in concatenated.iloc[0]['places_sorted'].items()][:20]
max_places = "".join(item + (", " if i % 2 == 0 and i < len(places_items)-1 else "\n" if i < len(places_items)-1 else "") for i, item in enumerate(places_items))
places_items2 = [f"{k} ({v})" for k, v in concatenated.iloc[-1]['places_sorted'].items()]
min_places = "".join(item + (", " if i % 2 == 0 and i < len(places_items2)-1 else "\n" if i < len(places_items2)-1 else "") for i, item in enumerate(places_items2))
fig1, ax1 = plt.subplots(figsize=(8,10))
sns.scatterplot(data=concatenated, x='unique_person_count', y='book_with_count', ax=ax1, color=people_color, edgecolor=None)
sns.scatterplot(data=concatenated, x='unique_places_count', y='book_with_count', marker='s', ax=ax1, color=places_color,edgecolor=None)
ax1.annotate(max_persons, xy=(concatenated.iloc[0]['unique_person_count'], concatenated.iloc[0]['book_with_count']), xytext=(concatenated.iloc[0]['unique_person_count']-43, 0 + 17), arrowprops=dict(arrowstyle="->", color=people_color), fontsize=10, color=people_color)
ax1.annotate(min_persons, xy=(concatenated.iloc[-1]['unique_person_count'], concatenated.iloc[-1]['book_with_count']), xytext=(concatenated.iloc[-1]['unique_person_count']+20, 48), arrowprops=dict(arrowstyle="->", color=people_color), fontsize=10, color=people_color)
ax1.annotate(max_places, xy=(concatenated.iloc[0]['unique_places_count'], concatenated.iloc[0]['book_with_count']), xytext=(concatenated.iloc[0]['unique_places_count']-15, 0 + 17), arrowprops=dict(arrowstyle="->", color=places_color), fontsize=10, color=places_color)
ax1.annotate(min_places, xy=(concatenated.iloc[-1]['unique_places_count'], concatenated.iloc[-1]['book_with_count']), xytext=(concatenated.iloc[-1]['unique_person_count']+20, 40), arrowprops=dict(arrowstyle="->", color=places_color), fontsize=10, color=places_color)
sns.despine(left=True)
ax1.tick_params(axis="y", length=0, pad=-10)
plt.xlabel("Unique counts")
plt.ylabel("")
title1 = "series. Entities and their frequencies are shown for the min and max (partial) values. Word count for the text from each book is given in parenthesis."
ax1.text(90,25, textwrap.fill("People", width=35),fontsize=14, family='Serif', color=people_color, fontweight='bold')
ax1.text(116,25, "and",fontsize=14, family='Serif')
ax1.text(130,25, "Places",fontsize=14, family='Serif', color=places_color, fontweight='bold')
ax1.text(155,25, "in Sherlock Holmes",fontsize=14, family='Serif')
ax1.text(90,31, textwrap.fill(title1, width=40),fontsize=14, family='Serif')
ax1.set_facecolor(bg_color)
fig1.patch.set_facecolor(bg_color)
plt.savefig("Sherlock_Holmes.png", dpi=300, bbox_inches='tight')
plt.show()