├── .gitignore
├── LICENSE
├── README.md
├── data
├── book.txt
├── create_final_community_reports.parquet
├── create_final_entities.parquet
├── create_final_nodes.parquet
└── create_summarized_entities.parquet
├── graphrag_lite
├── __init__.py
├── cluster_graph.py
└── global_search.ipynb
└── requirements.txt
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 | *.output
9 |
10 | # Distribution / packaging
11 | .Python
12 | build/
13 | develop-eggs/
14 | dist/
15 | downloads/
16 | eggs/
17 | .eggs/
18 | lib/
19 | lib64/
20 | parts/
21 | sdist/
22 | var/
23 | wheels/
24 | share/python-wheels/
25 | *.egg-info/
26 | .installed.cfg
27 | *.egg
28 | MANIFEST
29 |
30 | # PyInstaller
31 | # Usually these files are written by a python script from a template
32 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
33 | *.manifest
34 | *.spec
35 |
36 | # Installer logs
37 | pip-log.txt
38 | pip-delete-this-directory.txt
39 |
40 | # Unit test / coverage reports
41 | htmlcov/
42 | .tox/
43 | .nox/
44 | .coverage
45 | .coverage.*
46 | .cache
47 | nosetests.xml
48 | coverage.xml
49 | *.cover
50 | *.py,cover
51 | .hypothesis/
52 | .pytest_cache/
53 | cover/
54 |
55 | # Translations
56 | *.mo
57 | *.pot
58 |
59 | # Django stuff:
60 | *.log
61 | local_settings.py
62 | db.sqlite3
63 | db.sqlite3-journal
64 |
65 | # Flask stuff:
66 | instance/
67 | .webassets-cache
68 |
69 | # Scrapy stuff:
70 | .scrapy
71 |
72 | # Sphinx documentation
73 | docs/_build/
74 |
75 | # PyBuilder
76 | .pybuilder/
77 | target/
78 |
79 | # Jupyter Notebook
80 | .ipynb_checkpoints
81 |
82 | # IPython
83 | profile_default/
84 | ipython_config.py
85 |
86 | # pyenv
87 | # For a library or package, you might want to ignore these files since the code is
88 | # intended to run in multiple environments; otherwise, check them in:
89 | # .python-version
90 |
91 | # pipenv
92 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
94 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
95 | # install all needed dependencies.
96 | #Pipfile.lock
97 |
98 | # poetry
99 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
100 | # This is especially recommended for binary packages to ensure reproducibility, and is more
101 | # commonly ignored for libraries.
102 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
103 | #poetry.lock
104 |
105 | # pdm
106 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
107 | #pdm.lock
108 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
109 | # in version control.
110 | # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
111 | .pdm.toml
112 | .pdm-python
113 | .pdm-build/
114 |
115 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
116 | __pypackages__/
117 |
118 | # Celery stuff
119 | celerybeat-schedule
120 | celerybeat.pid
121 |
122 | # SageMath parsed files
123 | *.sage.py
124 |
125 | # Environments
126 | .env
127 | .venv
128 | env/
129 | venv/
130 | ENV/
131 | env.bak/
132 | venv.bak/
133 |
134 | # Spyder project settings
135 | .spyderproject
136 | .spyproject
137 |
138 | # Rope project settings
139 | .ropeproject
140 |
141 | # mkdocs documentation
142 | /site
143 |
144 | # mypy
145 | .mypy_cache/
146 | .dmypy.json
147 | dmypy.json
148 |
149 | # Pyre type checker
150 | .pyre/
151 |
152 | # pytype static type analyzer
153 | .pytype/
154 |
155 | # Cython debug symbols
156 | cython_debug/
157 |
158 | # PyCharm
159 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
160 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
161 | # and can be added to the global gitignore or merged into this file. For a more nuclear
162 | # option (not recommended) you can uncomment the following to ignore the entire idea folder.
163 | #.idea/
164 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # GraphRAG Lite
2 |
3 | A lightweight version of the Microsoft [GraphRAG](https://github.com/microsoft/graphrag) project.
4 |
5 | > Note: The development is currently in progress.
6 |
7 | ## Getting Started
8 |
9 | ```shell
10 | pip install -r requirements.txt
11 | ```
12 |
13 | ### 1. Graph Clustering
14 |
15 | ```python
16 | python graphrag_lite/cluster_graph.py
17 | ```
18 |
19 | This will create a `create_base_entity_graph.parquet` file in the `data` directory.
20 |
21 | ### 2. Global Search
22 |
23 | Play with `graphrag_lite/global_search.ipynb` notebook.
24 |
25 | - Configure the OpenAI API key and Model first
26 | - This demo will cost approximately 20K tokens, around $0.1
27 |
--------------------------------------------------------------------------------
/data/book.txt:
--------------------------------------------------------------------------------
1 | The Project Gutenberg eBook of A Christmas Carol
2 |
3 | This ebook is for the use of anyone anywhere in the United States and
4 | most other parts of the world at no cost and with almost no restrictions
5 | whatsoever. You may copy it, give it away or re-use it under the terms
6 | of the Project Gutenberg License included with this ebook or online
7 | at www.gutenberg.org. If you are not located in the United States,
8 | you will have to check the laws of the country where you are located
9 | before using this eBook.
10 |
11 | Title: A Christmas Carol
12 |
13 | Author: Charles Dickens
14 |
15 | Illustrator: Arthur Rackham
16 |
17 | Release date: December 24, 2007 [eBook #24022]
18 |
19 | Language: English
20 |
21 | Original publication: Philadelphia and New York: J. B. Lippincott Company,, 1915
22 |
23 | Credits: Produced by Suzanne Shell, Janet Blenkinship and the Online
24 | Distributed Proofreading Team at http://www.pgdp.net
25 |
26 |
27 | *** START OF THE PROJECT GUTENBERG EBOOK A CHRISTMAS CAROL ***
28 |
29 |
30 |
31 |
32 | Produced by Suzanne Shell, Janet Blenkinship and the Online
33 | Distributed Proofreading Team at http://www.pgdp.net
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 | A CHRISTMAS CAROL
46 |
47 | [Illustration: _"How now?" said Scrooge, caustic and cold as ever.
48 | "What do you want with me?"_]
49 |
50 |
51 | A CHRISTMAS CAROL
52 |
53 | [Illustration]
54 |
55 | BY
56 |
57 | CHARLES DICKENS
58 |
59 | [Illustration]
60 |
61 | ILLUSTRATED BY ARTHUR RACKHAM
62 |
63 | [Illustration]
64 |
65 | J. B. LIPPINCOTT COMPANY PHILADELPHIA AND NEW YORK
66 |
67 | FIRST PUBLISHED 1915
68 |
69 | REPRINTED 1923, 1927, 1932, 1933, 1934, 1935, 1947, 1948, 1952, 1958,
70 | 1962, 1964, 1966, 1967, 1969, 1971, 1972, 1973
71 |
72 | ISBN: 0-397-00033-2
73 |
74 | PRINTED IN GREAT BRITAIN
75 |
76 |
77 |
78 |
79 | PREFACE
80 |
81 | I have endeavoured in this Ghostly little book to raise the Ghost of an
82 | Idea which shall not put my readers out of humour with themselves, with
83 | each other, with the season, or with me. May it haunt their house
84 | pleasantly, and no one wish to lay it.
85 |
86 | Their faithful Friend and Servant,
87 |
88 | C. D.
89 |
90 | _December, 1843._
91 |
92 |
93 |
94 |
95 | CHARACTERS
96 |
97 | Bob Cratchit, clerk to Ebenezer Scrooge.
98 | Peter Cratchit, a son of the preceding.
99 | Tim Cratchit ("Tiny Tim"), a cripple, youngest son of Bob Cratchit.
100 | Mr. Fezziwig, a kind-hearted, jovial old merchant.
101 | Fred, Scrooge's nephew.
102 | Ghost of Christmas Past, a phantom showing things past.
103 | Ghost of Christmas Present, a spirit of a kind, generous,
104 | and hearty nature.
105 | Ghost of Christmas Yet to Come, an apparition showing the shadows
106 | of things which yet may happen.
107 | Ghost of Jacob Marley, a spectre of Scrooge's former partner in business.
108 | Joe, a marine-store dealer and receiver of stolen goods.
109 | Ebenezer Scrooge, a grasping, covetous old man, the surviving partner
110 | of the firm of Scrooge and Marley.
111 | Mr. Topper, a bachelor.
112 | Dick Wilkins, a fellow apprentice of Scrooge's.
113 |
114 | Belle, a comely matron, an old sweetheart of Scrooge's.
115 | Caroline, wife of one of Scrooge's debtors.
116 | Mrs. Cratchit, wife of Bob Cratchit.
117 | Belinda and Martha Cratchit, daughters of the preceding.
118 |
119 | Mrs. Dilber, a laundress.
120 | Fan, the sister of Scrooge.
121 | Mrs. Fezziwig, the worthy partner of Mr. Fezziwig.
122 |
123 |
124 |
125 |
126 | CONTENTS
127 |
128 | STAVE ONE--MARLEY'S GHOST 3
129 | STAVE TWO--THE FIRST OF THE THREE SPIRITS 37
130 | STAVE THREE--THE SECOND OF THE THREE SPIRITS 69
131 | STAVE FOUR--THE LAST OF THE SPIRITS 111
132 | STAVE FIVE--THE END OF IT 137
133 |
134 |
135 | LIST OF ILLUSTRATIONS
136 |
137 | _IN COLOUR_
138 |
139 |
140 | "How now?" said Scrooge, caustic
141 | and cold as ever. "What do you
142 | want with me?" _Frontispiece_
143 |
144 | Bob Cratchit went down a slide on
145 | Cornhill, at the end of a lane of
146 | boys, twenty times, in honour of
147 | its being Christmas Eve 16
148 |
149 | Nobody under the bed; nobody in
150 | the closet; nobody in his dressing-gown,
151 | which was hanging up
152 | in a suspicious attitude against
153 | the wall 20
154 |
155 | The air was filled with phantoms,
156 | wandering hither and thither in
157 | restless haste and moaning as
158 | they went 32
159 |
160 | Then old Fezziwig stood out to
161 | dance with Mrs. Fezziwig 54
162 |
163 | A flushed and boisterous group 62
164 |
165 | Laden with Christmas toys and
166 | presents 64
167 |
168 | The way he went after that plump
169 | sister in the lace tucker! 100
170 |
171 | "How are you?" said one.
172 | "How are you?" returned the other.
173 | "Well!" said the first. "Old
174 | Scratch has got his own at last,
175 | hey?" 114
176 |
177 | "What do you call this?" said Joe.
178 | "Bed-curtains!" "Ah!" returned
179 | the woman, laughing....
180 | "Bed-curtains!"
181 |
182 | "You don't mean to say you took
183 | 'em down, rings and all, with him
184 | lying there?" said Joe.
185 |
186 | "Yes, I do," replied the woman.
187 | "Why not?" 120
188 |
189 | "It's I, your uncle Scrooge. I have
190 | come to dinner. Will you let
191 | me in, Fred?" 144
192 |
193 | "Now, I'll tell you what, my friend,"
194 | said Scrooge. "I am not going
195 | to stand this sort of thing any
196 | longer." 146
197 |
198 | [Illustration]
199 |
200 | _IN BLACK AND WHITE_
201 |
202 |
203 | Tailpiece vi
204 | Tailpiece to List of Coloured Illustrations x
205 | Tailpiece to List of Black and White Illustrations xi
206 | Heading to Stave One 3
207 | They were portly gentlemen, pleasant to behold 12
208 | On the wings of the wind 28-29
209 | Tailpiece to Stave One 34
210 | Heading to Stave Two 37
211 | He produced a decanter of curiously
212 | light wine and a block of curiously heavy cake 50
213 | She left him, and they parted 60
214 | Tailpiece to Stave Two 65
215 | Heading to Stave Three 69
216 | There was nothing very cheerful in the climate 75
217 | He had been Tim's blood-horse all the way from church 84-85
218 | With the pudding 88
219 | Heading to Stave Four 111
220 | Heading to Stave Five 137
221 | Tailpiece to Stave Five 147
222 |
223 | [Illustration]
224 |
225 |
226 | STAVE ONE
227 |
228 |
229 | [Illustration]
230 |
231 |
232 |
233 |
234 | MARLEY'S GHOST
235 |
236 |
237 | Marley was dead, to begin with. There is no doubt whatever about that.
238 | The register of his burial was signed by the clergyman, the clerk, the
239 | undertaker, and the chief mourner. Scrooge signed it. And Scrooge's name
240 | was good upon 'Change for anything he chose to put his hand to. Old
241 | Marley was as dead as a door-nail.
242 |
243 | Mind! I don't mean to say that I know of my own knowledge, what there is
244 | particularly dead about a door-nail. I might have been inclined, myself,
245 | to regard a coffin-nail as the deadest piece of ironmongery in the
246 | trade. But the wisdom of our ancestors is in the simile; and my
247 | unhallowed hands shall not disturb it, or the country's done for. You
248 | will, therefore, permit me to repeat, emphatically, that Marley was as
249 | dead as a door-nail.
250 |
251 | Scrooge knew he was dead? Of course he did. How could it be otherwise?
252 | Scrooge and he were partners for I don't know how many years. Scrooge
253 | was his sole executor, his sole administrator, his sole assign, his sole
254 | residuary legatee, his sole friend, and sole mourner. And even Scrooge
255 | was not so dreadfully cut up by the sad event but that he was an
256 | excellent man of business on the very day of the funeral, and solemnised
257 | it with an undoubted bargain.
258 |
259 | The mention of Marley's funeral brings me back to the point I started
260 | from. There is no doubt that Marley was dead. This must be distinctly
261 | understood, or nothing wonderful can come of the story I am going to
262 | relate. If we were not perfectly convinced that Hamlet's father died
263 | before the play began, there would be nothing more remarkable in his
264 | taking a stroll at night, in an easterly wind, upon his own ramparts,
265 | than there would be in any other middle-aged gentleman rashly turning
266 | out after dark in a breezy spot--say St. Paul's Churchyard, for
267 | instance--literally to astonish his son's weak mind.
268 |
269 | Scrooge never painted out Old Marley's name. There it stood, years
270 | afterwards, above the warehouse door: Scrooge and Marley. The firm was
271 | known as Scrooge and Marley. Sometimes people new to the business called
272 | Scrooge Scrooge, and sometimes Marley, but he answered to both names. It
273 | was all the same to him.
274 |
275 | Oh! but he was a tight-fisted hand at the grindstone, Scrooge! a
276 | squeezing, wrenching, grasping, scraping, clutching, covetous old
277 | sinner! Hard and sharp as flint, from which no steel had ever struck out
278 | generous fire; secret, and self-contained, and solitary as an oyster.
279 | The cold within him froze his old features, nipped his pointed nose,
280 | shrivelled his cheek, stiffened his gait; made his eyes red, his thin
281 | lips blue; and spoke out shrewdly in his grating voice. A frosty rime
282 | was on his head, and on his eyebrows, and his wiry chin. He carried his
283 | own low temperature always about with him; he iced his office in the
284 | dog-days, and didn't thaw it one degree at Christmas.
285 |
286 | External heat and cold had little influence on Scrooge. No warmth could
287 | warm, no wintry weather chill him. No wind that blew was bitterer than
288 | he, no falling snow was more intent upon its purpose, no pelting rain
289 | less open to entreaty. Foul weather didn't know where to have him. The
290 | heaviest rain, and snow, and hail, and sleet could boast of the
291 | advantage over him in only one respect. They often 'came down'
292 | handsomely, and Scrooge never did.
293 |
294 | Nobody ever stopped him in the street to say, with gladsome looks, 'My
295 | dear Scrooge, how are you? When will you come to see me?' No beggars
296 | implored him to bestow a trifle, no children asked him what it was
297 | o'clock, no man or woman ever once in all his life inquired the way to
298 | such and such a place, of Scrooge. Even the blind men's dogs appeared to
299 | know him; and, when they saw him coming on, would tug their owners into
300 | doorways and up courts; and then would wag their tails as though they
301 | said, 'No eye at all is better than an evil eye, dark master!'
302 |
303 | But what did Scrooge care? It was the very thing he liked. To edge his
304 | way along the crowded paths of life, warning all human sympathy to keep
305 | its distance, was what the knowing ones call 'nuts' to Scrooge.
306 |
307 | Once upon a time--of all the good days in the year, on Christmas
308 | Eve--old Scrooge sat busy in his counting-house. It was cold, bleak,
309 | biting weather; foggy withal; and he could hear the people in the court
310 | outside go wheezing up and down, beating their hands upon their breasts,
311 | and stamping their feet upon the pavement stones to warm them. The City
312 | clocks had only just gone three, but it was quite dark already--it had
313 | not been light all day--and candles were flaring in the windows of the
314 | neighbouring offices, like ruddy smears upon the palpable brown air. The
315 | fog came pouring in at every chink and keyhole, and was so dense
316 | without, that, although the court was of the narrowest, the houses
317 | opposite were mere phantoms. To see the dingy cloud come drooping down,
318 | obscuring everything, one might have thought that nature lived hard by,
319 | and was brewing on a large scale.
320 |
321 | The door of Scrooge's counting-house was open, that he might keep his
322 | eye upon his clerk, who in a dismal little cell beyond, a sort of tank,
323 | was copying letters. Scrooge had a very small fire, but the clerk's fire
324 | was so very much smaller that it looked like one coal. But he couldn't
325 | replenish it, for Scrooge kept the coal-box in his own room; and so
326 | surely as the clerk came in with the shovel, the master predicted that
327 | it would be necessary for them to part. Wherefore the clerk put on his
328 | white comforter, and tried to warm himself at the candle; in which
329 | effort, not being a man of strong imagination, he failed.
330 |
331 | 'A merry Christmas, uncle! God save you!' cried a cheerful voice. It was
332 | the voice of Scrooge's nephew, who came upon him so quickly that this
333 | was the first intimation he had of his approach.
334 |
335 | 'Bah!' said Scrooge. 'Humbug!'
336 |
337 | He had so heated himself with rapid walking in the fog and frost, this
338 | nephew of Scrooge's, that he was all in a glow; his face was ruddy and
339 | handsome; his eyes sparkled, and his breath smoked again.
340 |
341 | 'Christmas a humbug, uncle!' said Scrooge's nephew. 'You don't mean
342 | that, I am sure?'
343 |
344 | 'I do,' said Scrooge. 'Merry Christmas! What right have you to be merry?
345 | What reason have you to be merry? You're poor enough.'
346 |
347 | 'Come, then,' returned the nephew gaily. 'What right have you to be
348 | dismal? What reason have you to be morose? You're rich enough.'
349 |
350 | Scrooge, having no better answer ready on the spur of the moment, said,
351 | 'Bah!' again; and followed it up with 'Humbug!'
352 |
353 | 'Don't be cross, uncle!' said the nephew.
354 |
355 | 'What else can I be,' returned the uncle, 'when I live in such a world
356 | of fools as this? Merry Christmas! Out upon merry Christmas! What's
357 | Christmas-time to you but a time for paying bills without money; a time
358 | for finding yourself a year older, and not an hour richer; a time for
359 | balancing your books, and having every item in 'em through a round dozen
360 | of months presented dead against you? If I could work my will,' said
361 | Scrooge indignantly, 'every idiot who goes about with "Merry Christmas"
362 | on his lips should be boiled with his own pudding, and buried with a
363 | stake of holly through his heart. He should!'
364 |
365 | 'Uncle!' pleaded the nephew.
366 |
367 | 'Nephew!' returned the uncle sternly, 'keep Christmas in your own way,
368 | and let me keep it in mine.'
369 |
370 | 'Keep it!' repeated Scrooge's nephew. 'But you don't keep it.'
371 |
372 | 'Let me leave it alone, then,' said Scrooge. 'Much good may it do you!
373 | Much good it has ever done you!'
374 |
375 | 'There are many things from which I might have derived good, by which I
376 | have not profited, I dare say,' returned the nephew; 'Christmas among
377 | the rest. But I am sure I have always thought of Christmas-time, when
378 | it has come round--apart from the veneration due to its sacred name and
379 | origin, if anything belonging to it can be apart from that--as a good
380 | time; a kind, forgiving, charitable, pleasant time; the only time I know
381 | of, in the long calendar of the year, when men and women seem by one
382 | consent to open their shut-up hearts freely, and to think of people
383 | below them as if they really were fellow-passengers to the grave, and
384 | not another race of creatures bound on other journeys. And therefore,
385 | uncle, though it has never put a scrap of gold or silver in my pocket, I
386 | believe that it _has_ done me good and _will_ do me good; and I say, God
387 | bless it!'
388 |
389 | The clerk in the tank involuntarily applauded. Becoming immediately
390 | sensible of the impropriety, he poked the fire, and extinguished the
391 | last frail spark for ever.
392 |
393 | 'Let me hear another sound from _you_,' said Scrooge, 'and you'll keep
394 | your Christmas by losing your situation! You're quite a powerful
395 | speaker, sir,' he added, turning to his nephew. 'I wonder you don't go
396 | into Parliament.'
397 |
398 | 'Don't be angry, uncle. Come! Dine with us to-morrow.'
399 |
400 | Scrooge said that he would see him----Yes, indeed he did. He went the
401 | whole length of the expression, and said that he would see him in that
402 | extremity first.
403 |
404 | 'But why?' cried Scrooge's nephew. 'Why?'
405 |
406 | 'Why did you get married?' said Scrooge.
407 |
408 | 'Because I fell in love.'
409 |
410 | 'Because you fell in love!' growled Scrooge, as if that were the only
411 | one thing in the world more ridiculous than a merry Christmas. 'Good
412 | afternoon!'
413 |
414 | 'Nay, uncle, but you never came to see me before that happened. Why give
415 | it as a reason for not coming now?'
416 |
417 | 'Good afternoon,' said Scrooge.
418 |
419 | 'I want nothing from you; I ask nothing of you; why cannot we be
420 | friends?'
421 |
422 | 'Good afternoon!' said Scrooge.
423 |
424 | 'I am sorry, with all my heart, to find you so resolute. We have never
425 | had any quarrel to which I have been a party. But I have made the trial
426 | in homage to Christmas, and I'll keep my Christmas humour to the last.
427 | So A Merry Christmas, uncle!'
428 |
429 | 'Good afternoon,' said Scrooge.
430 |
431 | 'And A Happy New Year!'
432 |
433 | 'Good afternoon!' said Scrooge.
434 |
435 | His nephew left the room without an angry word, notwithstanding. He
436 | stopped at the outer door to bestow the greetings of the season on the
437 | clerk, who, cold as he was, was warmer than Scrooge; for he returned
438 | them cordially.
439 |
440 | 'There's another fellow,' muttered Scrooge, who overheard him: 'my
441 | clerk, with fifteen shillings a week, and a wife and family, talking
442 | about a merry Christmas. I'll retire to Bedlam.'
443 |
444 | This lunatic, in letting Scrooge's nephew out, had let two other people
445 | in. They were portly gentlemen, pleasant to behold, and now stood, with
446 | their hats off, in Scrooge's office. They had books and papers in their
447 | hands, and bowed to him.
448 |
449 | 'Scrooge and Marley's, I believe,' said one of the gentlemen, referring
450 | to his list. 'Have I the pleasure of addressing Mr. Scrooge, or Mr.
451 | Marley?'
452 |
453 | 'Mr. Marley has been dead these seven years,' Scrooge replied. 'He died
454 | seven years ago, this very night.'
455 |
456 | 'We have no doubt his liberality is well represented by his surviving
457 | partner,' said the gentleman, presenting his credentials.
458 |
459 | [Illustration: THEY WERE PORTLY GENTLEMEN, PLEASANT TO BEHOLD]
460 |
461 | It certainly was; for they had been two kindred spirits. At the ominous
462 | word 'liberality' Scrooge frowned, and shook his head, and handed the
463 | credentials back.
464 |
465 | 'At this festive season of the year, Mr. Scrooge,' said the gentleman,
466 | taking up a pen, 'it is more than usually desirable that we should make
467 | some slight provision for the poor and destitute, who suffer greatly at
468 | the present time. Many thousands are in want of common necessaries;
469 | hundreds of thousands are in want of common comforts, sir.'
470 |
471 | 'Are there no prisons?' asked Scrooge.
472 |
473 | 'Plenty of prisons,' said the gentleman, laying down the pen again.
474 |
475 | 'And the Union workhouses?' demanded Scrooge. 'Are they still in
476 | operation?'
477 |
478 | 'They are. Still,' returned the gentleman, 'I wish I could say they were
479 | not.'
480 |
481 | 'The Treadmill and the Poor Law are in full vigour, then?' said Scrooge.
482 |
483 | 'Both very busy, sir.'
484 |
485 | 'Oh! I was afraid, from what you said at first, that something had
486 | occurred to stop them in their useful course,' said Scrooge. 'I am very
487 | glad to hear it.'
488 |
489 | 'Under the impression that they scarcely furnish Christian cheer of mind
490 | or body to the multitude,' returned the gentleman, 'a few of us are
491 | endeavouring to raise a fund to buy the Poor some meat and drink, and
492 | means of warmth. We choose this time, because it is a time, of all
493 | others, when Want is keenly felt, and Abundance rejoices. What shall I
494 | put you down for?'
495 |
496 | 'Nothing!' Scrooge replied.
497 |
498 | 'You wish to be anonymous?'
499 |
500 | 'I wish to be left alone,' said Scrooge. 'Since you ask me what I wish,
501 | gentlemen, that is my answer. I don't make merry myself at Christmas,
502 | and I can't afford to make idle people merry. I help to support the
503 | establishments I have mentioned--they cost enough: and those who are
504 | badly off must go there.'
505 |
506 | 'Many can't go there; and many would rather die.'
507 |
508 | 'If they would rather die,' said Scrooge, 'they had better do it, and
509 | decrease the surplus population. Besides--excuse me--I don't know that.'
510 |
511 | 'But you might know it,' observed the gentleman.
512 |
513 | 'It's not my business,' Scrooge returned. 'It's enough for a man to
514 | understand his own business, and not to interfere with other people's.
515 | Mine occupies me constantly. Good afternoon, gentlemen!'
516 |
517 | Seeing clearly that it would be useless to pursue their point, the
518 | gentlemen withdrew. Scrooge resumed his labours with an improved opinion
519 | of himself, and in a more facetious temper than was usual with him.
520 |
521 | Meanwhile the fog and darkness thickened so, that people ran about with
522 | flaring links, proffering their services to go before horses in
523 | carriages, and conduct them on their way. The ancient tower of a church,
524 | whose gruff old bell was always peeping slyly down at Scrooge out of a
525 | Gothic window in the wall, became invisible, and struck the hours and
526 | quarters in the clouds, with tremulous vibrations afterwards, as if its
527 | teeth were chattering in its frozen head up there. The cold became
528 | intense. In the main street, at the corner of the court, some labourers
529 | were repairing the gas-pipes, and had lighted a great fire in a brazier,
530 | round which a party of ragged men and boys were gathered: warming their
531 | hands and winking their eyes before the blaze in rapture. The water-plug
532 | being left in solitude, its overflowings suddenly congealed, and turned
533 | to misanthropic ice. The brightness of the shops, where holly sprigs and
534 | berries crackled in the lamp heat of the windows, made pale faces ruddy
535 | as they passed. Poulterers' and grocers' trades became a splendid joke:
536 | a glorious pageant, with which it was next to impossible to believe that
537 | such dull principles as bargain and sale had anything to do. The Lord
538 | Mayor, in the stronghold of the mighty Mansion House, gave orders to his
539 | fifty cooks and butlers to keep Christmas as a Lord Mayor's household
540 | should; and even the little tailor, whom he had fined five shillings on
541 | the previous Monday for being drunk and bloodthirsty in the streets,
542 | stirred up to-morrow's pudding in his garret, while his lean wife and
543 | the baby sallied out to buy the beef.
544 |
545 | Foggier yet, and colder! Piercing, searching, biting cold. If the good
546 | St. Dunstan had but nipped the Evil Spirit's nose with a touch of such
547 | weather as that, instead of using his familiar weapons, then indeed he
548 | would have roared to lusty purpose. The owner of one scant young nose,
549 | gnawed and mumbled by the hungry cold as bones are gnawed by dogs,
550 | stooped down at Scrooge's keyhole to regale him with a Christmas carol;
551 | but, at the first sound of
552 |
553 | 'God bless you, merry gentleman,
554 | May nothing you dismay!'
555 |
556 | Scrooge seized the ruler with such energy of action that the singer fled
557 | in terror, leaving the keyhole to the fog, and even more congenial
558 | frost.
559 |
560 | At length the hour of shutting up the counting-house arrived. With an
561 | ill-will Scrooge dismounted from his stool, and tacitly admitted the
562 | fact to the expectant clerk in the tank, who instantly snuffed his
563 | candle out, and put on his hat.
564 |
565 | 'You'll want all day to-morrow, I suppose?' said Scrooge.
566 |
567 | 'If quite convenient, sir.'
568 |
569 | 'It's not convenient,' said Scrooge, 'and it's not fair. If I was to
570 | stop half-a-crown for it, you'd think yourself ill used, I'll be bound?'
571 |
572 | The clerk smiled faintly.
573 |
574 | 'And yet,' said Scrooge, 'you don't think _me_ ill used when I pay a
575 | day's wages for no work.'
576 |
577 | [Illustration: _Bob Cratchit went down a slide on Cornhill, at the end
578 | of a lane of boys, twenty times, in honour of its being Christmas
579 | Eve_]
580 |
581 | The clerk observed that it was only once a year.
582 |
583 | 'A poor excuse for picking a man's pocket every twenty-fifth of
584 | December!' said Scrooge, buttoning his greatcoat to the chin. 'But I
585 | suppose you must have the whole day. Be here all the earlier next
586 | morning.'
587 |
588 | The clerk promised that he would; and Scrooge walked out with a growl.
589 | The office was closed in a twinkling, and the clerk, with the long ends
590 | of his white comforter dangling below his waist (for he boasted no
591 | greatcoat), went down a slide on Cornhill, at the end of a lane of boys,
592 | twenty times, in honour of its being Christmas Eve, and then ran home to
593 | Camden Town as hard as he could pelt, to play at blind man's-buff.
594 |
595 | Scrooge took his melancholy dinner in his usual melancholy tavern; and
596 | having read all the newspapers, and beguiled the rest of the evening
597 | with his banker's book, went home to bed. He lived in chambers which had
598 | once belonged to his deceased partner. They were a gloomy suite of
599 | rooms, in a lowering pile of building up a yard, where it had so little
600 | business to be, that one could scarcely help fancying it must have run
601 | there when it was a young house, playing at hide-and-seek with other
602 | houses, and have forgotten the way out again. It was old enough now, and
603 | dreary enough; for nobody lived in it but Scrooge, the other rooms
604 | being all let out as offices. The yard was so dark that even Scrooge,
605 | who knew its every stone, was fain to grope with his hands. The fog and
606 | frost so hung about the black old gateway of the house, that it seemed
607 | as if the Genius of the Weather sat in mournful meditation on the
608 | threshold.
609 |
610 | Now, it is a fact that there was nothing at all particular about the
611 | knocker on the door, except that it was very large. It is also a fact
612 | that Scrooge had seen it, night and morning, during his whole residence
613 | in that place; also that Scrooge had as little of what is called fancy
614 | about him as any man in the City of London, even including--which is a
615 | bold word--the corporation, aldermen, and livery. Let it also be borne
616 | in mind that Scrooge had not bestowed one thought on Marley since his
617 | last mention of his seven-years'-dead partner that afternoon. And then
618 | let any man explain to me, if he can, how it happened that Scrooge,
619 | having his key in the lock of the door, saw in the knocker, without its
620 | undergoing any intermediate process of change--not a knocker, but
621 | Marley's face.
622 |
623 | Marley's face. It was not in impenetrable shadow, as the other objects
624 | in the yard were, but had a dismal light about it, like a bad lobster in
625 | a dark cellar. It was not angry or ferocious, but looked at Scrooge as
626 | Marley used to look; with ghostly spectacles turned up on its ghostly
627 | forehead. The hair was curiously stirred, as if by breath or hot air;
628 | and, though the eyes were wide open, they were perfectly motionless.
629 | That, and its livid colour, made it horrible; but its horror seemed to
630 | be in spite of the face, and beyond its control, rather than a part of
631 | its own expression.
632 |
633 | As Scrooge looked fixedly at this phenomenon, it was a knocker again.
634 |
635 | To say that he was not startled, or that his blood was not conscious of
636 | a terrible sensation to which it had been a stranger from infancy, would
637 | be untrue. But he put his hand upon the key he had relinquished, turned
638 | it sturdily, walked in, and lighted his candle.
639 |
640 | He _did_ pause, with a moment's irresolution, before he shut the door;
641 | and he _did_ look cautiously behind it first, as if he half expected to
642 | be terrified with the sight of Marley's pigtail sticking out into the
643 | hall. But there was nothing on the back of the door, except the screws
644 | and nuts that held the knocker on, so he said, 'Pooh, pooh!' and closed
645 | it with a bang.
646 |
647 | The sound resounded through the house like thunder. Every room above,
648 | and every cask in the wine-merchant's cellars below, appeared to have a
649 | separate peal of echoes of its own. Scrooge was not a man to be
650 | frightened by echoes. He fastened the door, and walked across the hall,
651 | and up the stairs: slowly, too: trimming his candle as he went.
652 |
653 | You may talk vaguely about driving a coach and six up a good old flight
654 | of stairs, or through a bad young Act of Parliament; but I mean to say
655 | you might have got a hearse up that staircase, and taken it broadwise,
656 | with the splinter-bar towards the wall, and the door towards the
657 | balustrades: and done it easy. There was plenty of width for that, and
658 | room to spare; which is perhaps the reason why Scrooge thought he saw a
659 | locomotive hearse going on before him in the gloom. Half-a-dozen
660 | gas-lamps out of the street wouldn't have lighted the entry too well, so
661 | you may suppose that it was pretty dark with Scrooge's dip.
662 |
663 | Up Scrooge went, not caring a button for that. Darkness is cheap, and
664 | Scrooge liked it. But, before he shut his heavy door, he walked through
665 | his rooms to see that all was right. He had just enough recollection of
666 | the face to desire to do that.
667 |
668 | Sitting-room, bedroom, lumber-room. All as they should be. Nobody under
669 | the table, nobody under the sofa; a small fire in the grate; spoon and
670 | basin ready; and the little saucepan of gruel (Scrooge had a cold in his
671 | head) upon the hob. Nobody under the bed; nobody in the closet; nobody
672 | in his dressing-gown, which was hanging up in a suspicious attitude
673 | against the wall. Lumber-room as usual. Old fire-guard, old shoes, two
674 | fish baskets, washing-stand on three legs, and a poker.
675 |
676 | [Illustration: _Nobody under the bed; nobody in the closet; nobody in
677 | his dressing-gown, which was hanging up in a suspicious attitude against
678 | the wall_]
679 |
680 | Quite satisfied, he closed his door, and locked himself in; double
681 | locked himself in, which was not his custom. Thus secured against
682 | surprise, he took off his cravat; put on his dressing-gown and slippers,
683 | and his nightcap; and sat down before the fire to take his gruel.
684 |
685 | It was a very low fire indeed; nothing on such a bitter night. He was
686 | obliged to sit close to it, and brood over it, before he could extract
687 | the least sensation of warmth from such a handful of fuel. The fireplace
688 | was an old one, built by some Dutch merchant long ago, and paved all
689 | round with quaint Dutch tiles, designed to illustrate the Scriptures.
690 | There were Cains and Abels, Pharaoh's daughters, Queens of Sheba,
691 | Angelic messengers descending through the air on clouds like
692 | feather-beds, Abrahams, Belshazzars, Apostles putting off to sea in
693 | butter-boats, hundreds of figures to attract his thoughts; and yet that
694 | face of Marley, seven years dead, came like the ancient Prophet's rod,
695 | and swallowed up the whole. If each smooth tile had been a blank at
696 | first, with power to shape some picture on its surface from the
697 | disjointed fragments of his thoughts, there would have been a copy of
698 | old Marley's head on every one.
699 |
700 | 'Humbug!' said Scrooge; and walked across the room.
701 |
702 | After several turns he sat down again. As he threw his head back in the
703 | chair, his glance happened to rest upon a bell, a disused bell, that
704 | hung in the room, and communicated, for some purpose now forgotten, with
705 | a chamber in the highest storey of the building. It was with great
706 | astonishment, and with a strange, inexplicable dread, that, as he
707 | looked, he saw this bell begin to swing. It swung so softly in the
708 | outset that it scarcely made a sound; but soon it rang out loudly, and
709 | so did every bell in the house.
710 |
711 | This might have lasted half a minute, or a minute, but it seemed an
712 | hour. The bells ceased, as they had begun, together. They were succeeded
713 | by a clanking noise deep down below as if some person were dragging a
714 | heavy chain over the casks in the wine-merchant's cellar. Scrooge then
715 | remembered to have heard that ghosts in haunted houses were described as
716 | dragging chains.
717 |
718 | The cellar door flew open with a booming sound, and then he heard the
719 | noise much louder on the floors below; then coming up the stairs; then
720 | coming straight towards his door.
721 |
722 | 'It's humbug still!' said Scrooge. 'I won't believe it.'
723 |
724 | His colour changed, though, when, without a pause, it came on through
725 | the heavy door and passed into the room before his eyes. Upon its coming
726 | in, the dying flame leaped up, as though it cried, 'I know him! Marley's
727 | Ghost!' and fell again.
728 |
729 | The same face: the very same. Marley in his pigtail, usual waistcoat,
730 | tights, and boots; the tassels on the latter bristling, like his
731 | pigtail, and his coat-skirts, and the hair upon his head. The chain he
732 | drew was clasped about his middle. It was long, and wound about him like
733 | a tail; and it was made (for Scrooge observed it closely) of cash-boxes,
734 | keys, padlocks, ledgers, deeds, and heavy purses wrought in steel. His
735 | body was transparent: so that Scrooge, observing him, and looking
736 | through his waistcoat, could see the two buttons on his coat behind.
737 |
738 | Scrooge had often heard it said that Marley had no bowels, but he had
739 | never believed it until now.
740 |
741 | No, nor did he believe it even now. Though he looked the phantom through
742 | and through, and saw it standing before him; though he felt the chilling
743 | influence of its death-cold eyes, and marked the very texture of the
744 | folded kerchief bound about its head and chin, which wrapper he had not
745 | observed before, he was still incredulous, and fought against his
746 | senses.
747 |
748 | 'How now!' said Scrooge, caustic and cold as ever. 'What do you want
749 | with me?'
750 |
751 | 'Much!'--Marley's voice; no doubt about it.
752 |
753 | 'Who are you?'
754 |
755 | 'Ask me who I _was_.'
756 |
757 | 'Who _were_ you, then?' said Scrooge, raising his voice. 'You're
758 | particular, for a shade.' He was going to say '_to_ a shade,' but
759 | substituted this, as more appropriate.
760 |
761 | 'In life I was your partner, Jacob Marley.'
762 |
763 | 'Can you--can you sit down?' asked Scrooge, looking doubtfully at him.
764 |
765 | 'I can.'
766 |
767 | 'Do it, then.'
768 |
769 | Scrooge asked the question, because he didn't know whether a ghost so
770 | transparent might find himself in a condition to take a chair; and felt
771 | that in the event of its being impossible, it might involve the
772 | necessity of an embarrassing explanation. But the Ghost sat down on the
773 | opposite side of the fireplace, as if he were quite used to it.
774 |
775 | 'You don't believe in me,' observed the Ghost.
776 |
777 | 'I don't,' said Scrooge.
778 |
779 | 'What evidence would you have of my reality beyond that of your own
780 | senses?'
781 |
782 | 'I don't know,' said Scrooge.
783 |
784 | 'Why do you doubt your senses?'
785 |
786 | 'Because,' said Scrooge, 'a little thing affects them. A slight disorder
787 | of the stomach makes them cheats. You may be an undigested bit of beef,
788 | a blot of mustard, a crumb of cheese, a fragment of an underdone potato.
789 | There's more of gravy than of grave about you, whatever you are!'
790 |
791 | Scrooge was not much in the habit of cracking jokes, nor did he feel in
792 | his heart by any means waggish then. The truth is, that he tried to be
793 | smart, as a means of distracting his own attention, and keeping down his
794 | terror; for the spectre's voice disturbed the very marrow in his bones.
795 |
796 | To sit staring at those fixed, glazed eyes in silence, for a moment,
797 | would play, Scrooge felt, the very deuce with him. There was something
798 | very awful, too, in the spectre's being provided with an infernal
799 | atmosphere of his own. Scrooge could not feel it himself, but this was
800 | clearly the case; for though the Ghost sat perfectly motionless, its
801 | hair, and skirts, and tassels were still agitated as by the hot vapour
802 | from an oven.
803 |
804 | 'You see this toothpick?' said Scrooge, returning quickly to the charge,
805 | for the reason just assigned; and wishing, though it were only for a
806 | second, to divert the vision's stony gaze from himself.
807 |
808 | 'I do,' replied the Ghost.
809 |
810 | 'You are not looking at it,' said Scrooge.
811 |
812 | 'But I see it,' said the Ghost, 'notwithstanding.'
813 |
814 | 'Well!' returned Scrooge, 'I have but to swallow this, and be for the
815 | rest of my days persecuted by a legion of goblins, all of my own
816 | creation. Humbug, I tell you: humbug!'
817 |
818 | At this the spirit raised a frightful cry, and shook its chain with such
819 | a dismal and appalling noise, that Scrooge held on tight to his chair,
820 | to save himself from falling in a swoon. But how much greater was his
821 | horror when the phantom, taking off the bandage round his head, as if it
822 | were too warm to wear indoors, its lower jaw dropped down upon its
823 | breast!
824 |
825 | Scrooge fell upon his knees, and clasped his hands before his face.
826 |
827 | 'Mercy!' he said. 'Dreadful apparition, why do you trouble me?'
828 |
829 | 'Man of the worldly mind!' replied the Ghost, 'do you believe in me or
830 | not?'
831 |
832 | 'I do,' said Scrooge; 'I must. But why do spirits walk the earth, and
833 | why do they come to me?'
834 |
835 | 'It is required of every man,' the Ghost returned, 'that the spirit
836 | within him should walk abroad among his fellow-men, and travel far and
837 | wide; and, if that spirit goes not forth in life, it is condemned to do
838 | so after death. It is doomed to wander through the world--oh, woe is
839 | me!--and witness what it cannot share, but might have shared on earth,
840 | and turned to happiness!'
841 |
842 | Again the spectre raised a cry, and shook its chain and wrung its
843 | shadowy hands.
844 |
845 | 'You are fettered,' said Scrooge, trembling. 'Tell me why?'
846 |
847 | 'I wear the chain I forged in life,' replied the Ghost. 'I made it link
848 | by link, and yard by yard; I girded it on of my own free will, and of
849 | my own free will I wore it. Is its pattern strange to _you_?'
850 |
851 | Scrooge trembled more and more.
852 |
853 | 'Or would you know,' pursued the Ghost, 'the weight and length of the
854 | strong coil you bear yourself? It was full as heavy and as long as this
855 | seven Christmas Eves ago. You have laboured on it since. It is a
856 | ponderous chain!'
857 |
858 | Scrooge glanced about him on the floor, in the expectation of finding
859 | himself surrounded by some fifty or sixty fathoms of iron cable; but he
860 | could see nothing.
861 |
862 | 'Jacob!' he said imploringly. 'Old Jacob Marley, tell me more! Speak
863 | comfort to me, Jacob!'
864 |
865 | 'I have none to give,' the Ghost replied. 'It comes from other regions,
866 | Ebenezer Scrooge, and is conveyed by other ministers, to other kinds of
867 | men. Nor can I tell you what I would. A very little more is all
868 | permitted to me. I cannot rest, I cannot stay, I cannot linger anywhere.
869 | My spirit never walked beyond our counting-house--mark me;--in life my
870 | spirit never roved beyond the narrow limits of our money-changing hole;
871 | and weary journeys lie before me!'
872 |
873 | It was a habit with Scrooge, whenever he became thoughtful, to put his
874 | hands in his breeches pockets. Pondering on what the Ghost had said, he
875 | did so now, but without lifting up his eyes, or getting off his knees.
876 |
877 | [Illustration: ON THE WINGS OF THE WIND]
878 |
879 | 'You must have been very slow about it, Jacob,' Scrooge observed in a
880 | business-like manner, though with humility and deference.
881 |
882 | 'Slow!' the Ghost repeated.
883 |
884 | 'Seven years dead,' mused Scrooge. 'And travelling all the time?'
885 |
886 | 'The whole time,' said the Ghost. 'No rest, no peace. Incessant torture
887 | of remorse.'
888 |
889 | 'You travel fast?' said Scrooge.
890 |
891 | [Illustration]
892 |
893 | 'On the wings of the wind,' replied the Ghost.
894 |
895 | 'You might have got over a great quantity of ground in seven years,'
896 | said Scrooge.
897 |
898 | The Ghost, on hearing this, set up another cry, and clanked its chain so
899 | hideously in the dead silence of the night, that the Ward would have
900 | been justified in indicting it for a nuisance.
901 |
902 | 'Oh! captive, bound, and double-ironed,' cried the phantom, 'not to know
903 | that ages of incessant labour, by immortal creatures, for this earth
904 | must pass into eternity before the good of which it is susceptible is
905 | all developed! Not to know that any Christian spirit working kindly in
906 | its little sphere, whatever it may be, will find its mortal life too
907 | short for its vast means of usefulness! Not to know that no space of
908 | regret can make amends for one life's opportunities misused! Yet such
909 | was I! Oh, such was I!'
910 |
911 | 'But you were always a good man of business, Jacob,' faltered Scrooge,
912 | who now began to apply this to himself.
913 |
914 | 'Business!' cried the Ghost, wringing its hands again. 'Mankind was my
915 | business. The common welfare was my business; charity, mercy,
916 | forbearance, and benevolence were, all, my business. The dealings of my
917 | trade were but a drop of water in the comprehensive ocean of my
918 | business!'
919 |
920 | It held up its chain at arm's-length, as if that were the cause of all
921 | its unavailing grief, and flung it heavily upon the ground again.
922 |
923 | 'At this time of the rolling year,' the spectre said, 'I suffer most.
924 | Why did I walk through crowds of fellow-beings with my eyes turned down,
925 | and never raise them to that blessed Star which led the Wise Men to a
926 | poor abode? Were there no poor homes to which its light would have
927 | conducted _me_?'
928 |
929 | Scrooge was very much dismayed to hear the spectre going on at this
930 | rate, and began to quake exceedingly.
931 |
932 | 'Hear me!' cried the Ghost. 'My time is nearly gone.'
933 |
934 | 'I will,' said Scrooge. 'But don't be hard upon me! Don't be flowery,
935 | Jacob! Pray!'
936 |
937 | 'How it is that I appear before you in a shape that you can see, I may
938 | not tell. I have sat invisible beside you many and many a day.'
939 |
940 | It was not an agreeable idea. Scrooge shivered, and wiped the
941 | perspiration from his brow.
942 |
943 | 'That is no light part of my penance,' pursued the Ghost. 'I am here
944 | to-night to warn you that you have yet a chance and hope of escaping my
945 | fate. A chance and hope of my procuring, Ebenezer.'
946 |
947 | 'You were always a good friend to me,' said Scrooge. 'Thankee!'
948 |
949 | 'You will be haunted,' resumed the Ghost, 'by Three Spirits.'
950 |
951 | Scrooge's countenance fell almost as low as the Ghost's had done.
952 |
953 | 'Is that the chance and hope you mentioned, Jacob?' he demanded in a
954 | faltering voice.
955 |
956 | 'It is.'
957 |
958 | 'I--I think I'd rather not,' said Scrooge.
959 |
960 | 'Without their visits,' said the Ghost, 'you cannot hope to shun the
961 | path I tread. Expect the first to-morrow when the bell tolls One.'
962 |
963 | 'Couldn't I take 'em all at once, and have it over, Jacob?' hinted
964 | Scrooge.
965 |
966 | 'Expect the second on the next night at the same hour. The third, upon
967 | the next night when the last stroke of Twelve has ceased to vibrate.
968 | Look to see me no more; and look that, for your own sake, you remember
969 | what has passed between us!'
970 |
971 | When it had said these words, the spectre took its wrapper from the
972 | table, and bound it round its head as before. Scrooge knew this by the
973 | smart sound its teeth made when the jaws were brought together by the
974 | bandage. He ventured to raise his eyes again, and found his supernatural
975 | visitor confronting him in an erect attitude, with its chain wound over
976 | and about its arm.
977 |
978 | [Illustration: _The air was filled with phantoms, wandering hither and
979 | thither in restless haste and moaning as they went_]
980 |
981 | The apparition walked backward from him; and, at every step it took, the
982 | window raised itself a little, so that, when the spectre reached it, it
983 | was wide open. It beckoned Scrooge to approach, which he did. When they
984 | were within two paces of each other, Marley's Ghost held up its hand,
985 | warning him to come no nearer. Scrooge stopped.
986 |
987 | Not so much in obedience as in surprise and fear; for, on the raising of
988 | the hand, he became sensible of confused noises in the air; incoherent
989 | sounds of lamentation and regret; wailings inexpressibly sorrowful and
990 | self-accusatory. The spectre, after listening for a moment, joined in
991 | the mournful dirge; and floated out upon the bleak, dark night.
992 |
993 | Scrooge followed to the window: desperate in his curiosity. He looked
994 | out.
995 |
996 | The air was filled with phantoms, wandering hither and thither in
997 | restless haste, and moaning as they went. Every one of them wore chains
998 | like Marley's Ghost; some few (they might be guilty governments) were
999 | linked together; none were free. Many had been personally known to
1000 | Scrooge in their lives. He had been quite familiar with one old ghost in
1001 | a white waistcoat, with a monstrous iron safe attached to its ankle, who
1002 | cried piteously at being unable to assist a wretched woman with an
1003 | infant, whom it saw below upon a doorstep. The misery with them all was
1004 | clearly, that they sought to interfere, for good, in human matters, and
1005 | had lost the power for ever.
1006 |
1007 | Whether these creatures faded into mist, or mist enshrouded them, he
1008 | could not tell. But they and their spirit voices faded together; and
1009 | the night became as it had been when he walked home.
1010 |
1011 | Scrooge closed the window, and examined the door by which the Ghost had
1012 | entered. It was double locked, as he had locked it with his own hands,
1013 | and the bolts were undisturbed. He tried to say 'Humbug!' but stopped at
1014 | the first syllable. And being, from the emotions he had undergone, or
1015 | the fatigues of the day, or his glimpse of the Invisible World, or the
1016 | dull conversation of the Ghost, or the lateness of the hour, much in
1017 | need of repose, went straight to bed without undressing, and fell asleep
1018 | upon the instant.
1019 |
1020 | [Illustration]
1021 |
1022 |
1023 | STAVE TWO
1024 |
1025 | [Illustration]
1026 |
1027 |
1028 |
1029 |
1030 | THE FIRST OF THE THREE SPIRITS
1031 |
1032 |
1033 | When Scrooge awoke it was so dark, that, looking out of bed, he could
1034 | scarcely distinguish the transparent window from the opaque walls of his
1035 | chamber. He was endeavouring to pierce the darkness with his ferret
1036 | eyes, when the chimes of a neighbouring church struck the four quarters.
1037 | So he listened for the hour.
1038 |
1039 | To his great astonishment, the heavy bell went on from six to seven, and
1040 | from seven to eight, and regularly up to twelve; then stopped. Twelve!
1041 | It was past two when he went to bed. The clock was wrong. An icicle must
1042 | have got into the works. Twelve!
1043 |
1044 | He touched the spring of his repeater, to correct this most preposterous
1045 | clock. Its rapid little pulse beat twelve, and stopped.
1046 |
1047 | 'Why, it isn't possible,' said Scrooge, 'that I can have slept through a
1048 | whole day and far into another night. It isn't possible that anything
1049 | has happened to the sun, and this is twelve at noon!'
1050 |
1051 | The idea being an alarming one, he scrambled out of bed, and groped his
1052 | way to the window. He was obliged to rub the frost off with the sleeve
1053 | of his dressing-gown before he could see anything; and could see very
1054 | little then. All he could make out was, that it was still very foggy and
1055 | extremely cold, and that there was no noise of people running to and
1056 | fro, and making a great stir, as there unquestionably would have been if
1057 | night had beaten off bright day, and taken possession of the world. This
1058 | was a great relief, because 'Three days after sight of this First of
1059 | Exchange pay to Mr. Ebenezer Scrooge or his order,' and so forth, would
1060 | have become a mere United States security if there were no days to count
1061 | by.
1062 |
1063 | Scrooge went to bed again, and thought, and thought, and thought it over
1064 | and over, and could make nothing of it. The more he thought, the more
1065 | perplexed he was; and, the more he endeavoured not to think, the more he
1066 | thought.
1067 |
1068 | Marley's Ghost bothered him exceedingly. Every time he resolved within
1069 | himself, after mature inquiry that it was all a dream, his mind flew
1070 | back again, like a strong spring released, to its first position, and
1071 | presented the same problem to be worked all through, 'Was it a dream or
1072 | not?'
1073 |
1074 | Scrooge lay in this state until the chime had gone three-quarters more,
1075 | when he remembered, on a sudden, that the Ghost had warned him of a
1076 | visitation when the bell tolled one. He resolved to lie awake until the
1077 | hour was passed; and, considering that he could no more go to sleep than
1078 | go to heaven, this was, perhaps, the wisest resolution in his power.
1079 |
1080 | The quarter was so long, that he was more than once convinced he must
1081 | have sunk into a doze unconsciously, and missed the clock. At length it
1082 | broke upon his listening ear.
1083 |
1084 | 'Ding, dong!'
1085 |
1086 | 'A quarter past,' said Scrooge, counting.
1087 |
1088 | 'Ding, dong!'
1089 |
1090 | 'Half past,' said Scrooge.
1091 |
1092 | 'Ding, dong!'
1093 |
1094 | 'A quarter to it.' said Scrooge.
1095 |
1096 | 'Ding, dong!'
1097 |
1098 | 'The hour itself,' said Scrooge triumphantly, 'and nothing else!'
1099 |
1100 | He spoke before the hour bell sounded, which it now did with a deep,
1101 | dull, hollow, melancholy ONE. Light flashed up in the room upon the
1102 | instant, and the curtains of his bed were drawn.
1103 |
1104 | The curtains of his bed were drawn aside, I tell you, by a hand. Not
1105 | the curtains at his feet, nor the curtains at his back, but those to
1106 | which his face was addressed. The curtains of his bed were drawn aside;
1107 | and Scrooge, starting up into a half-recumbent attitude, found himself
1108 | face to face with the unearthly visitor who drew them: as close to it as
1109 | I am now to you, and I am standing in the spirit at your elbow.
1110 |
1111 | It was a strange figure--like a child; yet not so like a child as like
1112 | an old man, viewed through some supernatural medium, which gave him the
1113 | appearance of having receded from the view, and being diminished to a
1114 | child's proportions. Its hair, which hung about its neck and down its
1115 | back, was white, as if with age; and yet the face had not a wrinkle in
1116 | it, and the tenderest bloom was on the skin. The arms were very long and
1117 | muscular; the hands the same, as if its hold were of uncommon strength.
1118 | Its legs and feet, most delicately formed, were, like those upper
1119 | members, bare. It wore a tunic of the purest white; and round its waist
1120 | was bound a lustrous belt, the sheen of which was beautiful. It held a
1121 | branch of fresh green holly in its hand; and, in singular contradiction
1122 | of that wintry emblem, had its dress trimmed with summer flowers. But
1123 | the strangest thing about it was, that from the crown of its head there
1124 | sprang a bright clear jet of light, by which all this was visible; and
1125 | which was doubtless the occasion of its using, in its duller moments, a
1126 | great extinguisher for a cap, which it now held under its arm.
1127 |
1128 | Even this, though, when Scrooge looked at it with increasing steadiness,
1129 | was _not_ its strangest quality. For, as its belt sparkled and
1130 | glittered, now in one part and now in another, and what was light one
1131 | instant at another time was dark, so the figure itself fluctuated in its
1132 | distinctness; being now a thing with one arm, now with one leg, now with
1133 | twenty legs, now a pair of legs without a head, now a head without a
1134 | body: of which dissolving parts no outline would be visible in the dense
1135 | gloom wherein they melted away. And, in the very wonder of this, it
1136 | would be itself again; distinct and clear as ever.
1137 |
1138 | 'Are you the Spirit, sir, whose coming was foretold to me?' asked
1139 | Scrooge.
1140 |
1141 | 'I am!'
1142 |
1143 | The voice was soft and gentle. Singularly low, as if, instead of being
1144 | so close behind him, it were at a distance.
1145 |
1146 | 'Who and what are you?' Scrooge demanded.
1147 |
1148 | 'I am the Ghost of Christmas Past.'
1149 |
1150 | 'Long Past?' inquired Scrooge, observant of its dwarfish stature.
1151 |
1152 | 'No. Your past.'
1153 |
1154 | Perhaps Scrooge could not have told anybody why, if anybody could have
1155 | asked him; but he had a special desire to see the Spirit in his cap,
1156 | and begged him to be covered.
1157 |
1158 | 'What!' exclaimed the Ghost, 'would you so soon put out, with worldly
1159 | hands, the light I give? Is it not enough that you are one of those
1160 | whose passions made this cap, and force me through whole trains of years
1161 | to wear it low upon my brow?'
1162 |
1163 | Scrooge reverently disclaimed all intention to offend or any knowledge
1164 | of having wilfully 'bonneted' the Spirit at any period of his life. He
1165 | then made bold to inquire what business brought him there.
1166 |
1167 | 'Your welfare!' said the Ghost.
1168 |
1169 | Scrooge expressed himself much obliged, but could not help thinking that
1170 | a night of unbroken rest would have been more conducive to that end. The
1171 | Spirit must have heard him thinking, for it said immediately--
1172 |
1173 | 'Your reclamation, then. Take heed!'
1174 |
1175 | It put out its strong hand as it spoke, and clasped him gently by the
1176 | arm.
1177 |
1178 | 'Rise! and walk with me!'
1179 |
1180 | It would have been in vain for Scrooge to plead that the weather and the
1181 | hour were not adapted to pedestrian purposes; that bed was warm, and the
1182 | thermometer a long way below freezing; that he was clad but lightly in
1183 | his slippers, dressing-gown, and nightcap; and that he had a cold upon
1184 | him at that time. The grasp, though gentle as a woman's hand, was not
1185 | to be resisted. He rose; but, finding that the Spirit made towards the
1186 | window, clasped its robe in supplication.
1187 |
1188 | 'I am a mortal,' Scrooge remonstrated, 'and liable to fall.'
1189 |
1190 | 'Bear but a touch of my hand _there_,' said the Spirit, laying it upon
1191 | his heart, 'and you shall be upheld in more than this!'
1192 |
1193 | As the words were spoken, they passed through the wall, and stood upon
1194 | an open country road, with fields on either hand. The city had entirely
1195 | vanished. Not a vestige of it was to be seen. The darkness and the mist
1196 | had vanished with it, for it was a clear, cold, winter day, with snow
1197 | upon the ground.
1198 |
1199 | 'Good Heaven!' said Scrooge, clasping his hands together, as he looked
1200 | about him. 'I was bred in this place. I was a boy here!'
1201 |
1202 | The Spirit gazed upon him mildly. Its gentle touch, though it had been
1203 | light and instantaneous, appeared still present to the old man's sense
1204 | of feeling. He was conscious of a thousand odours floating in the air,
1205 | each one connected with a thousand thoughts, and hopes, and joys, and
1206 | cares long, long forgotten!
1207 |
1208 | 'Your lip is trembling,' said the Ghost. 'And what is that upon your
1209 | cheek?'
1210 |
1211 | Scrooge muttered, with an unusual catching in his voice, that it was a
1212 | pimple; and begged the Ghost to lead him where he would.
1213 |
1214 | 'You recollect the way?' inquired the Spirit.
1215 |
1216 | 'Remember it!' cried Scrooge with fervour; 'I could walk it blindfold.'
1217 |
1218 | 'Strange to have forgotten it for so many years!' observed the Ghost.
1219 | 'Let us go on.'
1220 |
1221 | They walked along the road, Scrooge recognising every gate, and post,
1222 | and tree, until a little market-town appeared in the distance, with its
1223 | bridge, its church, and winding river. Some shaggy ponies now were seen
1224 | trotting towards them with boys upon their backs, who called to other
1225 | boys in country gigs and carts, driven by farmers. All these boys were
1226 | in great spirits, and shouted to each other, until the broad fields were
1227 | so full of merry music, that the crisp air laughed to hear it.
1228 |
1229 | 'These are but shadows of the things that have been,' said the Ghost.
1230 | 'They have no consciousness of us.'
1231 |
1232 | The jocund travellers came on; and as they came, Scrooge knew and named
1233 | them every one. Why was he rejoiced beyond all bounds to see them? Why
1234 | did his cold eye glisten, and his heart leap up as they went past? Why
1235 | was he filled with gladness when he heard them give each other Merry
1236 | Christmas, as they parted at cross-roads and by-ways for their several
1237 | homes? What was merry Christmas to Scrooge? Out upon merry Christmas!
1238 | What good had it ever done to him?
1239 |
1240 | 'The school is not quite deserted,' said the Ghost. 'A solitary child,
1241 | neglected by his friends, is left there still.'
1242 |
1243 | Scrooge said he knew it. And he sobbed.
1244 |
1245 | They left the high-road by a well-remembered lane and soon approached a
1246 | mansion of dull red brick, with a little weather-cock surmounted cupola
1247 | on the roof, and a bell hanging in it. It was a large house, but one of
1248 | broken fortunes; for the spacious offices were little used, their walls
1249 | were damp and mossy, their windows broken, and their gates decayed.
1250 | Fowls clucked and strutted in the stables; and the coach-houses and
1251 | sheds were overrun with grass. Nor was it more retentive of its ancient
1252 | state within; for, entering the dreary hall, and glancing through the
1253 | open doors of many rooms, they found them poorly furnished, cold, and
1254 | vast. There was an earthy savour in the air, a chilly bareness in the
1255 | place, which associated itself somehow with too much getting up by
1256 | candle light and not too much to eat.
1257 |
1258 | They went, the Ghost and Scrooge, across the hall, to a door at the back
1259 | of the house. It opened before them, and disclosed a long, bare,
1260 | melancholy room, made barer still by lines of plain deal forms and
1261 | desks. At one of these a lonely boy was reading near a feeble fire; and
1262 | Scrooge sat down upon a form, and wept to see his poor forgotten self as
1263 | he had used to be.
1264 |
1265 | Not a latent echo in the house, not a squeak and scuffle from the mice
1266 | behind the panelling, not a drip from the half-thawed waterspout in the
1267 | dull yard behind, not a sigh among the leafless boughs of one despondent
1268 | poplar, not the idle swinging of an empty storehouse door, no, not a
1269 | clicking in the fire, but fell upon the heart of Scrooge with softening
1270 | influence, and gave a freer passage to his tears.
1271 |
1272 | The Spirit touched him on the arm, and pointed to his younger self,
1273 | intent upon his reading. Suddenly a man in foreign garments, wonderfully
1274 | real and distinct to look at, stood outside the window, with an axe
1275 | stuck in his belt, and leading by the bridle an ass laden with wood.
1276 |
1277 | 'Why, it's Ali Baba!' Scrooge exclaimed in ecstasy. 'It's dear old
1278 | honest Ali Baba! Yes, yes, I know. One Christmas-time, when yonder
1279 | solitary child was left here all alone, he _did_ come, for the first
1280 | time, just like that. Poor boy! And Valentine,' said Scrooge, 'and his
1281 | wild brother, Orson; there they go! And what's his name, who was put
1282 | down in his drawers, asleep, at the gate of Damascus; don't you see him?
1283 | And the Sultan's Groom turned upside down by the Genii; there he is upon
1284 | his head! Serve him right! I'm glad of it. What business had he to be
1285 | married to the Princess?'
1286 |
1287 | To hear Scrooge expending all the earnestness of his nature on such
1288 | subjects, in a most extraordinary voice between laughing and crying; and
1289 | to see his heightened and excited face; would have been a surprise to
1290 | his business friends in the City, indeed.
1291 |
1292 | 'There's the Parrot!' cried Scrooge. 'Green body and yellow tail, with a
1293 | thing like a lettuce growing out of the top of his head; there he is!
1294 | Poor Robin Crusoe he called him, when he came home again after sailing
1295 | round the island. "Poor Robin Crusoe, where have you been, Robin
1296 | Crusoe?" The man thought he was dreaming, but he wasn't. It was the
1297 | Parrot, you know. There goes Friday, running for his life to the little
1298 | creek! Halloa! Hoop! Halloo!'
1299 |
1300 | Then, with a rapidity of transition very foreign to his usual character,
1301 | he said, in pity for his former self, 'Poor boy!' and cried again.
1302 |
1303 | 'I wish,' Scrooge muttered, putting his hand in his pocket, and looking
1304 | about him, after drying his eyes with his cuff; 'but it's too late now.'
1305 |
1306 | 'What is the matter?' asked the Spirit.
1307 |
1308 | 'Nothing,' said Scrooge. 'Nothing. There was a boy singing a Christmas
1309 | carol at my door last night. I should like to have given him something:
1310 | that's all.'
1311 |
1312 | The Ghost smiled thoughtfully, and waved its hand, saying as it did so,
1313 | 'Let us see another Christmas!'
1314 |
1315 | Scrooge's former self grew larger at the words, and the room became a
1316 | little darker and more dirty. The panels shrunk, the windows cracked;
1317 | fragments of plaster fell out of the ceiling, and the naked laths were
1318 | shown instead; but how all this was brought about Scrooge knew no more
1319 | than you do. He only knew that it was quite correct; that everything had
1320 | happened so; that there he was, alone again, when all the other boys had
1321 | gone home for the jolly holidays.
1322 |
1323 | He was not reading now, but walking up and down despairingly. Scrooge
1324 | looked at the Ghost, and, with a mournful shaking of his head, glanced
1325 | anxiously towards the door.
1326 |
1327 | It opened; and a little girl, much younger than the boy, came darting
1328 | in, and, putting her arms about his neck, and often kissing him,
1329 | addressed him as her 'dear, dear brother.'
1330 |
1331 | 'I have come to bring you home, dear brother!' said the child, clapping
1332 | her tiny hands, and bending down to laugh. 'To bring you home, home,
1333 | home!'
1334 |
1335 | 'Home, little Fan?' returned the boy.
1336 |
1337 | 'Yes!' said the child, brimful of glee. 'Home for good and all. Home for
1338 | ever and ever. Father is so much kinder than he used to be, that home's
1339 | like heaven! He spoke so gently to me one dear night when I was going to
1340 | bed, that I was not afraid to ask him once more if you might come home;
1341 | and he said Yes, you should; and sent me in a coach to bring you. And
1342 | you're to be a man!' said the child, opening her eyes; 'and are never to
1343 | come back here; but first we're to be together all the Christmas long,
1344 | and have the merriest time in all the world.'
1345 |
1346 | 'You are quite a woman, little Fan!' exclaimed the boy.
1347 |
1348 | She clapped her hands and laughed, and tried to touch his head; but,
1349 | being too little laughed again, and stood on tiptoe to embrace him. Then
1350 | she began to drag him, in her childish eagerness, towards the door; and
1351 | he, nothing loath to go, accompanied her.
1352 |
1353 | A terrible voice in the hall cried, 'Bring down Master Scrooge's box,
1354 | there!' and in the hall appeared the schoolmaster himself, who glared on
1355 | Master Scrooge with a ferocious condescension, and threw him into a
1356 | dreadful state of mind by shaking hands with him. He then conveyed him
1357 | and his sister into the veriest old well of a shivering best parlour
1358 | that ever was seen, where the maps upon the wall, and the celestial and
1359 | terrestrial globes in the windows, were waxy with cold. Here he produced
1360 | a decanter of curiously light wine, and a block of curiously heavy cake,
1361 | and administered instalments of those dainties to the young people; at
1362 | the same time sending out a meagre servant to offer a glass of
1363 | 'something' to the postboy, who answered that he thanked the gentleman,
1364 | but, if it was the same tap as he had tasted before, he had rather not.
1365 | Master Scrooge's trunk being by this time tied on to the top of the
1366 | chaise, the children bade the schoolmaster good-bye right willingly;
1367 | and, getting into it, drove gaily down the garden sweep; the quick
1368 | wheels dashing the hoar-frost and snow from off the dark leaves of the
1369 | evergreens like spray.
1370 |
1371 | [Illustration: HE PRODUCED A DECANTER OF CURIOUSLY LIGHT WINE, AND A
1372 | BLOCK OF CURIOUSLY HEAVY CAKE]
1373 |
1374 | 'Always a delicate creature, whom a breath might have withered,' said
1375 | the Ghost. 'But she had a large heart!'
1376 |
1377 | 'So she had,' cried Scrooge. 'You're right. I will not gainsay it,
1378 | Spirit. God forbid!'
1379 |
1380 | 'She died a woman,' said the Ghost, 'and had, as I think, children.'
1381 |
1382 | 'One child,' Scrooge returned.
1383 |
1384 | 'True,' said the Ghost. 'Your nephew!'
1385 |
1386 | Scrooge seemed uneasy in his mind, and answered briefly, 'Yes.'
1387 |
1388 | Although they had but that moment left the school behind them, they were
1389 | now in the busy thoroughfares of a city, where shadowy passengers passed
1390 | and re-passed; where shadowy carts and coaches battled for the way, and
1391 | all the strife and tumult of a real city were. It was made plain enough,
1392 | by the dressing of the shops, that here, too, it was Christmas-time
1393 | again; but it was evening, and the streets were lighted up.
1394 |
1395 | The Ghost stopped at a certain warehouse door, and asked Scrooge if he
1396 | knew it.
1397 |
1398 | 'Know it!' said Scrooge. 'Was I apprenticed here?'
1399 |
1400 | They went in. At sight of an old gentleman in a Welsh wig, sitting
1401 | behind such a high desk, that if he had been two inches taller, he must
1402 | have knocked his head against the ceiling, Scrooge cried in great
1403 | excitement--
1404 |
1405 | 'Why, it's old Fezziwig! Bless his heart, it's Fezziwig alive again!'
1406 |
1407 | Old Fezziwig laid down his pen, and looked up at the clock, which
1408 | pointed to the hour of seven. He rubbed his hands; adjusted his
1409 | capacious waistcoat; laughed all over himself, from his shoes to his
1410 | organ of benevolence; and called out, in a comfortable, oily, rich, fat,
1411 | jovial voice--
1412 |
1413 | 'Yo ho, there! Ebenezer! Dick!'
1414 |
1415 | Scrooge's former self, now grown a young man, came briskly in,
1416 | accompanied by his fellow-'prentice.
1417 |
1418 | 'Dick Wilkins, to be sure!' said Scrooge to the Ghost. 'Bless me, yes.
1419 | There he is. He was very much attached to me, was Dick. Poor Dick! Dear,
1420 | dear!'
1421 |
1422 | 'Yo ho, my boys!' said Fezziwig. 'No more work to-night. Christmas Eve,
1423 | Dick. Christmas, Ebenezer! Let's have the shutters up,' cried old
1424 | Fezziwig, with a sharp clap of his hands, 'before a man can say Jack
1425 | Robinson!'
1426 |
1427 | You wouldn't believe how those two fellows went at it! They charged into
1428 | the street with the shutters--one, two, three--had 'em up in their
1429 | places--four, five, six--barred 'em and pinned 'em--seven, eight,
1430 | nine--and came back before you could have got to twelve, panting like
1431 | racehorses.
1432 |
1433 | 'Hilli-ho!' cried old Fezziwig, skipping down from the high desk with
1434 | wonderful agility. 'Clear away, my lads, and let's have lots of room
1435 | here! Hilli-ho, Dick! Chirrup, Ebenezer!'
1436 |
1437 | Clear away! There was nothing they wouldn't have cleared away, or
1438 | couldn't have cleared away, with old Fezziwig looking on. It was done in
1439 | a minute. Every movable was packed off, as if it were dismissed from
1440 | public life for evermore; the floor was swept and watered, the lamps
1441 | were trimmed, fuel was heaped upon the fire; and the warehouse was as
1442 | snug, and warm, and dry, and bright a ball-room as you would desire to
1443 | see upon a winter's night.
1444 |
1445 | In came a fiddler with a music-book, and went up to the lofty desk, and
1446 | made an orchestra of it, and tuned like fifty stomach-aches. In came
1447 | Mrs. Fezziwig, one vast substantial smile. In came the three Miss
1448 | Fezziwigs, beaming and lovable. In came the six young followers whose
1449 | hearts they broke. In came all the young men and women employed in the
1450 | business. In came the housemaid, with her cousin the baker. In came the
1451 | cook with her brother's particular friend the milkman. In came the boy
1452 | from over the way, who was suspected of not having board enough from his
1453 | master; trying to hide himself behind the girl from next door but one,
1454 | who was proved to have had her ears pulled by her mistress. In they all
1455 | came, one after another; some shyly, some boldly, some gracefully, some
1456 | awkwardly, some pushing, some pulling; in they all came, any how and
1457 | every how. Away they all went, twenty couple at once; hands half round
1458 | and back again the other way; down the middle and up again; round and
1459 | round in various stages of affectionate grouping; old top couple always
1460 | turning up in the wrong place; new top couple starting off again as soon
1461 | as they got there; all top couples at last, and not a bottom one to help
1462 | them! When this result was brought about, old Fezziwig, clapping his
1463 | hands to stop the dance, cried out, 'Well done!' and the fiddler plunged
1464 | his hot face into a pot of porter, especially provided for that purpose.
1465 | But, scorning rest upon his reappearance, he instantly began again,
1466 | though there were no dancers yet, as if the other fiddler had been
1467 | carried home, exhausted, on a shutter, and he were a bran-new man
1468 | resolved to beat him out of sight, or perish.
1469 |
1470 | [Illustration: _Then old Fezziwig stood out to dance with Mrs.
1471 | Fezziwig_]
1472 |
1473 | There were more dances, and there were forfeits, and more dances, and
1474 | there was cake, and there was negus, and there was a great piece of Cold
1475 | Roast, and there was a great piece of Cold Boiled, and there were
1476 | mince-pies, and plenty of beer. But the great effect of the evening came
1477 | after the Roast and Boiled, when the fiddler (an artful dog, mind! The
1478 | sort of man who knew his business better than you or I could have told
1479 | it him!) struck up 'Sir Roger de Coverley.' Then old Fezziwig stood
1480 | out to dance with Mrs. Fezziwig. Top couple, too; with a good stiff
1481 | piece of work cut out for them; three or four and twenty pair of
1482 | partners; people who were not to be trifled with; people who would
1483 | dance, and had no notion of walking.
1484 |
1485 | But if they had been twice as many--ah! four times--old Fezziwig would
1486 | have been a match for them, and so would Mrs. Fezziwig. As to _her_, she
1487 | was worthy to be his partner in every sense of the term. If that's not
1488 | high praise, tell me higher, and I'll use it. A positive light appeared
1489 | to issue from Fezziwig's calves. They shone in every part of the dance
1490 | like moons. You couldn't have predicted, at any given time, what would
1491 | become of them next. And when old Fezziwig and Mrs. Fezziwig had gone
1492 | all through the dance; advance and retire, both hands to your partner,
1493 | bow and curtsy, cork-screw, thread-the-needle, and back again to your
1494 | place: Fezziwig 'cut'--cut so deftly, that he appeared to wink with his
1495 | legs, and came upon his feet again without a stagger.
1496 |
1497 | When the clock struck eleven, this domestic ball broke up. Mr. and Mrs.
1498 | Fezziwig took their stations, one on either side the door, and, shaking
1499 | hands with every person individually as he or she went out, wished him
1500 | or her a Merry Christmas. When everybody had retired but the two
1501 | 'prentices, they did the same to them; and thus the cheerful voices died
1502 | away, and the lads were left to their beds; which were under a counter
1503 | in the back-shop.
1504 |
1505 | During the whole of this time Scrooge had acted like a man out of his
1506 | wits. His heart and soul were in the scene, and with his former self. He
1507 | corroborated everything, remembered everything, enjoyed everything, and
1508 | underwent the strangest agitation. It was not until now, when the bright
1509 | faces of his former self and Dick were turned from them, that he
1510 | remembered the Ghost, and became conscious that it was looking full upon
1511 | him, while the light upon its head burnt very clear.
1512 |
1513 | 'A small matter,' said the Ghost, 'to make these silly folks so full of
1514 | gratitude.'
1515 |
1516 | 'Small!' echoed Scrooge.
1517 |
1518 | The Spirit signed to him to listen to the two apprentices, who were
1519 | pouring out their hearts in praise of Fezziwig; and when he had done so,
1520 | said:
1521 |
1522 | 'Why! Is it not? He has spent but a few pounds of your mortal money:
1523 | three or four, perhaps. Is that so much that he deserves this praise?'
1524 |
1525 | 'It isn't that,' said Scrooge, heated by the remark, and speaking
1526 | unconsciously like his former, not his latter self. 'It isn't that,
1527 | Spirit. He has the power to render us happy or unhappy; to make our
1528 | service light or burdensome; a pleasure or a toil. Say that his power
1529 | lies in words and looks; in things so slight and insignificant that it
1530 | is impossible to add and count 'em up: what then? The happiness he gives
1531 | is quite as great as if it cost a fortune.'
1532 |
1533 | He felt the Spirit's glance, and stopped.
1534 |
1535 | 'What is the matter?' asked the Ghost.
1536 |
1537 | 'Nothing particular,' said Scrooge.
1538 |
1539 | 'Something, I think?' the Ghost insisted.
1540 |
1541 | 'No,' said Scrooge, 'no. I should like to be able to say a word or two
1542 | to my clerk just now. That's all.'
1543 |
1544 | His former self turned down the lamps as he gave utterance to the wish;
1545 | and Scrooge and the Ghost again stood side by side in the open air.
1546 |
1547 | 'My time grows short,' observed the Spirit. 'Quick!'
1548 |
1549 | This was not addressed to Scrooge, or to any one whom he could see, but
1550 | it produced an immediate effect. For again Scrooge saw himself. He was
1551 | older now; a man in the prime of life. His face had not the harsh and
1552 | rigid lines of later years; but it had begun to wear the signs of care
1553 | and avarice. There was an eager, greedy, restless motion in the eye,
1554 | which showed the passion that had taken root, and where the shadow of
1555 | the growing tree would fall.
1556 |
1557 | He was not alone, but sat by the side of a fair young girl in a mourning
1558 | dress: in whose eyes there were tears, which sparkled in the light that
1559 | shone out of the Ghost of Christmas Past.
1560 |
1561 | 'It matters little,' she said softly. 'To you, very little. Another idol
1562 | has displaced me; and, if it can cheer and comfort you in time to come
1563 | as I would have tried to do, I have no just cause to grieve.'
1564 |
1565 | 'What Idol has displaced you?' he rejoined.
1566 |
1567 | 'A golden one.'
1568 |
1569 | 'This is the even-handed dealing of the world!' he said. 'There is
1570 | nothing on which it is so hard as poverty; and there is nothing it
1571 | professes to condemn with such severity as the pursuit of wealth!'
1572 |
1573 | 'You fear the world too much,' she answered gently. 'All your other
1574 | hopes have merged into the hope of being beyond the chance of its sordid
1575 | reproach. I have seen your nobler aspirations fall off one by one, until
1576 | the master passion, Gain, engrosses you. Have I not?'
1577 |
1578 | 'What then?' he retorted. 'Even if I have grown so much wiser, what
1579 | then? I am not changed towards you.'
1580 |
1581 | She shook her head.
1582 |
1583 | 'Am I?'
1584 |
1585 | 'Our contract is an old one. It was made when we were both poor, and
1586 | content to be so, until, in good season, we could improve our worldly
1587 | fortune by our patient industry. You _are_ changed. When it was made you
1588 | were another man.'
1589 |
1590 | 'I was a boy,' he said impatiently.
1591 |
1592 | 'Your own feeling tells you that you were not what you are,' she
1593 | returned. 'I am. That which promised happiness when we were one in heart
1594 | is fraught with misery now that we are two. How often and how keenly I
1595 | have thought of this I will not say. It is enough that I _have_ thought
1596 | of it, and can release you.'
1597 |
1598 | 'Have I ever sought release?'
1599 |
1600 | 'In words. No. Never.'
1601 |
1602 | 'In what, then?'
1603 |
1604 | 'In a changed nature; in an altered spirit; in another atmosphere of
1605 | life; another Hope as its great end. In everything that made my love of
1606 | any worth or value in your sight. If this had never been between us,'
1607 | said the girl, looking mildly, but with steadiness, upon him; 'tell me,
1608 | would you seek me out and try to win me now? Ah, no!'
1609 |
1610 | He seemed to yield to the justice of this supposition in spite of
1611 | himself. But he said, with a struggle, 'You think not.'
1612 |
1613 | 'I would gladly think otherwise if I could,' she answered. 'Heaven
1614 | knows! When _I_ have learned a Truth like this, I know how strong and
1615 | irresistible it must be. But if you were free to-day, to-morrow,
1616 | yesterday, can even I believe that you would choose a dowerless
1617 | girl--you who, in your very confidence with her, weigh everything by
1618 | Gain: or, choosing her, if for a moment you were false enough to your
1619 | one guiding principle to do so, do I not know that your repentance and
1620 | regret would surely follow? I do; and I release you. With a full heart,
1621 | for the love of him you once were.'
1622 |
1623 | [Illustration: SHE LEFT HIM, AND THEY PARTED]
1624 |
1625 | He was about to speak; but, with her head turned from him, she resumed:
1626 |
1627 | 'You may--the memory of what is past half makes me hope you will--have
1628 | pain in this. A very, very brief time, and you will dismiss the
1629 | recollection of it gladly, as an unprofitable dream, from which it
1630 | happened well that you awoke. May you be happy in the life you have
1631 | chosen!'
1632 |
1633 | She left him, and they parted.
1634 |
1635 |
1636 |
--------------------------------------------------------------------------------
/data/create_final_community_reports.parquet:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/M1n9X/GraphRAG_Lite/3c06782772027dbfba0fedc2c028211781100287/data/create_final_community_reports.parquet
--------------------------------------------------------------------------------
/data/create_final_entities.parquet:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/M1n9X/GraphRAG_Lite/3c06782772027dbfba0fedc2c028211781100287/data/create_final_entities.parquet
--------------------------------------------------------------------------------
/data/create_final_nodes.parquet:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/M1n9X/GraphRAG_Lite/3c06782772027dbfba0fedc2c028211781100287/data/create_final_nodes.parquet
--------------------------------------------------------------------------------
/data/create_summarized_entities.parquet:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/M1n9X/GraphRAG_Lite/3c06782772027dbfba0fedc2c028211781100287/data/create_summarized_entities.parquet
--------------------------------------------------------------------------------
/graphrag_lite/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/M1n9X/GraphRAG_Lite/3c06782772027dbfba0fedc2c028211781100287/graphrag_lite/__init__.py
--------------------------------------------------------------------------------
/graphrag_lite/cluster_graph.py:
--------------------------------------------------------------------------------
1 | # Code modified from Microsoft/GraphRAG project
2 |
3 | """A module containing cluster_graph, apply_clustering, and run_layout methods definition."""
4 | import asyncio
5 | import logging
6 | from enum import Enum
7 | from random import Random
8 | from typing import Any, Optional, cast
9 |
10 | import networkx as nx
11 | import pandas as pd
12 | from datashaper import TableContainer, VerbCallbacks, VerbInput, progress_iterable
13 | from graphrag.index import run_pipeline
14 | from graphrag.index.config import PipelineWorkflowReference
15 | from graphrag.index.graph.utils import stable_largest_connected_component
16 | from graphrag.index.utils import gen_uuid, load_graph
17 | from graspologic.partition import hierarchical_leiden
18 |
19 | log = logging.getLogger(__name__)
20 | logging.basicConfig(level=logging.INFO) # Basic logging configuration
21 | Communities = list[tuple[int, str, list[str]]]
22 |
23 |
24 | def run_leiden(
25 | graph: nx.Graph, args: dict[str, Any]
26 | ) -> dict[int, dict[str, list[str]]]:
27 | """Run method definition."""
28 | max_cluster_size = args.get("max_cluster_size", 10)
29 | use_lcc = args.get("use_lcc", True)
30 | if args.get("verbose", False):
31 | log.info(
32 | "Running leiden with max_cluster_size=%s, lcc=%s", max_cluster_size, use_lcc
33 | )
34 |
35 | node_id_to_community_map = _compute_leiden_communities(
36 | graph=graph,
37 | max_cluster_size=max_cluster_size,
38 | use_lcc=use_lcc,
39 | seed=args.get("seed", 0xDEADBEEF),
40 | )
41 | levels = args.get("levels") or sorted(node_id_to_community_map.keys())
42 |
43 | results_by_level: dict[int, dict[str, list[str]]] = {}
44 | for level in levels:
45 | result = {}
46 | results_by_level[level] = result
47 | for node_id, raw_community_id in node_id_to_community_map[level].items():
48 | community_id = str(raw_community_id)
49 | result.setdefault(community_id, []).append(node_id)
50 |
51 | return results_by_level
52 |
53 |
54 | def _compute_leiden_communities(
55 | graph: nx.Graph | nx.DiGraph,
56 | max_cluster_size: int,
57 | use_lcc: bool,
58 | seed: Optional[int] = 0xDEADBEEF,
59 | ) -> dict[int, dict[str, int]]:
60 | """Return Leiden root communities."""
61 | if use_lcc:
62 | graph = stable_largest_connected_component(graph)
63 |
64 | community_mapping = hierarchical_leiden(
65 | graph, max_cluster_size=max_cluster_size, random_seed=seed
66 | )
67 | results: dict[int, dict[str, int]] = {}
68 | for partition in community_mapping:
69 | level = partition.level
70 | results.setdefault(level, {})[partition.node] = partition.cluster
71 |
72 | return results
73 |
74 |
75 | def cluster_graph(
76 | input: VerbInput,
77 | callbacks: VerbCallbacks,
78 | strategy: dict[str, Any],
79 | column: str,
80 | to: str,
81 | level_to: Optional[str] = None,
82 | **_kwargs,
83 | ) -> TableContainer:
84 | """
85 | Apply a hierarchical clustering algorithm to a graph. The graph is expected to be in graphml format. The verb outputs a new column containing the clustered graph, and a new column containing the level of the graph.
86 | """
87 | output_df = cast(pd.DataFrame, input.get_input())
88 | var = output_df[column].apply(lambda graph: run_layout(strategy, graph))
89 |
90 | level_to = level_to or f"{to}_level"
91 | output_df[[to, level_to]] = [None, None]
92 | graph_level_pairs_column = []
93 |
94 | for _, row in progress_iterable(
95 | output_df.iterrows(), callbacks.progress, len(output_df)
96 | ):
97 | levels = list({level for level, _, _ in row[var]})
98 | row[level_to] = levels
99 | graph_level_pairs = [
100 | (
101 | level,
102 | "\n".join(
103 | nx.generate_graphml(
104 | apply_clustering(
105 | cast(str, row[column]), cast(Communities, row[var]), level
106 | )
107 | )
108 | ),
109 | )
110 | for level in levels
111 | ]
112 | graph_level_pairs_column.append(graph_level_pairs)
113 |
114 | output_df[to] = graph_level_pairs_column
115 | output_df = output_df.explode(to, ignore_index=True)
116 | output_df[[level_to, to]] = pd.DataFrame(
117 | output_df[to].tolist(), index=output_df.index
118 | )
119 | output_df.drop(columns=[var], inplace=True)
120 |
121 | return TableContainer(table=output_df)
122 |
123 |
124 | def apply_clustering(
125 | graphml: str, communities: Communities, level=0, seed=0xF001
126 | ) -> nx.Graph:
127 | """Apply clustering to a graphml string."""
128 | random = Random(seed)
129 | graph = nx.parse_graphml(graphml)
130 | for community_level, community_id, nodes in communities:
131 | if level == community_level:
132 | for node in nodes:
133 | graph.nodes[node]["cluster"] = community_id
134 | graph.nodes[node]["level"] = level
135 |
136 | for node in graph.nodes:
137 | graph.nodes[node]["degree"] = int(graph.degree(node))
138 | graph.nodes[node]["human_readable_id"] = node
139 | graph.nodes[node]["id"] = str(gen_uuid(random))
140 |
141 | for index, edge in enumerate(graph.edges()):
142 | graph.edges[edge]["id"] = str(gen_uuid(random))
143 | graph.edges[edge]["human_readable_id"] = index
144 | graph.edges[edge]["level"] = level
145 |
146 | return graph
147 |
148 |
149 | class GraphCommunityStrategyType(str, Enum):
150 | """GraphCommunityStrategyType class definition."""
151 |
152 | leiden = "leiden"
153 |
154 | def __repr__(self):
155 | """Get a string representation."""
156 | return f'"{self.value}"'
157 |
158 |
159 | def run_layout(
160 | strategy: dict[str, Any], graphml_or_graph: str | nx.Graph
161 | ) -> Communities:
162 | """Run layout method definition."""
163 | graph = load_graph(graphml_or_graph)
164 | if len(graph.nodes) == 0:
165 | log.warning("Graph has no nodes")
166 | return []
167 |
168 | clusters: dict[int, dict[str, list[str]]] = {}
169 | strategy_type = strategy.get("type", GraphCommunityStrategyType.leiden)
170 |
171 | if strategy_type == GraphCommunityStrategyType.leiden:
172 | clusters = run_leiden(graph, strategy)
173 | else:
174 | raise ValueError(f"Unknown clustering strategy {strategy_type}")
175 |
176 | results: Communities = []
177 | for level, cluster_dict in clusters.items():
178 | for cluster_id, nodes in cluster_dict.items():
179 | results.append((level, cluster_id, nodes))
180 |
181 | return results
182 |
183 |
184 | dataset = pd.read_parquet("data/create_summarized_entities.parquet")
185 |
186 |
187 | async def run_python():
188 | """Run a pipeline using the python API"""
189 | workflows: list[PipelineWorkflowReference] = [
190 | PipelineWorkflowReference(
191 | steps=[
192 | {
193 | "verb": "cluster_graph",
194 | "args": {
195 | "strategy": {"type": "leiden"},
196 | "column": "entity_graph",
197 | "to": "clustered_graph",
198 | "level_to": "level",
199 | },
200 | },
201 | {
202 | "verb": "select",
203 | "args": {
204 | "columns": (["level", "clustered_graph"]),
205 | },
206 | },
207 | ]
208 | ),
209 | ]
210 |
211 | tables = []
212 | async for table in run_pipeline(dataset=dataset, workflows=workflows):
213 | tables.append(table)
214 | pipeline_result = tables[-1]
215 |
216 | if pipeline_result.result is not None:
217 | print(pipeline_result.result)
218 | pipeline_result.result.to_parquet("data/create_base_entity_graph.parquet")
219 | else:
220 | print("No results!")
221 |
222 |
223 | if __name__ == "__main__":
224 | asyncio.run(run_python())
225 |
--------------------------------------------------------------------------------
/graphrag_lite/global_search.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {},
7 | "outputs": [],
8 | "source": [
9 | "# Code modified from Microsoft/GraphRAG project"
10 | ]
11 | },
12 | {
13 | "cell_type": "code",
14 | "execution_count": null,
15 | "metadata": {},
16 | "outputs": [],
17 | "source": [
18 | "api_key = \"sk-\"\n",
19 | "llm_model = \"gpt-4o\""
20 | ]
21 | },
22 | {
23 | "cell_type": "code",
24 | "execution_count": 1,
25 | "metadata": {},
26 | "outputs": [],
27 | "source": [
28 | "import pandas as pd\n",
29 | "import tiktoken\n",
30 | "\n",
31 | "from graphrag.query.indexer_adapters import read_indexer_entities, read_indexer_reports\n",
32 | "from graphrag.query.llm.oai.chat_openai import ChatOpenAI\n",
33 | "from graphrag.query.llm.oai.typing import OpenaiApiType\n",
34 | "from graphrag.query.structured_search.global_search.community_context import (\n",
35 | " GlobalCommunityContext,\n",
36 | ")\n",
37 | "from graphrag.query.structured_search.global_search.search import GlobalSearch"
38 | ]
39 | },
40 | {
41 | "cell_type": "markdown",
42 | "metadata": {},
43 | "source": [
44 | "### LLM setup"
45 | ]
46 | },
47 | {
48 | "cell_type": "code",
49 | "execution_count": 16,
50 | "metadata": {},
51 | "outputs": [],
52 | "source": [
53 | "llm = ChatOpenAI(\n",
54 | " api_key=api_key,\n",
55 | " model=llm_model,\n",
56 | " api_type=OpenaiApiType.OpenAI, # OpenaiApiType.OpenAI or OpenaiApiType.AzureOpenAI\n",
57 | " max_retries=20,\n",
58 | ")\n",
59 | "\n",
60 | "token_encoder = tiktoken.get_encoding(\"cl100k_base\")"
61 | ]
62 | },
63 | {
64 | "cell_type": "code",
65 | "execution_count": 14,
66 | "metadata": {},
67 | "outputs": [
68 | {
69 | "name": "stdout",
70 | "output_type": "stream",
71 | "text": [
72 | "Report records: 31\n"
73 | ]
74 | },
75 | {
76 | "data": {
77 | "text/html": [
78 | "
\n",
79 | "\n",
92 | "
\n",
93 | " \n",
94 | " \n",
95 | " | \n",
96 | " community | \n",
97 | " full_content | \n",
98 | " level | \n",
99 | " rank | \n",
100 | " title | \n",
101 | " rank_explanation | \n",
102 | " summary | \n",
103 | " findings | \n",
104 | " full_content_json | \n",
105 | " id | \n",
106 | "
\n",
107 | " \n",
108 | " \n",
109 | " \n",
110 | " 0 | \n",
111 | " 30 | \n",
112 | " # Scrooge and His Community\\n\\nThe community c... | \n",
113 | " 2 | \n",
114 | " 8.5 | \n",
115 | " Scrooge and His Community | \n",
116 | " The impact severity rating is high due to the ... | \n",
117 | " The community centers around Scrooge, a comple... | \n",
118 | " [{'explanation': 'Scrooge is the central figur... | \n",
119 | " {\\n \"title\": \"Scrooge and His Community\",\\n... | \n",
120 | " 4bf0a5b9-d843-44bd-923d-12856108186a | \n",
121 | "
\n",
122 | " \n",
123 | " 1 | \n",
124 | " 31 | \n",
125 | " # Scrooge's Journey with The Spirit\\n\\nThe com... | \n",
126 | " 2 | \n",
127 | " 7.5 | \n",
128 | " Scrooge's Journey with The Spirit | \n",
129 | " The impact severity rating is high due to the ... | \n",
130 | " The community revolves around Scrooge and his ... | \n",
131 | " [{'explanation': 'The Spirit is a supernatural... | \n",
132 | " {\\n \"title\": \"Scrooge's Journey with The Sp... | \n",
133 | " b6e474fd-a19a-4f5b-b1c4-022a4e3fac7a | \n",
134 | "
\n",
135 | " \n",
136 | " 2 | \n",
137 | " 16 | \n",
138 | " # A Christmas Carol and Its Contributors\\n\\nTh... | \n",
139 | " 1 | \n",
140 | " 7.5 | \n",
141 | " A Christmas Carol and Its Contributors | \n",
142 | " The impact severity rating is high due to the ... | \n",
143 | " The community revolves around the novella 'A C... | \n",
144 | " [{'explanation': 'Charles Dickens is the autho... | \n",
145 | " {\\n \"title\": \"A Christmas Carol and Its Con... | \n",
146 | " b632ef4f-938c-4e95-a07f-2b10dabf2716 | \n",
147 | "
\n",
148 | " \n",
149 | " 3 | \n",
150 | " 17 | \n",
151 | " # J. B. Lippincott Company and A Christmas Car... | \n",
152 | " 1 | \n",
153 | " 6.5 | \n",
154 | " J. B. Lippincott Company and A Christmas Carol | \n",
155 | " The impact severity rating is moderately high ... | \n",
156 | " The community centers around J. B. Lippincott ... | \n",
157 | " [{'explanation': 'J. B. Lippincott Company is ... | \n",
158 | " {\\n \"title\": \"J. B. Lippincott Company and ... | \n",
159 | " ed7baee5-b820-43fb-a1d8-e5da5ad3f3d4 | \n",
160 | "
\n",
161 | " \n",
162 | " 4 | \n",
163 | " 18 | \n",
164 | " # Project Gutenberg and A Christmas Carol\\n\\nT... | \n",
165 | " 1 | \n",
166 | " 3.0 | \n",
167 | " Project Gutenberg and A Christmas Carol | \n",
168 | " The impact severity rating is low due to the p... | \n",
169 | " The community revolves around Project Gutenber... | \n",
170 | " [{'explanation': 'Project Gutenberg is a signi... | \n",
171 | " {\\n \"title\": \"Project Gutenberg and A Chris... | \n",
172 | " 4289cf6e-0e88-4c6f-90c2-05e6c8c22f95 | \n",
173 | "
\n",
174 | " \n",
175 | "
\n",
176 | "
"
177 | ],
178 | "text/plain": [
179 | " community full_content level rank \\\n",
180 | "0 30 # Scrooge and His Community\\n\\nThe community c... 2 8.5 \n",
181 | "1 31 # Scrooge's Journey with The Spirit\\n\\nThe com... 2 7.5 \n",
182 | "2 16 # A Christmas Carol and Its Contributors\\n\\nTh... 1 7.5 \n",
183 | "3 17 # J. B. Lippincott Company and A Christmas Car... 1 6.5 \n",
184 | "4 18 # Project Gutenberg and A Christmas Carol\\n\\nT... 1 3.0 \n",
185 | "\n",
186 | " title \\\n",
187 | "0 Scrooge and His Community \n",
188 | "1 Scrooge's Journey with The Spirit \n",
189 | "2 A Christmas Carol and Its Contributors \n",
190 | "3 J. B. Lippincott Company and A Christmas Carol \n",
191 | "4 Project Gutenberg and A Christmas Carol \n",
192 | "\n",
193 | " rank_explanation \\\n",
194 | "0 The impact severity rating is high due to the ... \n",
195 | "1 The impact severity rating is high due to the ... \n",
196 | "2 The impact severity rating is high due to the ... \n",
197 | "3 The impact severity rating is moderately high ... \n",
198 | "4 The impact severity rating is low due to the p... \n",
199 | "\n",
200 | " summary \\\n",
201 | "0 The community centers around Scrooge, a comple... \n",
202 | "1 The community revolves around Scrooge and his ... \n",
203 | "2 The community revolves around the novella 'A C... \n",
204 | "3 The community centers around J. B. Lippincott ... \n",
205 | "4 The community revolves around Project Gutenber... \n",
206 | "\n",
207 | " findings \\\n",
208 | "0 [{'explanation': 'Scrooge is the central figur... \n",
209 | "1 [{'explanation': 'The Spirit is a supernatural... \n",
210 | "2 [{'explanation': 'Charles Dickens is the autho... \n",
211 | "3 [{'explanation': 'J. B. Lippincott Company is ... \n",
212 | "4 [{'explanation': 'Project Gutenberg is a signi... \n",
213 | "\n",
214 | " full_content_json \\\n",
215 | "0 {\\n \"title\": \"Scrooge and His Community\",\\n... \n",
216 | "1 {\\n \"title\": \"Scrooge's Journey with The Sp... \n",
217 | "2 {\\n \"title\": \"A Christmas Carol and Its Con... \n",
218 | "3 {\\n \"title\": \"J. B. Lippincott Company and ... \n",
219 | "4 {\\n \"title\": \"Project Gutenberg and A Chris... \n",
220 | "\n",
221 | " id \n",
222 | "0 4bf0a5b9-d843-44bd-923d-12856108186a \n",
223 | "1 b6e474fd-a19a-4f5b-b1c4-022a4e3fac7a \n",
224 | "2 b632ef4f-938c-4e95-a07f-2b10dabf2716 \n",
225 | "3 ed7baee5-b820-43fb-a1d8-e5da5ad3f3d4 \n",
226 | "4 4289cf6e-0e88-4c6f-90c2-05e6c8c22f95 "
227 | ]
228 | },
229 | "execution_count": 14,
230 | "metadata": {},
231 | "output_type": "execute_result"
232 | }
233 | ],
234 | "source": [
235 | "COMMUNITY_LEVEL = 2\n",
236 | "\n",
237 | "entity_df = pd.read_parquet(\"data/create_final_nodes.parquet\")\n",
238 | "report_df = pd.read_parquet(\"data/create_final_community_reports.parquet\")\n",
239 | "entity_embedding_df = pd.read_parquet(\"data/create_final_entities.parquet\")\n",
240 | "\n",
241 | "reports = read_indexer_reports(report_df, entity_df, COMMUNITY_LEVEL)\n",
242 | "entities = read_indexer_entities(entity_df, entity_embedding_df, COMMUNITY_LEVEL)\n",
243 | "print(f\"Report records: {len(report_df)}\")\n",
244 | "report_df.head()"
245 | ]
246 | },
247 | {
248 | "cell_type": "markdown",
249 | "metadata": {},
250 | "source": [
251 | "#### Build global context based on community reports"
252 | ]
253 | },
254 | {
255 | "cell_type": "code",
256 | "execution_count": 17,
257 | "metadata": {},
258 | "outputs": [],
259 | "source": [
260 | "context_builder = GlobalCommunityContext(\n",
261 | " community_reports=reports,\n",
262 | " entities=entities, # default to None if you don't want to use community weights for ranking\n",
263 | " token_encoder=token_encoder,\n",
264 | ")"
265 | ]
266 | },
267 | {
268 | "cell_type": "markdown",
269 | "metadata": {},
270 | "source": [
271 | "#### Perform global search"
272 | ]
273 | },
274 | {
275 | "cell_type": "code",
276 | "execution_count": 18,
277 | "metadata": {},
278 | "outputs": [],
279 | "source": [
280 | "context_builder_params = {\n",
281 | " \"use_community_summary\": False, # False means using full community reports. True means using community short summaries.\n",
282 | " \"shuffle_data\": True,\n",
283 | " \"include_community_rank\": True,\n",
284 | " \"min_community_rank\": 0,\n",
285 | " \"community_rank_name\": \"rank\",\n",
286 | " \"include_community_weight\": True,\n",
287 | " \"community_weight_name\": \"occurrence weight\",\n",
288 | " \"normalize_community_weight\": True,\n",
289 | " \"max_tokens\": 12_000, # change this based on the token limit you have on your model (if you are using a model with 8k limit, a good setting could be 5000)\n",
290 | " \"context_name\": \"Reports\",\n",
291 | "}\n",
292 | "\n",
293 | "map_llm_params = {\n",
294 | " \"max_tokens\": 1000,\n",
295 | " \"temperature\": 0.0,\n",
296 | " \"response_format\": {\"type\": \"json_object\"},\n",
297 | "}\n",
298 | "\n",
299 | "reduce_llm_params = {\n",
300 | " \"max_tokens\": 2000, # change this based on the token limit you have on your model (if you are using a model with 8k limit, a good setting could be 1000-1500)\n",
301 | " \"temperature\": 0.0,\n",
302 | "}"
303 | ]
304 | },
305 | {
306 | "cell_type": "code",
307 | "execution_count": 19,
308 | "metadata": {},
309 | "outputs": [],
310 | "source": [
311 | "search_engine = GlobalSearch(\n",
312 | " llm=llm,\n",
313 | " context_builder=context_builder,\n",
314 | " token_encoder=token_encoder,\n",
315 | " max_data_tokens=12_000, # change this based on the token limit you have on your model (if you are using a model with 8k limit, a good setting could be 5000)\n",
316 | " map_llm_params=map_llm_params,\n",
317 | " reduce_llm_params=reduce_llm_params,\n",
318 | " allow_general_knowledge=False, # set this to True will add instruction to encourage the LLM to incorporate general knowledge in the response, which may increase hallucinations, but could be useful in some use cases.\n",
319 | " json_mode=True, # set this to False if your LLM model does not support JSON mode.\n",
320 | " context_builder_params=context_builder_params,\n",
321 | " concurrent_coroutines=32,\n",
322 | " response_type=\"multiple paragraphs\", # free form text describing the response type and format, can be anything, e.g. prioritized list, single paragraph, multiple paragraphs, multiple-page report\n",
323 | ")"
324 | ]
325 | },
326 | {
327 | "cell_type": "code",
328 | "execution_count": 20,
329 | "metadata": {},
330 | "outputs": [
331 | {
332 | "name": "stdout",
333 | "output_type": "stream",
334 | "text": [
335 | "### Top Themes in the Story\n",
336 | "\n",
337 | "#### Redemption and Transformation\n",
338 | "The central theme of the story is the redemption and transformation of Ebenezer Scrooge. Initially depicted as a miserly and solitary figure, Scrooge undergoes a profound emotional and spiritual transformation. This change is catalyzed by his interactions with various supernatural figures, including the ghost of his former business partner Jacob Marley and the Ghosts of Christmas Past, Present, and Yet to Come. These encounters prompt Scrooge to reflect on his life and ultimately embrace kindness and community [Data: Reports (19, 27, 31, 30, 12, 6, +more)].\n",
339 | "\n",
340 | "#### Impact of Supernatural Encounters\n",
341 | "The supernatural elements in the story play a pivotal role in Scrooge's transformation. The ghostly visitations serve as catalysts for his reflection and change. Marley's ghost and the three spirits guide Scrooge through scenes of his past, present, and potential future, highlighting the consequences of his actions and urging him to reconsider his values [Data: Reports (30, 8, 6, 19, 31)].\n",
342 | "\n",
343 | "#### Kindness and Generosity\n",
344 | "The theme of kindness and generosity is highlighted through characters like Fezziwig and the Cratchit family. Fezziwig is remembered fondly for his ability to make his apprentices happy through small acts of kindness, while the Cratchit family celebrates Christmas Eve with joy despite their modest means. These examples contrast sharply with Scrooge's initial focus on material wealth and underscore the positive impact of kindness and generosity on individuals and communities [Data: Reports (23, 2, 30, 6)].\n",
345 | "\n",
346 | "#### Consequences of Greed and Materialism\n",
347 | "Scrooge's initial focus on money and material wealth is a significant theme in the story. The Counting-House, where Scrooge and Marley conducted their business, symbolizes this focus. The ghostly visitations reveal the negative impact of such values on Scrooge's life and relationships, ultimately leading him to understand the emptiness of a life driven by greed [Data: Reports (27, 21)].\n",
348 | "\n",
349 | "#### Family and Human Connection\n",
350 | "The importance of family and human connection is another key theme. Scrooge's relationships with his nephew Fred and the Cratchit family highlight the value of familial bonds and social connections. Fred's invitation to Scrooge for Christmas dinner and the close-knit nature of the Cratchit family serve as reminders of the joy and fulfillment that come from being part of a loving community [Data: Reports (27, 2, 30, 25)].\n",
351 | "\n",
352 | "#### Reflection and Self-Awareness\n",
353 | "Scrooge's journey with the Ghosts emphasizes the theme of reflection and self-awareness. By guiding him through scenes of his past, present, and potential future, the Ghosts prompt Scrooge to reconsider his values and actions. This reflection is crucial to his eventual transformation and redemption [Data: Reports (19, 31)].\n",
354 | "\n",
355 | "### Conclusion\n",
356 | "The story masterfully weaves together these themes to illustrate the profound impact of personal transformation, the importance of kindness and generosity, and the value of family and community. Through Scrooge's journey, the narrative underscores the potential for redemption and the enduring power of human connection.\n"
357 | ]
358 | }
359 | ],
360 | "source": [
361 | "result = await search_engine.asearch(\n",
362 | " \"What are the top themes in this story?\"\n",
363 | ")\n",
364 | "\n",
365 | "print(result.response)"
366 | ]
367 | },
368 | {
369 | "cell_type": "code",
370 | "execution_count": 21,
371 | "metadata": {},
372 | "outputs": [
373 | {
374 | "data": {
375 | "text/html": [
376 | "\n",
377 | "\n",
390 | "
\n",
391 | " \n",
392 | " \n",
393 | " | \n",
394 | " id | \n",
395 | " title | \n",
396 | " occurrence weight | \n",
397 | " content | \n",
398 | " rank | \n",
399 | "
\n",
400 | " \n",
401 | " \n",
402 | " \n",
403 | " 0 | \n",
404 | " 19 | \n",
405 | " Scrooge and the Ghost of Jacob Marley | \n",
406 | " 0.260274 | \n",
407 | " # Scrooge and the Ghost of Jacob Marley\\n\\nThe... | \n",
408 | " 8.5 | \n",
409 | "
\n",
410 | " \n",
411 | " 1 | \n",
412 | " 23 | \n",
413 | " Fezziwig's Festive Community | \n",
414 | " 0.164384 | \n",
415 | " # Fezziwig's Festive Community\\n\\nThe communit... | \n",
416 | " 7.5 | \n",
417 | "
\n",
418 | " \n",
419 | " 2 | \n",
420 | " 27 | \n",
421 | " Ebenezer Scrooge and Jacob Marley Community | \n",
422 | " 0.136986 | \n",
423 | " # Ebenezer Scrooge and Jacob Marley Community\\... | \n",
424 | " 8.5 | \n",
425 | "
\n",
426 | " \n",
427 | " 3 | \n",
428 | " 2 | \n",
429 | " Bob Cratchit and Christmas Eve Community | \n",
430 | " 0.123288 | \n",
431 | " # Bob Cratchit and Christmas Eve Community\\n\\n... | \n",
432 | " 7.5 | \n",
433 | "
\n",
434 | " \n",
435 | " 4 | \n",
436 | " 31 | \n",
437 | " Scrooge's Journey with The Spirit | \n",
438 | " 0.109589 | \n",
439 | " # Scrooge's Journey with The Spirit\\n\\nThe com... | \n",
440 | " 7.5 | \n",
441 | "
\n",
442 | " \n",
443 | " 5 | \n",
444 | " 28 | \n",
445 | " Marley's Ghost and Scrooge | \n",
446 | " 0.095890 | \n",
447 | " # Marley's Ghost and Scrooge\\n\\nThe community ... | \n",
448 | " 7.5 | \n",
449 | "
\n",
450 | " \n",
451 | " 6 | \n",
452 | " 20 | \n",
453 | " Scrooge and Christmas Community | \n",
454 | " 0.082192 | \n",
455 | " # Scrooge and Christmas Community\\n\\nThe commu... | \n",
456 | " 7.5 | \n",
457 | "
\n",
458 | " \n",
459 | " 7 | \n",
460 | " 29 | \n",
461 | " Scrooge's Family and Associates | \n",
462 | " 0.068493 | \n",
463 | " # Scrooge's Family and Associates\\n\\nThe commu... | \n",
464 | " 7.5 | \n",
465 | "
\n",
466 | " \n",
467 | " 8 | \n",
468 | " 24 | \n",
469 | " Fezziwig's Dance and Festivities | \n",
470 | " 0.041096 | \n",
471 | " # Fezziwig's Dance and Festivities\\n\\nThe comm... | \n",
472 | " 6.5 | \n",
473 | "
\n",
474 | " \n",
475 | " 9 | \n",
476 | " 13 | \n",
477 | " Scrooge's Vision: The Fair Young Girl and The Man | \n",
478 | " 0.027397 | \n",
479 | " # Scrooge's Vision: The Fair Young Girl and Th... | \n",
480 | " 7.5 | \n",
481 | "
\n",
482 | " \n",
483 | " 10 | \n",
484 | " 5 | \n",
485 | " City of London and The Corporation | \n",
486 | " 0.027397 | \n",
487 | " # City of London and The Corporation\\n\\nThe co... | \n",
488 | " 6.5 | \n",
489 | "
\n",
490 | " \n",
491 | " 11 | \n",
492 | " 21 | \n",
493 | " Scrooge's Counting-House Community | \n",
494 | " 0.027397 | \n",
495 | " # Scrooge's Counting-House Community\\n\\nThe co... | \n",
496 | " 6.5 | \n",
497 | "
\n",
498 | " \n",
499 | " 12 | \n",
500 | " 17 | \n",
501 | " J. B. Lippincott Company and A Christmas Carol | \n",
502 | " 0.027397 | \n",
503 | " # J. B. Lippincott Company and A Christmas Car... | \n",
504 | " 6.5 | \n",
505 | "
\n",
506 | " \n",
507 | " 13 | \n",
508 | " 15 | \n",
509 | " Scrooge's Narrative Connections | \n",
510 | " 0.027397 | \n",
511 | " # Scrooge's Narrative Connections\\n\\nThe commu... | \n",
512 | " 4.5 | \n",
513 | "
\n",
514 | " \n",
515 | " 14 | \n",
516 | " 18 | \n",
517 | " Project Gutenberg and A Christmas Carol | \n",
518 | " 0.027397 | \n",
519 | " # Project Gutenberg and A Christmas Carol\\n\\nT... | \n",
520 | " 3.0 | \n",
521 | "
\n",
522 | " \n",
523 | " 15 | \n",
524 | " 3 | \n",
525 | " Scrooge and the Christmas Carol Incident | \n",
526 | " 0.013699 | \n",
527 | " # Scrooge and the Christmas Carol Incident\\n\\n... | \n",
528 | " 6.5 | \n",
529 | "
\n",
530 | " \n",
531 | " 16 | \n",
532 | " 10 | \n",
533 | " Scrooge and Marley's Business Partnership | \n",
534 | " 0.013699 | \n",
535 | " # Scrooge and Marley's Business Partnership\\n\\... | \n",
536 | " 6.5 | \n",
537 | "
\n",
538 | " \n",
539 | " 17 | \n",
540 | " 11 | \n",
541 | " Scrooge and Marley Firm | \n",
542 | " 0.013699 | \n",
543 | " # Scrooge and Marley Firm\\n\\nThe community rev... | \n",
544 | " 6.5 | \n",
545 | "
\n",
546 | " \n",
547 | " 18 | \n",
548 | " 26 | \n",
549 | " The Three Miss Fezziwigs and Their Romantic Im... | \n",
550 | " 0.013699 | \n",
551 | " # The Three Miss Fezziwigs and Their Romantic ... | \n",
552 | " 4.5 | \n",
553 | "
\n",
554 | " \n",
555 | " 19 | \n",
556 | " 14 | \n",
557 | " Scrooge and the Old Ghost in a White Waistcoat | \n",
558 | " 0.013699 | \n",
559 | " # Scrooge and the Old Ghost in a White Waistco... | \n",
560 | " 4.5 | \n",
561 | "
\n",
562 | " \n",
563 | " 20 | \n",
564 | " 30 | \n",
565 | " Scrooge and His Community | \n",
566 | " 1.000000 | \n",
567 | " # Scrooge and His Community\\n\\nThe community c... | \n",
568 | " 8.5 | \n",
569 | "
\n",
570 | " \n",
571 | " 21 | \n",
572 | " 8 | \n",
573 | " Scrooge and Marley's Haunting Legacy | \n",
574 | " 0.123288 | \n",
575 | " # Scrooge and Marley's Haunting Legacy\\n\\nThe ... | \n",
576 | " 8.5 | \n",
577 | "
\n",
578 | " \n",
579 | " 22 | \n",
580 | " 25 | \n",
581 | " Fezziwig's Ball and Domestic Festivities | \n",
582 | " 0.123288 | \n",
583 | " # Fezziwig's Ball and Domestic Festivities\\n\\n... | \n",
584 | " 4.5 | \n",
585 | "
\n",
586 | " \n",
587 | " 23 | \n",
588 | " 12 | \n",
589 | " Scrooge's Journey through The City and The War... | \n",
590 | " 0.082192 | \n",
591 | " # Scrooge's Journey through The City and The W... | \n",
592 | " 7.5 | \n",
593 | "
\n",
594 | " \n",
595 | " 24 | \n",
596 | " 6 | \n",
597 | " Jacob and the Path to Enlightenment | \n",
598 | " 0.068493 | \n",
599 | " # Jacob and the Path to Enlightenment\\n\\nThe c... | \n",
600 | " 7.5 | \n",
601 | "
\n",
602 | " \n",
603 | " 25 | \n",
604 | " 9 | \n",
605 | " The Schoolmaster and Master Scrooge | \n",
606 | " 0.041096 | \n",
607 | " # The Schoolmaster and Master Scrooge\\n\\nThe c... | \n",
608 | " 6.5 | \n",
609 | "
\n",
610 | " \n",
611 | "
\n",
612 | "
"
613 | ],
614 | "text/plain": [
615 | " id title occurrence weight \\\n",
616 | "0 19 Scrooge and the Ghost of Jacob Marley 0.260274 \n",
617 | "1 23 Fezziwig's Festive Community 0.164384 \n",
618 | "2 27 Ebenezer Scrooge and Jacob Marley Community 0.136986 \n",
619 | "3 2 Bob Cratchit and Christmas Eve Community 0.123288 \n",
620 | "4 31 Scrooge's Journey with The Spirit 0.109589 \n",
621 | "5 28 Marley's Ghost and Scrooge 0.095890 \n",
622 | "6 20 Scrooge and Christmas Community 0.082192 \n",
623 | "7 29 Scrooge's Family and Associates 0.068493 \n",
624 | "8 24 Fezziwig's Dance and Festivities 0.041096 \n",
625 | "9 13 Scrooge's Vision: The Fair Young Girl and The Man 0.027397 \n",
626 | "10 5 City of London and The Corporation 0.027397 \n",
627 | "11 21 Scrooge's Counting-House Community 0.027397 \n",
628 | "12 17 J. B. Lippincott Company and A Christmas Carol 0.027397 \n",
629 | "13 15 Scrooge's Narrative Connections 0.027397 \n",
630 | "14 18 Project Gutenberg and A Christmas Carol 0.027397 \n",
631 | "15 3 Scrooge and the Christmas Carol Incident 0.013699 \n",
632 | "16 10 Scrooge and Marley's Business Partnership 0.013699 \n",
633 | "17 11 Scrooge and Marley Firm 0.013699 \n",
634 | "18 26 The Three Miss Fezziwigs and Their Romantic Im... 0.013699 \n",
635 | "19 14 Scrooge and the Old Ghost in a White Waistcoat 0.013699 \n",
636 | "20 30 Scrooge and His Community 1.000000 \n",
637 | "21 8 Scrooge and Marley's Haunting Legacy 0.123288 \n",
638 | "22 25 Fezziwig's Ball and Domestic Festivities 0.123288 \n",
639 | "23 12 Scrooge's Journey through The City and The War... 0.082192 \n",
640 | "24 6 Jacob and the Path to Enlightenment 0.068493 \n",
641 | "25 9 The Schoolmaster and Master Scrooge 0.041096 \n",
642 | "\n",
643 | " content rank \n",
644 | "0 # Scrooge and the Ghost of Jacob Marley\\n\\nThe... 8.5 \n",
645 | "1 # Fezziwig's Festive Community\\n\\nThe communit... 7.5 \n",
646 | "2 # Ebenezer Scrooge and Jacob Marley Community\\... 8.5 \n",
647 | "3 # Bob Cratchit and Christmas Eve Community\\n\\n... 7.5 \n",
648 | "4 # Scrooge's Journey with The Spirit\\n\\nThe com... 7.5 \n",
649 | "5 # Marley's Ghost and Scrooge\\n\\nThe community ... 7.5 \n",
650 | "6 # Scrooge and Christmas Community\\n\\nThe commu... 7.5 \n",
651 | "7 # Scrooge's Family and Associates\\n\\nThe commu... 7.5 \n",
652 | "8 # Fezziwig's Dance and Festivities\\n\\nThe comm... 6.5 \n",
653 | "9 # Scrooge's Vision: The Fair Young Girl and Th... 7.5 \n",
654 | "10 # City of London and The Corporation\\n\\nThe co... 6.5 \n",
655 | "11 # Scrooge's Counting-House Community\\n\\nThe co... 6.5 \n",
656 | "12 # J. B. Lippincott Company and A Christmas Car... 6.5 \n",
657 | "13 # Scrooge's Narrative Connections\\n\\nThe commu... 4.5 \n",
658 | "14 # Project Gutenberg and A Christmas Carol\\n\\nT... 3.0 \n",
659 | "15 # Scrooge and the Christmas Carol Incident\\n\\n... 6.5 \n",
660 | "16 # Scrooge and Marley's Business Partnership\\n\\... 6.5 \n",
661 | "17 # Scrooge and Marley Firm\\n\\nThe community rev... 6.5 \n",
662 | "18 # The Three Miss Fezziwigs and Their Romantic ... 4.5 \n",
663 | "19 # Scrooge and the Old Ghost in a White Waistco... 4.5 \n",
664 | "20 # Scrooge and His Community\\n\\nThe community c... 8.5 \n",
665 | "21 # Scrooge and Marley's Haunting Legacy\\n\\nThe ... 8.5 \n",
666 | "22 # Fezziwig's Ball and Domestic Festivities\\n\\n... 4.5 \n",
667 | "23 # Scrooge's Journey through The City and The W... 7.5 \n",
668 | "24 # Jacob and the Path to Enlightenment\\n\\nThe c... 7.5 \n",
669 | "25 # The Schoolmaster and Master Scrooge\\n\\nThe c... 6.5 "
670 | ]
671 | },
672 | "execution_count": 21,
673 | "metadata": {},
674 | "output_type": "execute_result"
675 | }
676 | ],
677 | "source": [
678 | "# inspect the data used to build the context for the LLM responses\n",
679 | "result.context_data[\"reports\"]"
680 | ]
681 | },
682 | {
683 | "cell_type": "code",
684 | "execution_count": 22,
685 | "metadata": {},
686 | "outputs": [
687 | {
688 | "name": "stdout",
689 | "output_type": "stream",
690 | "text": [
691 | "LLM calls: 3. LLM tokens: 18952\n"
692 | ]
693 | }
694 | ],
695 | "source": [
696 | "# inspect number of LLM calls and tokens\n",
697 | "print(f\"LLM calls: {result.llm_calls}. LLM tokens: {result.prompt_tokens}\")"
698 | ]
699 | }
700 | ],
701 | "metadata": {
702 | "kernelspec": {
703 | "display_name": "Python 3",
704 | "language": "python",
705 | "name": "python3"
706 | },
707 | "language_info": {
708 | "codemirror_mode": {
709 | "name": "ipython",
710 | "version": 3
711 | },
712 | "file_extension": ".py",
713 | "mimetype": "text/x-python",
714 | "name": "python",
715 | "nbconvert_exporter": "python",
716 | "pygments_lexer": "ipython3",
717 | "version": "3.11.5"
718 | }
719 | },
720 | "nbformat": 4,
721 | "nbformat_minor": 2
722 | }
723 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | graphrag
--------------------------------------------------------------------------------