Overglitch commited on
Commit
56da2e5
·
1 Parent(s): 9959265

first commit

Browse files
.gitignore ADDED
File without changes
app.py CHANGED
@@ -1,64 +1,157 @@
1
  import gradio as gr
2
- from huggingface_hub import InferenceClient
3
-
4
- """
5
- For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
6
- """
7
- client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
8
-
9
-
10
- def respond(
11
- message,
12
- history: list[tuple[str, str]],
13
- system_message,
14
- max_tokens,
15
- temperature,
16
- top_p,
17
- ):
18
- messages = [{"role": "system", "content": system_message}]
19
-
20
- for val in history:
21
- if val[0]:
22
- messages.append({"role": "user", "content": val[0]})
23
- if val[1]:
24
- messages.append({"role": "assistant", "content": val[1]})
25
-
26
- messages.append({"role": "user", "content": message})
27
-
28
- response = ""
29
-
30
- for message in client.chat_completion(
31
- messages,
32
- max_tokens=max_tokens,
33
- stream=True,
34
- temperature=temperature,
35
- top_p=top_p,
36
- ):
37
- token = message.choices[0].delta.content
38
-
39
- response += token
40
- yield response
41
-
42
-
43
- """
44
- For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
45
- """
46
- demo = gr.ChatInterface(
47
- respond,
48
- additional_inputs=[
49
- gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
50
- gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
51
- gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
52
- gr.Slider(
53
- minimum=0.1,
54
- maximum=1.0,
55
- value=0.95,
56
- step=0.05,
57
- label="Top-p (nucleus sampling)",
58
- ),
59
- ],
60
- )
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
 
63
  if __name__ == "__main__":
64
- demo.launch()
 
1
  import gradio as gr
2
+ from modules.extractive import TFIDFSummarizer, TextRankSummarizer, CombinedSummarizer, BERTSummarizer
3
+ from modules.abstractive import load_summarizers, abstractive_summary
4
+ from modules.preprocessing import Preprocessor, PDFProcessor
5
+ from modules.utils import handle_long_text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
+ # Cargar modelos abstractivos finetuneados
8
+ summarizers = load_summarizers()
9
+
10
+
11
+ # Función principal para generar resúmenes
12
+ def summarize(input_text, file, summary_type, method, num_sentences, model_name, max_length, num_beams):
13
+ preprocessor = Preprocessor()
14
+
15
+ if file is not None:
16
+ pdf_processor = PDFProcessor()
17
+ input_text = pdf_processor.pdf_to_text(file.name)
18
+
19
+ if not input_text:
20
+ return "Por favor, ingrese texto o cargue un archivo válido."
21
+
22
+ cleaned_text = preprocessor.clean_text(input_text)
23
+
24
+ if summary_type == "Extractivo":
25
+ if method == "TF-IDF":
26
+ summarizer = TFIDFSummarizer()
27
+ elif method == "TextRank":
28
+ summarizer = TextRankSummarizer()
29
+ elif method == "BERT":
30
+ summarizer = BERTSummarizer()
31
+ elif method == "TF-IDF + TextRank":
32
+ summarizer = CombinedSummarizer()
33
+ else:
34
+ return "Método no válido para resumen extractivo."
35
+
36
+ return summarizer.summarize(
37
+ preprocessor.split_into_sentences(cleaned_text),
38
+ preprocessor.clean_sentences(preprocessor.split_into_sentences(cleaned_text)),
39
+ num_sentences,
40
+ )
41
+
42
+ elif summary_type == "Abstractivo":
43
+ if model_name not in summarizers:
44
+ return "Modelo no disponible para resumen abstractivo."
45
+ return handle_long_text(
46
+ cleaned_text,
47
+ summarizers[model_name][0],
48
+ summarizers[model_name][1],
49
+ max_length=max_length,
50
+ stride=128,
51
+ )
52
+
53
+ elif summary_type == "Combinado":
54
+ if model_name not in summarizers:
55
+ return "Modelo no disponible para resumen abstractivo."
56
+ extractive_summary = TFIDFSummarizer().summarize(
57
+ preprocessor.split_into_sentences(cleaned_text),
58
+ preprocessor.clean_sentences(preprocessor.split_into_sentences(cleaned_text)),
59
+ num_sentences,
60
+ )
61
+ return handle_long_text(
62
+ extractive_summary,
63
+ summarizers[model_name][0],
64
+ summarizers[model_name][1],
65
+ max_length=max_length,
66
+ stride=128,
67
+ )
68
+
69
+ return "Seleccione un tipo de resumen válido."
70
+
71
+
72
+ # Interfaz dinámica
73
+ with gr.Blocks() as interface:
74
+ gr.Markdown("# Demo: Generador de Resúmenes Inteligente")
75
+
76
+ # Entrada de texto o archivo
77
+ with gr.Row():
78
+ input_text = gr.Textbox(lines=9, label="Ingrese texto")
79
+ file = gr.File(label="Subir archivo (PDF, TXT)")
80
+
81
+ # Selección de tipo de resumen
82
+ summary_type = gr.Radio(
83
+ ["Extractivo", "Abstractivo", "Combinado"],
84
+ label="Tipo de resumen",
85
+ value="Extractivo",
86
+ )
87
+
88
+ # Opciones dinámicas
89
+ method = gr.Radio(
90
+ ["TF-IDF", "TextRank", "BERT", "TF-IDF + TextRank"],
91
+ label="Método Extractivo",
92
+ visible=True,
93
+ )
94
+ num_sentences = gr.Slider(
95
+ 1, 10, value=3, step=1, label="Número de oraciones (Extractivo)", visible=True
96
+ )
97
+ model_name = gr.Radio(
98
+ ["Pegasus", "T5", "BART"],
99
+ label="Modelo Abstractivo",
100
+ visible=False,
101
+ )
102
+ max_length = gr.Slider(
103
+ 50, 300, value=128, step=10, label="Longitud máxima (Abstractivo)", visible=False
104
+ )
105
+ num_beams = gr.Slider(
106
+ 1, 10, value=4, step=1, label="Número de haces (Abstractivo)", visible=False
107
+ )
108
+
109
+
110
+ def update_options(summary_type):
111
+ if summary_type == "Extractivo":
112
+ return (
113
+ gr.update(visible=True), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False),
114
+ gr.update(visible=False))
115
+ elif summary_type == "Abstractivo":
116
+ return (
117
+ gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), gr.update(visible=True),
118
+ gr.update(visible=True))
119
+ elif summary_type == "Combinado":
120
+ return (gr.update(visible=True), gr.update(visible=True), gr.update(visible=True), gr.update(visible=True),
121
+ gr.update(visible=True))
122
+ else:
123
+ return (
124
+ gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False),
125
+ gr.update(visible=False))
126
+
127
+
128
+ summary_type.change(
129
+ update_options,
130
+ inputs=[summary_type],
131
+ outputs=[method, num_sentences, model_name, max_length, num_beams],
132
+ )
133
+
134
+ summarize_button = gr.Button("Generar Resumen")
135
+ output = gr.Textbox(lines=10, label="Resumen generado", interactive=True)
136
+ copy_button = gr.Button("Copiar Resumen")
137
+
138
+ summarize_button.click(
139
+ summarize,
140
+ inputs=[input_text, file, summary_type, method, num_sentences, model_name, max_length, num_beams],
141
+ outputs=output,
142
+ )
143
+
144
+
145
+ def copy_summary(summary):
146
+ return summary
147
+
148
+
149
+ copy_button.click(
150
+ fn=copy_summary,
151
+ inputs=[output],
152
+ outputs=[output],
153
+ js="""function(summary) { navigator.clipboard.writeText(summary); return summary; }""",
154
+ )
155
 
156
  if __name__ == "__main__":
157
+ interface.launch()
examples/sample_doc.pdf ADDED
Binary file (573 kB). View file
 
examples/sample_text.txt ADDED
@@ -0,0 +1,1312 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ TITLE: Alice's Adventures in Wonderland
2
+ AUTHOR: Lewis Carroll
3
+
4
+
5
+ = CHAPTER I =
6
+ =( Down the Rabbit-Hole )=
7
+
8
+ Alice was beginning to get very tired of sitting by her sister
9
+ on the bank, and of having nothing to do: once or twice she had
10
+ peeped into the book her sister was reading, but it had no
11
+ pictures or conversations in it, `and what is the use of a book,'
12
+ thought Alice `without pictures or conversation?'
13
+
14
+ So she was considering in her own mind (as well as she could,
15
+ for the hot day made her feel very sleepy and stupid), whether
16
+ the pleasure of making a daisy-chain would be worth the trouble
17
+ of getting up and picking the daisies, when suddenly a White
18
+ Rabbit with pink eyes ran close by her.
19
+
20
+ There was nothing so VERY remarkable in that; nor did Alice
21
+ think it so VERY much out of the way to hear the Rabbit say to
22
+ itself, `Oh dear! Oh dear! I shall be late!' (when she thought
23
+ it over afterwards, it occurred to her that she ought to have
24
+ wondered at this, but at the time it all seemed quite natural);
25
+ but when the Rabbit actually TOOK A WATCH OUT OF ITS WAISTCOAT-
26
+ POCKET, and looked at it, and then hurried on, Alice started to
27
+ her feet, for it flashed across her mind that she had never
28
+ before seen a rabbit with either a waistcoat-pocket, or a watch to
29
+ take out of it, and burning with curiosity, she ran across the
30
+ field after it, and fortunately was just in time to see it pop
31
+ down a large rabbit-hole under the hedge.
32
+
33
+ In another moment down went Alice after it, never once
34
+ considering how in the world she was to get out again.
35
+
36
+ The rabbit-hole went straight on like a tunnel for some way,
37
+ and then dipped suddenly down, so suddenly that Alice had not a
38
+ moment to think about stopping herself before she found herself
39
+ falling down a very deep well.
40
+
41
+ Either the well was very deep, or she fell very slowly, for she
42
+ had plenty of time as she went down to look about her and to
43
+ wonder what was going to happen next. First, she tried to look
44
+ down and make out what she was coming to, but it was too dark to
45
+ see anything; then she looked at the sides of the well, and
46
+ noticed that they were filled with cupboards and book-shelves;
47
+ here and there she saw maps and pictures hung upon pegs. She
48
+ took down a jar from one of the shelves as she passed; it was
49
+ labelled `ORANGE MARMALADE', but to her great disappointment it
50
+ was empty: she did not like to drop the jar for fear of killing
51
+ somebody, so managed to put it into one of the cupboards as she
52
+ fell past it.
53
+
54
+ `Well!' thought Alice to herself, `after such a fall as this, I
55
+ shall think nothing of tumbling down stairs! How brave they'll
56
+ all think me at home! Why, I wouldn't say anything about it,
57
+ even if I fell off the top of the house!' (Which was very likely
58
+ true.)
59
+
60
+ Down, down, down. Would the fall NEVER come to an end! `I
61
+ wonder how many miles I've fallen by this time?' she said aloud.
62
+ `I must be getting somewhere near the centre of the earth. Let
63
+ me see: that would be four thousand miles down, I think--' (for,
64
+ you see, Alice had learnt several things of this sort in her
65
+ lessons in the schoolroom, and though this was not a VERY good
66
+ opportunity for showing off her knowledge, as there was no one to
67
+ listen to her, still it was good practice to say it over) `--yes,
68
+ that's about the right distance--but then I wonder what Latitude
69
+ or Longitude I've got to?' (Alice had no idea what Latitude was,
70
+ or Longitude either, but thought they were nice grand words to
71
+ say.)
72
+
73
+ Presently she began again. `I wonder if I shall fall right
74
+ THROUGH the earth! How funny it'll seem to come out among the
75
+ people that walk with their heads downward! The Antipathies, I
76
+ think--' (she was rather glad there WAS no one listening, this
77
+ time, as it didn't sound at all the right word) `--but I shall
78
+ have to ask them what the name of the country is, you know.
79
+ Please, Ma'am, is this New Zealand or Australia?' (and she tried
80
+ to curtsey as she spoke--fancy CURTSEYING as you're falling
81
+ through the air! Do you think you could manage it?) `And what
82
+ an ignorant little girl she'll think me for asking! No, it'll
83
+ never do to ask: perhaps I shall see it written up somewhere.'
84
+
85
+ Down, down, down. There was nothing else to do, so Alice soon
86
+ began talking again. `Dinah'll miss me very much to-night, I
87
+ should think!' (Dinah was the cat.) `I hope they'll remember
88
+ her saucer of milk at tea-time. Dinah my dear! I wish you were
89
+ down here with me! There are no mice in the air, I'm afraid, but
90
+ you might catch a bat, and that's very like a mouse, you know.
91
+ But do cats eat bats, I wonder?' And here Alice began to get
92
+ rather sleepy, and went on saying to herself, in a dreamy sort of
93
+ way, `Do cats eat bats? Do cats eat bats?' and sometimes, `Do
94
+ bats eat cats?' for, you see, as she couldn't answer either
95
+ question, it didn't much matter which way she put it. She felt
96
+ that she was dozing off, and had just begun to dream that she
97
+ was walking hand in hand with Dinah, and saying to her very
98
+ earnestly, `Now, Dinah, tell me the truth: did you ever eat a
99
+ bat?' when suddenly, thump! thump! down she came upon a heap of
100
+ sticks and dry leaves, and the fall was over.
101
+
102
+ Alice was not a bit hurt, and she jumped up on to her feet in a
103
+ moment: she looked up, but it was all dark overhead; before her
104
+ was another long passage, and the White Rabbit was still in
105
+ sight, hurrying down it. There was not a moment to be lost:
106
+ away went Alice like the wind, and was just in time to hear it
107
+ say, as it turned a corner, `Oh my ears and whiskers, how late
108
+ it's getting!' She was close behind it when she turned the
109
+ corner, but the Rabbit was no longer to be seen: she found
110
+ herself in a long, low hall, which was lit up by a row of lamps
111
+ hanging from the roof.
112
+
113
+ There were doors all round the hall, but they were all locked;
114
+ and when Alice had been all the way down one side and up the
115
+ other, trying every door, she walked sadly down the middle,
116
+ wondering how she was ever to get out again.
117
+
118
+ Suddenly she came upon a little three-legged table, all made of
119
+ solid glass; there was nothing on it except a tiny golden key,
120
+ and Alice's first thought was that it might belong to one of the
121
+ doors of the hall; but, alas! either the locks were too large, or
122
+ the key was too small, but at any rate it would not open any of
123
+ them. However, on the second time round, she came upon a low
124
+ curtain she had not noticed before, and behind it was a little
125
+ door about fifteen inches high: she tried the little golden key
126
+ in the lock, and to her great delight it fitted!
127
+
128
+ Alice opened the door and found that it led into a small
129
+ passage, not much larger than a rat-hole: she knelt down and
130
+ looked along the passage into the loveliest garden you ever saw.
131
+ How she longed to get out of that dark hall, and wander about
132
+ among those beds of bright flowers and those cool fountains, but
133
+ she could not even get her head through the doorway; `and even if
134
+ my head would go through,' thought poor Alice, `it would be of
135
+ very little use without my shoulders. Oh, how I wish
136
+ I could shut up like a telescope! I think I could, if I only
137
+ know how to begin.' For, you see, so many out-of-the-way things
138
+ had happened lately, that Alice had begun to think that very few
139
+ things indeed were really impossible.
140
+
141
+ There seemed to be no use in waiting by the little door, so she
142
+ went back to the table, half hoping she might find another key on
143
+ it, or at any rate a book of rules for shutting people up like
144
+ telescopes: this time she found a little bottle on it, (`which
145
+ certainly was not here before,' said Alice,) and round the neck
146
+ of the bottle was a paper label, with the words `DRINK ME'
147
+ beautifully printed on it in large letters.
148
+
149
+ It was all very well to say `Drink me,' but the wise little
150
+ Alice was not going to do THAT in a hurry. `No, I'll look
151
+ first,' she said, `and see whether it's marked "poison" or not';
152
+ for she had read several nice little histories about children who
153
+ had got burnt, and eaten up by wild beasts and other unpleasant
154
+ things, all because they WOULD not remember the simple rules
155
+ their friends had taught them: such as, that a red-hot poker
156
+ will burn you if you hold it too long; and that if you cut your
157
+ finger VERY deeply with a knife, it usually bleeds; and she had
158
+ never forgotten that, if you drink much from a bottle marked
159
+ `poison,' it is almost certain to disagree with you, sooner or
160
+ later.
161
+
162
+ However, this bottle was NOT marked `poison,' so Alice ventured
163
+ to taste it, and finding it very nice, (it had, in fact, a sort
164
+ of mixed flavour of cherry-tart, custard, pine-apple, roast
165
+ turkey, toffee, and hot buttered toast,) she very soon finished
166
+ it off.
167
+
168
+ * * * * * * *
169
+
170
+ * * * * * *
171
+
172
+ * * * * * * *
173
+
174
+ `What a curious feeling!' said Alice; `I must be shutting up
175
+ like a telescope.'
176
+
177
+ And so it was indeed: she was now only ten inches high, and
178
+ her face brightened up at the thought that she was now the right
179
+ size for going through the little door into that lovely garden.
180
+ First, however, she waited for a few minutes to see if she was
181
+ going to shrink any further: she felt a little nervous about
182
+ this; `for it might end, you know,' said Alice to herself, `in my
183
+ going out altogether, like a candle. I wonder what I should be
184
+ like then?' And she tried to fancy what the flame of a candle is
185
+ like after the candle is blown out, for she could not remember
186
+ ever having seen such a thing.
187
+
188
+ After a while, finding that nothing more happened, she decided
189
+ on going into the garden at once; but, alas for poor Alice!
190
+ when she got to the door, she found she had forgotten the
191
+ little golden key, and when she went back to the table for it,
192
+ she found she could not possibly reach it: she could see it
193
+ quite plainly through the glass, and she tried her best to climb
194
+ up one of the legs of the table, but it was too slippery;
195
+ and when she had tired herself out with trying,
196
+ the poor little thing sat down and cried.
197
+
198
+ `Come, there's no use in crying like that!' said Alice to
199
+ herself, rather sharply; `I advise you to leave off this minute!'
200
+ She generally gave herself very good advice, (though she very
201
+ seldom followed it), and sometimes she scolded herself so
202
+ severely as to bring tears into her eyes; and once she remembered
203
+ trying to box her own ears for having cheated herself in a game
204
+ of croquet she was playing against herself, for this curious
205
+ child was very fond of pretending to be two people. `But it's no
206
+ use now,' thought poor Alice, `to pretend to be two people! Why,
207
+ there's hardly enough of me left to make ONE respectable
208
+ person!'
209
+
210
+ Soon her eye fell on a little glass box that was lying under
211
+ the table: she opened it, and found in it a very small cake, on
212
+ which the words `EAT ME' were beautifully marked in currants.
213
+ `Well, I'll eat it,' said Alice, `and if it makes me grow larger,
214
+ I can reach the key; and if it makes me grow smaller, I can creep
215
+ under the door; so either way I'll get into the garden, and I
216
+ don't care which happens!'
217
+
218
+ She ate a little bit, and said anxiously to herself, `Which
219
+ way? Which way?', holding her hand on the top of her head to
220
+ feel which way it was growing, and she was quite surprised to
221
+ find that she remained the same size: to be sure, this generally
222
+ happens when one eats cake, but Alice had got so much into the
223
+ way of expecting nothing but out-of-the-way things to happen,
224
+ that it seemed quite dull and stupid for life to go on in the
225
+ common way.
226
+
227
+ So she set to work, and very soon finished off the cake.
228
+
229
+ * * * * * * *
230
+
231
+ * * * * * *
232
+
233
+ * * * * * * *
234
+
235
+
236
+
237
+
238
+ = CHAPTER II =
239
+ =( The Pool of Tears )=
240
+
241
+
242
+ `Curiouser and curiouser!' cried Alice (she was so much
243
+ surprised, that for the moment she quite forgot how to speak good
244
+ English); `now I'm opening out like the largest telescope that
245
+ ever was! Good-bye, feet!' (for when she looked down at her
246
+ feet, they seemed to be almost out of sight, they were getting so
247
+ far off). `Oh, my poor little feet, I wonder who will put on
248
+ your shoes and stockings for you now, dears? I'm sure _I_ shan't
249
+ be able! I shall be a great deal too far off to trouble myself
250
+ about you: you must manage the best way you can; --but I must be
251
+ kind to them,' thought Alice, `or perhaps they won't walk the
252
+ way I want to go! Let me see: I'll give them a new pair of
253
+ boots every Christmas.'
254
+
255
+ And she went on planning to herself how she would manage it.
256
+ `They must go by the carrier,' she thought; `and how funny it'll
257
+ seem, sending presents to one's own feet! And how odd the
258
+ directions will look!
259
+
260
+ ALICE'S RIGHT FOOT, ESQ.
261
+ HEARTHRUG,
262
+ NEAR THE FENDER,
263
+ (WITH ALICE'S LOVE).
264
+
265
+ Oh dear, what nonsense I'm talking!'
266
+
267
+ Just then her head struck against the roof of the hall: in
268
+ fact she was now more than nine feet high, and she at once took
269
+ up the little golden key and hurried off to the garden door.
270
+
271
+ Poor Alice! It was as much as she could do, lying down on one
272
+ side, to look through into the garden with one eye; but to get
273
+ through was more hopeless than ever: she sat down and began to
274
+ cry again.
275
+
276
+ `You ought to be ashamed of yourself,' said Alice, `a great
277
+ girl like you,' (she might well say this), `to go on crying in
278
+ this way! Stop this moment, I tell you!' But she went on all
279
+ the same, shedding gallons of tears, until there was a large pool
280
+ all round her, about four inches deep and reaching half down the
281
+ hall.
282
+
283
+ After a time she heard a little pattering of feet in the
284
+ distance, and she hastily dried her eyes to see what was coming.
285
+ It was the White Rabbit returning, splendidly dressed, with a
286
+ pair of white kid gloves in one hand and a large fan in the
287
+ other: he came trotting along in a great hurry, muttering to
288
+ himself as he came, `Oh! the Duchess, the Duchess! Oh! won't she
289
+ be savage if I've kept her waiting!' Alice felt so desperate
290
+ that she was ready to ask help of any one; so, when the Rabbit
291
+ came near her, she began, in a low, timid voice, `If you please,
292
+ sir--' The Rabbit started violently, dropped the white kid
293
+ gloves and the fan, and skurried away into the darkness as hard
294
+ as he could go.
295
+
296
+ Alice took up the fan and gloves, and, as the hall was very
297
+ hot, she kept fanning herself all the time she went on talking:
298
+ `Dear, dear! How queer everything is to-day! And yesterday
299
+ things went on just as usual. I wonder if I've been changed in
300
+ the night? Let me think: was I the same when I got up this
301
+ morning? I almost think I can remember feeling a little
302
+ different. But if I'm not the same, the next question is, Who in
303
+ the world am I? Ah, THAT'S the great puzzle!' And she began
304
+ thinking over all the children she knew that were of the same age
305
+ as herself, to see if she could have been changed for any of
306
+ them.
307
+
308
+ `I'm sure I'm not Ada,' she said, `for her hair goes in such
309
+ long ringlets, and mine doesn't go in ringlets at all; and I'm
310
+ sure I can't be Mabel, for I know all sorts of things, and she,
311
+ oh! she knows such a very little! Besides, SHE'S she, and I'm I,
312
+ and--oh dear, how puzzling it all is! I'll try if I know all the
313
+ things I used to know. Let me see: four times five is twelve,
314
+ and four times six is thirteen, and four times seven is--oh dear!
315
+ I shall never get to twenty at that rate! However, the
316
+ Multiplication Table doesn't signify: let's try Geography.
317
+ London is the capital of Paris, and Paris is the capital of Rome,
318
+ and Rome--no, THAT'S all wrong, I'm certain! I must have been
319
+ changed for Mabel! I'll try and say "How doth the little--"'
320
+ and she crossed her hands on her lap as if she were saying lessons,
321
+ and began to repeat it, but her voice sounded hoarse and
322
+ strange, and the words did not come the same as they used to do:--
323
+
324
+ `How doth the little crocodile
325
+ Improve his shining tail,
326
+ And pour the waters of the Nile
327
+ On every golden scale!
328
+
329
+ `How cheerfully he seems to grin,
330
+ How neatly spread his claws,
331
+ And welcome little fishes in
332
+ With gently smiling jaws!'
333
+
334
+ `I'm sure those are not the right words,' said poor Alice, and
335
+ her eyes filled with tears again as she went on, `I must be Mabel
336
+ after all, and I shall have to go and live in that poky little
337
+ house, and have next to no toys to play with, and oh! ever so
338
+ many lessons to learn! No, I've made up my mind about it; if I'm
339
+ Mabel, I'll stay down here! It'll be no use their putting their
340
+ heads down and saying "Come up again, dear!" I shall only look
341
+ up and say "Who am I then? Tell me that first, and then, if I
342
+ like being that person, I'll come up: if not, I'll stay down
343
+ here till I'm somebody else"--but, oh dear!' cried Alice, with a
344
+ sudden burst of tears, `I do wish they WOULD put their heads
345
+ down! I am so VERY tired of being all alone here!'
346
+
347
+ As she said this she looked down at her hands, and was
348
+ surprised to see that she had put on one of the Rabbit's little
349
+ white kid gloves while she was talking. `How CAN I have done
350
+ that?' she thought. `I must be growing small again.' She got up
351
+ and went to the table to measure herself by it, and found that,
352
+ as nearly as she could guess, she was now about two feet high,
353
+ and was going on shrinking rapidly: she soon found out that the
354
+ cause of this was the fan she was holding, and she dropped it
355
+ hastily, just in time to avoid shrinking away altogether.
356
+
357
+ `That WAS a narrow escape!' said Alice, a good deal frightened at
358
+ the sudden change, but very glad to find herself still in
359
+ existence; `and now for the garden!' and she ran with all speed
360
+ back to the little door: but, alas! the little door was shut
361
+ again, and the little golden key was lying on the glass table as
362
+ before, `and things are worse than ever,' thought the poor child,
363
+ `for I never was so small as this before, never! And I declare
364
+ it's too bad, that it is!'
365
+
366
+ As she said these words her foot slipped, and in another
367
+ moment, splash! she was up to her chin in salt water. Her first
368
+ idea was that she had somehow fallen into the sea, `and in that
369
+ case I can go back by railway,' she said to herself. (Alice had
370
+ been to the seaside once in her life, and had come to the general
371
+ conclusion, that wherever you go to on the English coast you find
372
+ a number of bathing machines in the sea, some children digging in
373
+ the sand with wooden spades, then a row of lodging houses, and
374
+ behind them a railway station.) However, she soon made out that
375
+ she was in the pool of tears which she had wept when she was nine
376
+ feet high.
377
+
378
+ `I wish I hadn't cried so much!' said Alice, as she swam about,
379
+ trying to find her way out. `I shall be punished for it now, I
380
+ suppose, by being drowned in my own tears! That WILL be a queer
381
+ thing, to be sure! However, everything is queer to-day.'
382
+
383
+ Just then she heard something splashing about in the pool a
384
+ little way off, and she swam nearer to make out what it was: at
385
+ first she thought it must be a walrus or hippopotamus, but then
386
+ she remembered how small she was now, and she soon made out that
387
+ it was only a mouse that had slipped in like herself.
388
+
389
+ `Would it be of any use, now,' thought Alice, `to speak to this
390
+ mouse? Everything is so out-of-the-way down here, that I should
391
+ think very likely it can talk: at any rate, there's no harm in
392
+ trying.' So she began: `O Mouse, do you know the way out of
393
+ this pool? I am very tired of swimming about here, O Mouse!'
394
+ (Alice thought this must be the right way of speaking to a mouse:
395
+ she had never done such a thing before, but she remembered having
396
+ seen in her brother's Latin Grammar, `A mouse--of a mouse--to a
397
+ mouse--a mouse--O mouse!') The Mouse looked at her rather
398
+ inquisitively, and seemed to her to wink with one of its little
399
+ eyes, but it said nothing.
400
+
401
+ `Perhaps it doesn't understand English,' thought Alice; `I
402
+ daresay it's a French mouse, come over with William the
403
+ Conqueror.' (For, with all her knowledge of history, Alice had
404
+ no very clear notion how long ago anything had happened.) So she
405
+ began again: `Ou est ma chatte?' which was the first sentence in
406
+ her French lesson-book. The Mouse gave a sudden leap out of the
407
+ water, and seemed to quiver all over with fright. `Oh, I beg
408
+ your pardon!' cried Alice hastily, afraid that she had hurt the
409
+ poor animal's feelings. `I quite forgot you didn't like cats.'
410
+
411
+ `Not like cats!' cried the Mouse, in a shrill, passionate
412
+ voice. `Would YOU like cats if you were me?'
413
+
414
+ `Well, perhaps not,' said Alice in a soothing tone: `don't be
415
+ angry about it. And yet I wish I could show you our cat Dinah:
416
+ I think you'd take a fancy to cats if you could only see her.
417
+ She is such a dear quiet thing,' Alice went on, half to herself,
418
+ as she swam lazily about in the pool, `and she sits purring so
419
+ nicely by the fire, licking her paws and washing her face--and
420
+ she is such a nice soft thing to nurse--and she's such a capital
421
+ one for catching mice--oh, I beg your pardon!' cried Alice again,
422
+ for this time the Mouse was bristling all over, and she felt
423
+ certain it must be really offended. `We won't talk about her any
424
+ more if you'd rather not.'
425
+
426
+ `We indeed!' cried the Mouse, who was trembling down to the end
427
+ of his tail. `As if I would talk on such a subject! Our family
428
+ always HATED cats: nasty, low, vulgar things! Don't let me hear
429
+ the name again!'
430
+
431
+ `I won't indeed!' said Alice, in a great hurry to change the
432
+ subject of conversation. `Are you--are you fond--of--of dogs?'
433
+ The Mouse did not answer, so Alice went on eagerly: `There is
434
+ such a nice little dog near our house I should like to show you!
435
+ A little bright-eyed terrier, you know, with oh, such long curly
436
+ brown hair! And it'll fetch things when you throw them, and
437
+ it'll sit up and beg for its dinner, and all sorts of things--I
438
+ can't remember half of them--and it belongs to a farmer, you
439
+ know, and he says it's so useful, it's worth a hundred pounds!
440
+ He says it kills all the rats and--oh dear!' cried Alice in a
441
+ sorrowful tone, `I'm afraid I've offended it again!' For the
442
+ Mouse was swimming away from her as hard as it could go, and
443
+ making quite a commotion in the pool as it went.
444
+
445
+ So she called softly after it, `Mouse dear! Do come back
446
+ again, and we won't talk about cats or dogs either, if you don't
447
+ like them!' When the Mouse heard this, it turned round and swam
448
+ slowly back to her: its face was quite pale (with passion, Alice
449
+ thought), and it said in a low trembling voice, `Let us get to
450
+ the shore, and then I'll tell you my history, and you'll
451
+ understand why it is I hate cats and dogs.'
452
+
453
+ It was high time to go, for the pool was getting quite crowded
454
+ with the birds and animals that had fallen into it: there were a
455
+ Duck and a Dodo, a Lory and an Eaglet, and several other curious
456
+ creatures. Alice led the way, and the whole party swam to the
457
+ shore.
458
+
459
+
460
+
461
+ = CHAPTER III =
462
+ =( A Caucus-Race and a Long Tale )=
463
+
464
+
465
+ They were indeed a queer-looking party that assembled on the
466
+ bank--the birds with draggled feathers, the animals with their
467
+ fur clinging close to them, and all dripping wet, cross, and
468
+ uncomfortable.
469
+
470
+ The first question of course was, how to get dry again: they
471
+ had a consultation about this, and after a few minutes it seemed
472
+ quite natural to Alice to find herself talking familiarly with
473
+ them, as if she had known them all her life. Indeed, she had
474
+ quite a long argument with the Lory, who at last turned sulky,
475
+ and would only say, `I am older than you, and must know better';
476
+ and this Alice would not allow without knowing how old it was,
477
+ and, as the Lory positively refused to tell its age, there was no
478
+ more to be said.
479
+
480
+ At last the Mouse, who seemed to be a person of authority among
481
+ them, called out, `Sit down, all of you, and listen to me! I'LL
482
+ soon make you dry enough!' They all sat down at once, in a large
483
+ ring, with the Mouse in the middle. Alice kept her eyes
484
+ anxiously fixed on it, for she felt sure she would catch a bad
485
+ cold if she did not get dry very soon.
486
+
487
+ `Ahem!' said the Mouse with an important air, `are you all ready?
488
+ This is the driest thing I know. Silence all round, if you please!
489
+ "William the Conqueror, whose cause was favoured by the pope, was
490
+ soon submitted to by the English, who wanted leaders, and had been
491
+ of late much accustomed to usurpation and conquest. Edwin and
492
+ Morcar, the earls of Mercia and Northumbria--"'
493
+
494
+ `Ugh!' said the Lory, with a shiver.
495
+
496
+ `I beg your pardon!' said the Mouse, frowning, but very
497
+ politely: `Did you speak?'
498
+
499
+ `Not I!' said the Lory hastily.
500
+
501
+ `I thought you did,' said the Mouse. `--I proceed. "Edwin and
502
+ Morcar, the earls of Mercia and Northumbria, declared for him:
503
+ and even Stigand, the patriotic archbishop of Canterbury, found
504
+ it advisable--"'
505
+
506
+ `Found WHAT?' said the Duck.
507
+
508
+ `Found IT,' the Mouse replied rather crossly: `of course you
509
+ know what "it" means.'
510
+
511
+ `I know what "it" means well enough, when I find a thing,' said
512
+ the Duck: `it's generally a frog or a worm. The question is,
513
+ what did the archbishop find?'
514
+
515
+ The Mouse did not notice this question, but hurriedly went on,
516
+ `"--found it advisable to go with Edgar Atheling to meet William
517
+ and offer him the crown. William's conduct at first was
518
+ moderate. But the insolence of his Normans--" How are you
519
+ getting on now, my dear?' it continued, turning to Alice as it
520
+ spoke.
521
+
522
+ `As wet as ever,' said Alice in a melancholy tone: `it doesn't
523
+ seem to dry me at all.'
524
+
525
+ `In that case,' said the Dodo solemnly, rising to its feet, `I
526
+ move that the meeting adjourn, for the immediate adoption of more
527
+ energetic remedies--'
528
+
529
+ `Speak English!' said the Eaglet. `I don't know the meaning of
530
+ half those long words, and, what's more, I don't believe you do
531
+ either!' And the Eaglet bent down its head to hide a smile:
532
+ some of the other birds tittered audibly.
533
+
534
+ `What I was going to say,' said the Dodo in an offended tone,
535
+ `was, that the best thing to get us dry would be a Caucus-race.'
536
+
537
+ `What IS a Caucus-race?' said Alice; not that she wanted much
538
+ to know, but the Dodo had paused as if it thought that SOMEBODY
539
+ ought to speak, and no one else seemed inclined to say anything.
540
+
541
+ `Why,' said the Dodo, `the best way to explain it is to do it.'
542
+ (And, as you might like to try the thing yourself, some winter
543
+ day, I will tell you how the Dodo managed it.)
544
+
545
+ First it marked out a race-course, in a sort of circle, (`the
546
+ exact shape doesn't matter,' it said,) and then all the party
547
+ were placed along the course, here and there. There was no `One,
548
+ two, three, and away,' but they began running when they liked,
549
+ and left off when they liked, so that it was not easy to know
550
+ when the race was over. However, when they had been running half
551
+ an hour or so, and were quite dry again, the Dodo suddenly called
552
+ out `The race is over!' and they all crowded round it, panting,
553
+ and asking, `But who has won?'
554
+
555
+ This question the Dodo could not answer without a great deal of
556
+ thought, and it sat for a long time with one finger pressed upon
557
+ its forehead (the position in which you usually see Shakespeare,
558
+ in the pictures of him), while the rest waited in silence. At
559
+ last the Dodo said, `EVERYBODY has won, and all must have
560
+ prizes.'
561
+
562
+ `But who is to give the prizes?' quite a chorus of voices
563
+ asked.
564
+
565
+ `Why, SHE, of course,' said the Dodo, pointing to Alice with
566
+ one finger; and the whole party at once crowded round her,
567
+ calling out in a confused way, `Prizes! Prizes!'
568
+
569
+ Alice had no idea what to do, and in despair she put her hand
570
+ in her pocket, and pulled out a box of comfits, (luckily the salt
571
+ water had not got into it), and handed them round as prizes.
572
+ There was exactly one a-piece all round.
573
+
574
+ `But she must have a prize herself, you know,' said the Mouse.
575
+
576
+ `Of course,' the Dodo replied very gravely. `What else have
577
+ you got in your pocket?' he went on, turning to Alice.
578
+
579
+ `Only a thimble,' said Alice sadly.
580
+
581
+ `Hand it over here,' said the Dodo.
582
+
583
+ Then they all crowded round her once more, while the Dodo
584
+ solemnly presented the thimble, saying `We beg your acceptance of
585
+ this elegant thimble'; and, when it had finished this short
586
+ speech, they all cheered.
587
+
588
+ Alice thought the whole thing very absurd, but they all looked
589
+ so grave that she did not dare to laugh; and, as she could not
590
+ think of anything to say, she simply bowed, and took the thimble,
591
+ looking as solemn as she could.
592
+
593
+ The next thing was to eat the comfits: this caused some noise
594
+ and confusion, as the large birds complained that they could not
595
+ taste theirs, and the small ones choked and had to be patted on
596
+ the back. However, it was over at last, and they sat down again
597
+ in a ring, and begged the Mouse to tell them something more.
598
+
599
+ `You promised to tell me your history, you know,' said Alice,
600
+ `and why it is you hate--C and D,' she added in a whisper, half
601
+ afraid that it would be offended again.
602
+
603
+ `Mine is a long and a sad tale!' said the Mouse, turning to
604
+ Alice, and sighing.
605
+
606
+ `It IS a long tail, certainly,' said Alice, looking down with
607
+ wonder at the Mouse's tail; `but why do you call it sad?' And
608
+ she kept on puzzling about it while the Mouse was speaking, so
609
+ that her idea of the tale was something like this:--
610
+
611
+ `Fury said to a
612
+ mouse, That he
613
+ met in the
614
+ house,
615
+ "Let us
616
+ both go to
617
+ law: I will
618
+ prosecute
619
+ YOU. --Come,
620
+ I'll take no
621
+ denial; We
622
+ must have a
623
+ trial: For
624
+ really this
625
+ morning I've
626
+ nothing
627
+ to do."
628
+ Said the
629
+ mouse to the
630
+ cur, "Such
631
+ a trial,
632
+ dear Sir,
633
+ With
634
+ no jury
635
+ or judge,
636
+ would be
637
+ wasting
638
+ our
639
+ breath."
640
+ "I'll be
641
+ judge, I'll
642
+ be jury,"
643
+ Said
644
+ cunning
645
+ old Fury:
646
+ "I'll
647
+ try the
648
+ whole
649
+ cause,
650
+ and
651
+ condemn
652
+ you
653
+ to
654
+ death."'
655
+
656
+
657
+ `You are not attending!' said the Mouse to Alice severely.
658
+ `What are you thinking of?'
659
+
660
+ `I beg your pardon,' said Alice very humbly: `you had got to
661
+ the fifth bend, I think?'
662
+
663
+ `I had NOT!' cried the Mouse, sharply and very angrily.
664
+
665
+ `A knot!' said Alice, always ready to make herself useful, and
666
+ looking anxiously about her. `Oh, do let me help to undo it!'
667
+
668
+ `I shall do nothing of the sort,' said the Mouse, getting up
669
+ and walking away. `You insult me by talking such nonsense!'
670
+
671
+ `I didn't mean it!' pleaded poor Alice. `But you're so easily
672
+ offended, you know!'
673
+
674
+ The Mouse only growled in reply.
675
+
676
+ `Please come back and finish your story!' Alice called after
677
+ it; and the others all joined in chorus, `Yes, please do!' but
678
+ the Mouse only shook its head impatiently, and walked a little
679
+ quicker.
680
+
681
+ `What a pity it wouldn't stay!' sighed the Lory, as soon as it
682
+ was quite out of sight; and an old Crab took the opportunity of
683
+ saying to her daughter `Ah, my dear! Let this be a lesson to you
684
+ never to lose YOUR temper!' `Hold your tongue, Ma!' said the
685
+ young Crab, a little snappishly. `You're enough to try the
686
+ patience of an oyster!'
687
+
688
+ `I wish I had our Dinah here, I know I do!' said Alice aloud,
689
+ addressing nobody in particular. `She'd soon fetch it back!'
690
+
691
+ `And who is Dinah, if I might venture to ask the question?'
692
+ said the Lory.
693
+
694
+ Alice replied eagerly, for she was always ready to talk about
695
+ her pet: `Dinah's our cat. And she's such a capital one for
696
+ catching mice you can't think! And oh, I wish you could see her
697
+ after the birds! Why, she'll eat a little bird as soon as look
698
+ at it!'
699
+
700
+ This speech caused a remarkable sensation among the party.
701
+ Some of the birds hurried off at once: one old Magpie began
702
+ wrapping itself up very carefully, remarking, `I really must be
703
+ getting home; the night-air doesn't suit my throat!' and a Canary
704
+ called out in a trembling voice to its children, `Come away, my
705
+ dears! It's high time you were all in bed!' On various pretexts
706
+ they all moved off, and Alice was soon left alone.
707
+
708
+ `I wish I hadn't mentioned Dinah!' she said to herself in a
709
+ melancholy tone. `Nobody seems to like her, down here, and I'm
710
+ sure she's the best cat in the world! Oh, my dear Dinah! I
711
+ wonder if I shall ever see you any more!' And here poor Alice
712
+ began to cry again, for she felt very lonely and low-spirited.
713
+ In a little while, however, she again heard a little pattering of
714
+ footsteps in the distance, and she looked up eagerly, half hoping
715
+ that the Mouse had changed his mind, and was coming back to
716
+ finish his story.
717
+
718
+
719
+
720
+ = CHAPTER IV =
721
+ =( The Rabbit Sends in a Little Bill )=
722
+
723
+
724
+ It was the White Rabbit, trotting slowly back again, and
725
+ looking anxiously about as it went, as if it had lost something;
726
+ and she heard it muttering to itself `The Duchess! The Duchess!
727
+ Oh my dear paws! Oh my fur and whiskers! She'll get me
728
+ executed, as sure as ferrets are ferrets! Where CAN I have
729
+ dropped them, I wonder?' Alice guessed in a moment that it was
730
+ looking for the fan and the pair of white kid gloves, and she
731
+ very good-naturedly began hunting about for them, but they were
732
+ nowhere to be seen--everything seemed to have changed since her
733
+ swim in the pool, and the great hall, with the glass table and
734
+ the little door, had vanished completely.
735
+
736
+ Very soon the Rabbit noticed Alice, as she went hunting about,
737
+ and called out to her in an angry tone, `Why, Mary Ann, what ARE
738
+ you doing out here? Run home this moment, and fetch me a pair of
739
+ gloves and a fan! Quick, now!' And Alice was so much frightened
740
+ that she ran off at once in the direction it pointed to, without
741
+ trying to explain the mistake it had made.
742
+
743
+ `He took me for his housemaid,' she said to herself as she ran.
744
+ `How surprised he'll be when he finds out who I am! But I'd
745
+ better take him his fan and gloves--that is, if I can find them.'
746
+ As she said this, she came upon a neat little house, on the door
747
+ of which was a bright brass plate with the name `W. RABBIT'
748
+ engraved upon it. She went in without knocking, and hurried
749
+ upstairs, in great fear lest she should meet the real Mary Ann,
750
+ and be turned out of the house before she had found the fan and
751
+ gloves.
752
+
753
+ `How queer it seems,' Alice said to herself, `to be going
754
+ messages for a rabbit! I suppose Dinah'll be sending me on
755
+ messages next!' And she began fancying the sort of thing that
756
+ would happen: `"Miss Alice! Come here directly, and get ready
757
+ for your walk!" "Coming in a minute, nurse! But I've got to see
758
+ that the mouse doesn't get out." Only I don't think,' Alice went
759
+ on, `that they'd let Dinah stop in the house if it began ordering
760
+ people about like that!'
761
+
762
+ By this time she had found her way into a tidy little room with
763
+ a table in the window, and on it (as she had hoped) a fan and two
764
+ or three pairs of tiny white kid gloves: she took up the fan and
765
+ a pair of the gloves, and was just going to leave the room, when
766
+ her eye fell upon a little bottle that stood near the looking-
767
+ glass. There was no label this time with the words `DRINK ME,'
768
+ but nevertheless she uncorked it and put it to her lips. `I know
769
+ SOMETHING interesting is sure to happen,' she said to herself,
770
+ `whenever I eat or drink anything; so I'll just see what this
771
+ bottle does. I do hope it'll make me grow large again, for
772
+ really I'm quite tired of being such a tiny little thing!'
773
+
774
+ It did so indeed, and much sooner than she had expected:
775
+ before she had drunk half the bottle, she found her head pressing
776
+ against the ceiling, and had to stoop to save her neck from being
777
+ broken. She hastily put down the bottle, saying to herself
778
+ `That's quite enough--I hope I shan't grow any more--As it is, I
779
+ can't get out at the door--I do wish I hadn't drunk quite so
780
+ much!'
781
+
782
+ Alas! it was too late to wish that! She went on growing, and
783
+ growing, and very soon had to kneel down on the floor: in
784
+ another minute there was not even room for this, and she tried
785
+ the effect of lying down with one elbow against the door, and the
786
+ other arm curled round her head. Still she went on growing, and,
787
+ as a last resource, she put one arm out of the window, and one
788
+ foot up the chimney, and said to herself `Now I can do no more,
789
+ whatever happens. What WILL become of me?'
790
+
791
+ Luckily for Alice, the little magic bottle had now had its full
792
+ effect, and she grew no larger: still it was very uncomfortable,
793
+ and, as there seemed to be no sort of chance of her ever getting
794
+ out of the room again, no wonder she felt unhappy.
795
+
796
+ `It was much pleasanter at home,' thought poor Alice, `when one
797
+ wasn't always growing larger and smaller, and being ordered about
798
+ by mice and rabbits. I almost wish I hadn't gone down that
799
+ rabbit-hole--and yet--and yet--it's rather curious, you know,
800
+ this sort of life! I do wonder what CAN have happened to me!
801
+ When I used to read fairy-tales, I fancied that kind of thing
802
+ never happened, and now here I am in the middle of one! There
803
+ ought to be a book written about me, that there ought! And when
804
+ I grow up, I'll write one--but I'm grown up now,' she added in a
805
+ sorrowful tone; `at least there's no room to grow up any more
806
+ HERE.'
807
+
808
+ `But then,' thought Alice, `shall I NEVER get any older than I
809
+ am now? That'll be a comfort, one way--never to be an old woman--
810
+ but then--always to have lessons to learn! Oh, I shouldn't like THAT!'
811
+
812
+ `Oh, you foolish Alice!' she answered herself. `How can you
813
+ learn lessons in here? Why, there's hardly room for YOU, and no
814
+ room at all for any lesson-books!'
815
+
816
+ And so she went on, taking first one side and then the other,
817
+ and making quite a conversation of it altogether; but after a few
818
+ minutes she heard a voice outside, and stopped to listen.
819
+
820
+ `Mary Ann! Mary Ann!' said the voice. `Fetch me my gloves
821
+ this moment!' Then came a little pattering of feet on the
822
+ stairs. Alice knew it was the Rabbit coming to look for her, and
823
+ she trembled till she shook the house, quite forgetting that she
824
+ was now about a thousand times as large as the Rabbit, and had no
825
+ reason to be afraid of it.
826
+
827
+ Presently the Rabbit came up to the door, and tried to open it;
828
+ but, as the door opened inwards, and Alice's elbow was pressed
829
+ hard against it, that attempt proved a failure. Alice heard it
830
+ say to itself `Then I'll go round and get in at the window.'
831
+
832
+ `THAT you won't' thought Alice, and, after waiting till she
833
+ fancied she heard the Rabbit just under the window, she suddenly
834
+ spread out her hand, and made a snatch in the air. She did not
835
+ get hold of anything, but she heard a little shriek and a fall,
836
+ and a crash of broken glass, from which she concluded that it was
837
+ just possible it had fallen into a cucumber-frame, or something
838
+ of the sort.
839
+
840
+ Next came an angry voice--the Rabbit's--`Pat! Pat! Where are
841
+ you?' And then a voice she had never heard before, `Sure then
842
+ I'm here! Digging for apples, yer honour!'
843
+
844
+ `Digging for apples, indeed!' said the Rabbit angrily. `Here!
845
+ Come and help me out of THIS!' (Sounds of more broken glass.)
846
+
847
+ `Now tell me, Pat, what's that in the window?'
848
+
849
+ `Sure, it's an arm, yer honour!' (He pronounced it `arrum.')
850
+
851
+ `An arm, you goose! Who ever saw one that size? Why, it
852
+ fills the whole window!'
853
+
854
+ `Sure, it does, yer honour: but it's an arm for all that.'
855
+
856
+ `Well, it's got no business there, at any rate: go and take it
857
+ away!'
858
+
859
+ There was a long silence after this, and Alice could only hear
860
+ whispers now and then; such as, `Sure, I don't like it, yer
861
+ honour, at all, at all!' `Do as I tell you, you coward!' and at
862
+ last she spread out her hand again, and made another snatch in
863
+ the air. This time there were TWO little shrieks, and more
864
+ sounds of broken glass. `What a number of cucumber-frames there
865
+ must be!' thought Alice. `I wonder what they'll do next! As for
866
+ pulling me out of the window, I only wish they COULD! I'm sure I
867
+ don't want to stay in here any longer!'
868
+
869
+ She waited for some time without hearing anything more: at
870
+ last came a rumbling of little cartwheels, and the sound of a
871
+ good many voices all talking together: she made out the words:
872
+ `Where's the other ladder?--Why, I hadn't to bring but one;
873
+ Bill's got the other--Bill! fetch it here, lad!--Here, put 'em up
874
+ at this corner--No, tie 'em together first--they don't reach half
875
+ high enough yet--Oh! they'll do well enough; don't be particular--
876
+ Here, Bill! catch hold of this rope--Will the roof bear?--Mind
877
+ that loose slate--Oh, it's coming down! Heads below!' (a loud
878
+ crash)--`Now, who did that?--It was Bill, I fancy--Who's to go
879
+ down the chimney?--Nay, I shan't! YOU do it!--That I won't,
880
+ then!--Bill's to go down--Here, Bill! the master says you're to
881
+ go down the chimney!'
882
+
883
+ `Oh! So Bill's got to come down the chimney, has he?' said
884
+ Alice to herself. `Shy, they seem to put everything upon Bill!
885
+ I wouldn't be in Bill's place for a good deal: this fireplace is
886
+ narrow, to be sure; but I THINK I can kick a little!'
887
+
888
+ She drew her foot as far down the chimney as she could, and
889
+ waited till she heard a little animal (she couldn't guess of what
890
+ sort it was) scratching and scrambling about in the chimney close
891
+ above her: then, saying to herself `This is Bill,' she gave one
892
+ sharp kick, and waited to see what would happen next.
893
+
894
+ The first thing she heard was a general chorus of `There goes
895
+ Bill!' then the Rabbit's voice along--`Catch him, you by the
896
+ hedge!' then silence, and then another confusion of voices--`Hold
897
+ up his head--Brandy now--Don't choke him--How was it, old fellow?
898
+ What happened to you? Tell us all about it!'
899
+
900
+ Last came a little feeble, squeaking voice, (`That's Bill,'
901
+ thought Alice,) `Well, I hardly know--No more, thank ye; I'm
902
+ better now--but I'm a deal too flustered to tell you--all I know
903
+ is, something comes at me like a Jack-in-the-box, and up I goes
904
+ like a sky-rocket!'
905
+
906
+ `So you did, old fellow!' said the others.
907
+
908
+ `We must burn the house down!' said the Rabbit's voice; and
909
+ Alice called out as loud as she could, `If you do. I'll set
910
+ Dinah at you!'
911
+
912
+ There was a dead silence instantly, and Alice thought to
913
+ herself, `I wonder what they WILL do next! If they had any
914
+ sense, they'd take the roof off.' After a minute or two, they
915
+ began moving about again, and Alice heard the Rabbit say, `A
916
+ barrowful will do, to begin with.'
917
+
918
+ `A barrowful of WHAT?' thought Alice; but she had not long to
919
+ doubt, for the next moment a shower of little pebbles came
920
+ rattling in at the window, and some of them hit her in the face.
921
+ `I'll put a stop to this,' she said to herself, and shouted out,
922
+ `You'd better not do that again!' which produced another dead
923
+ silence.
924
+
925
+ Alice noticed with some surprise that the pebbles were all
926
+ turning into little cakes as they lay on the floor, and a bright
927
+ idea came into her head. `If I eat one of these cakes,' she
928
+ thought, `it's sure to make SOME change in my size; and as it
929
+ can't possibly make me larger, it must make me smaller, I
930
+ suppose.'
931
+
932
+ So she swallowed one of the cakes, and was delighted to find
933
+ that she began shrinking directly. As soon as she was small
934
+ enough to get through the door, she ran out of the house, and
935
+ found quite a crowd of little animals and birds waiting outside.
936
+ The poor little Lizard, Bill, was in the middle, being held up by
937
+ two guinea-pigs, who were giving it something out of a bottle.
938
+ They all made a rush at Alice the moment she appeared; but she
939
+ ran off as hard as she could, and soon found herself safe in a
940
+ thick wood.
941
+
942
+ `The first thing I've got to do,' said Alice to herself, as she
943
+ wandered about in the wood, `is to grow to my right size again;
944
+ and the second thing is to find my way into that lovely garden.
945
+ I think that will be the best plan.'
946
+
947
+ It sounded an excellent plan, no doubt, and very neatly and
948
+ simply arranged; the only difficulty was, that she had not the
949
+ smallest idea how to set about it; and while she was peering
950
+ about anxiously among the trees, a little sharp bark just over
951
+ her head made her look up in a great hurry.
952
+
953
+ An enormous puppy was looking down at her with large round
954
+ eyes, and feebly stretching out one paw, trying to touch her.
955
+ `Poor little thing!' said Alice, in a coaxing tone, and she tried
956
+ hard to whistle to it; but she was terribly frightened all the
957
+ time at the thought that it might be hungry, in which case it
958
+ would be very likely to eat her up in spite of all her coaxing.
959
+
960
+ Hardly knowing what she did, she picked up a little bit of
961
+ stick, and held it out to the puppy; whereupon the puppy jumped
962
+ into the air off all its feet at once, with a yelp of delight,
963
+ and rushed at the stick, and made believe to worry it; then Alice
964
+ dodged behind a great thistle, to keep herself from being run
965
+ over; and the moment she appeared on the other side, the puppy
966
+ made another rush at the stick, and tumbled head over heels in
967
+ its hurry to get hold of it; then Alice, thinking it was very
968
+ like having a game of play with a cart-horse, and expecting every
969
+ moment to be trampled under its feet, ran round the thistle
970
+ again; then the puppy began a series of short charges at the
971
+ stick, running a very little way forwards each time and a long
972
+ way back, and barking hoarsely all the while, till at last it sat
973
+ down a good way off, panting, with its tongue hanging out of its
974
+ mouth, and its great eyes half shut.
975
+
976
+ This seemed to Alice a good opportunity for making her escape;
977
+ so she set off at once, and ran till she was quite tired and out
978
+ of breath, and till the puppy's bark sounded quite faint in the
979
+ distance.
980
+
981
+ `And yet what a dear little puppy it was!' said Alice, as she
982
+ leant against a buttercup to rest herself, and fanned herself
983
+ with one of the leaves: `I should have liked teaching it tricks
984
+ very much, if--if I'd only been the right size to do it! Oh
985
+ dear! I'd nearly forgotten that I've got to grow up again! Let
986
+ me see--how IS it to be managed? I suppose I ought to eat or
987
+ drink something or other; but the great question is, what?'
988
+
989
+ The great question certainly was, what? Alice looked all round
990
+ her at the flowers and the blades of grass, but she did not see
991
+ anything that looked like the right thing to eat or drink under
992
+ the circumstances. There was a large mushroom growing near her,
993
+ about the same height as herself; and when she had looked under
994
+ it, and on both sides of it, and behind it, it occurred to her
995
+ that she might as well look and see what was on the top of it.
996
+
997
+ She stretched herself up on tiptoe, and peeped over the edge of
998
+ the mushroom, and her eyes immediately met those of a large
999
+ caterpillar, that was sitting on the top with its arms folded,
1000
+ quietly smoking a long hookah, and taking not the smallest notice
1001
+ of her or of anything else.
1002
+
1003
+
1004
+
1005
+ = CHAPTER V =
1006
+ =( Advice from a Caterpillar )=
1007
+
1008
+
1009
+ The Caterpillar and Alice looked at each other for some time in
1010
+ silence: at last the Caterpillar took the hookah out of its
1011
+ mouth, and addressed her in a languid, sleepy voice.
1012
+
1013
+ `Who are YOU?' said the Caterpillar.
1014
+
1015
+ This was not an encouraging opening for a conversation. Alice
1016
+ replied, rather shyly, `I--I hardly know, sir, just at present--
1017
+ at least I know who I WAS when I got up this morning, but I think
1018
+ I must have been changed several times since then.'
1019
+
1020
+ `What do you mean by that?' said the Caterpillar sternly.
1021
+ `Explain yourself!'
1022
+
1023
+ `I can't explain MYSELF, I'm afraid, sir' said Alice, `because
1024
+ I'm not myself, you see.'
1025
+
1026
+ `I don't see,' said the Caterpillar.
1027
+
1028
+ `I'm afraid I can't put it more clearly,' Alice replied very
1029
+ politely, `for I can't understand it myself to begin with; and
1030
+ being so many different sizes in a day is very confusing.'
1031
+
1032
+ `It isn't,' said the Caterpillar.
1033
+
1034
+ `Well, perhaps you haven't found it so yet,' said Alice; `but
1035
+ when you have to turn into a chrysalis--you will some day, you
1036
+ know--and then after that into a butterfly, I should think you'll
1037
+ feel it a little queer, won't you?'
1038
+
1039
+ `Not a bit,' said the Caterpillar.
1040
+
1041
+ `Well, perhaps your feelings may be different,' said Alice;
1042
+ `all I know is, it would feel very queer to ME.'
1043
+
1044
+ `You!' said the Caterpillar contemptuously. `Who are YOU?'
1045
+
1046
+ Which brought them back again to the beginning of the
1047
+ conversation. Alice felt a little irritated at the Caterpillar's
1048
+ making such VERY short remarks, and she drew herself up and said,
1049
+ very gravely, `I think, you ought to tell me who YOU are, first.'
1050
+
1051
+ `Why?' said the Caterpillar.
1052
+
1053
+ Here was another puzzling question; and as Alice could not
1054
+ think of any good reason, and as the Caterpillar seemed to be in
1055
+ a VERY unpleasant state of mind, she turned away.
1056
+
1057
+ `Come back!' the Caterpillar called after her. `I've something
1058
+ important to say!'
1059
+
1060
+ This sounded promising, certainly: Alice turned and came back
1061
+ again.
1062
+
1063
+ `Keep your temper,' said the Caterpillar.
1064
+
1065
+ `Is that all?' said Alice, swallowing down her anger as well as
1066
+ she could.
1067
+
1068
+ `No,' said the Caterpillar.
1069
+
1070
+ Alice thought she might as well wait, as she had nothing else
1071
+ to do, and perhaps after all it might tell her something worth
1072
+ hearing. For some minutes it puffed away without speaking, but
1073
+ at last it unfolded its arms, took the hookah out of its mouth
1074
+ again, and said, `So you think you're changed, do you?'
1075
+
1076
+ `I'm afraid I am, sir,' said Alice; `I can't remember things as
1077
+ I used--and I don't keep the same size for ten minutes together!'
1078
+
1079
+ `Can't remember WHAT things?' said the Caterpillar.
1080
+
1081
+ `Well, I've tried to say "HOW DOTH THE LITTLE BUSY BEE," but it
1082
+ all came different!' Alice replied in a very melancholy voice.
1083
+
1084
+ `Repeat, "YOU ARE OLD, FATHER WILLIAM,"' said the Caterpillar.
1085
+
1086
+ Alice folded her hands, and began:--
1087
+
1088
+ `You are old, Father William,' the young man said,
1089
+ `And your hair has become very white;
1090
+ And yet you incessantly stand on your head--
1091
+ Do you think, at your age, it is right?'
1092
+
1093
+ `In my youth,' Father William replied to his son,
1094
+ `I feared it might injure the brain;
1095
+ But, now that I'm perfectly sure I have none,
1096
+ Why, I do it again and again.'
1097
+
1098
+ `You are old,' said the youth, `as I mentioned before,
1099
+ And have grown most uncommonly fat;
1100
+ Yet you turned a back-somersault in at the door--
1101
+ Pray, what is the reason of that?'
1102
+
1103
+ `In my youth,' said the sage, as he shook his grey locks,
1104
+ `I kept all my limbs very supple
1105
+ By the use of this ointment--one shilling the box--
1106
+ Allow me to sell you a couple?'
1107
+
1108
+ `You are old,' said the youth, `and your jaws are too weak
1109
+ For anything tougher than suet;
1110
+ Yet you finished the goose, with the bones and the beak--
1111
+ Pray how did you manage to do it?'
1112
+
1113
+ `In my youth,' said his father, `I took to the law,
1114
+ And argued each case with my wife;
1115
+ And the muscular strength, which it gave to my jaw,
1116
+ Has lasted the rest of my life.'
1117
+
1118
+ `You are old,' said the youth, `one would hardly suppose
1119
+ That your eye was as steady as ever;
1120
+ Yet you balanced an eel on the end of your nose--
1121
+ What made you so awfully clever?'
1122
+
1123
+ `I have answered three questions, and that is enough,'
1124
+ Said his father; `don't give yourself airs!
1125
+ Do you think I can listen all day to such stuff?
1126
+ Be off, or I'll kick you down stairs!'
1127
+
1128
+
1129
+ `That is not said right,' said the Caterpillar.
1130
+
1131
+ `Not QUITE right, I'm afraid,' said Alice, timidly; `some of the
1132
+ words have got altered.'
1133
+
1134
+ `It is wrong from beginning to end,' said the Caterpillar
1135
+ decidedly, and there was silence for some minutes.
1136
+
1137
+ The Caterpillar was the first to speak.
1138
+
1139
+ `What size do you want to be?' it asked.
1140
+
1141
+ `Oh, I'm not particular as to size,' Alice hastily replied;
1142
+ `only one doesn't like changing so often, you know.'
1143
+
1144
+ `I DON'T know,' said the Caterpillar.
1145
+
1146
+ Alice said nothing: she had never been so much contradicted in
1147
+ her life before, and she felt that she was losing her temper.
1148
+
1149
+ `Are you content now?' said the Caterpillar.
1150
+
1151
+ `Well, I should like to be a LITTLE larger, sir, if you
1152
+ wouldn't mind,' said Alice: `three inches is such a wretched
1153
+ height to be.'
1154
+
1155
+ `It is a very good height indeed!' said the Caterpillar
1156
+ angrily, rearing itself upright as it spoke (it was exactly three
1157
+ inches high).
1158
+
1159
+ `But I'm not used to it!' pleaded poor Alice in a piteous tone.
1160
+ And she thought of herself, `I wish the creatures wouldn't be so
1161
+ easily offended!'
1162
+
1163
+ `You'll get used to it in time,' said the Caterpillar; and it
1164
+ put the hookah into its mouth and began smoking again.
1165
+
1166
+ This time Alice waited patiently until it chose to speak again.
1167
+ In a minute or two the Caterpillar took the hookah out of its
1168
+ mouth and yawned once or twice, and shook itself. Then it got
1169
+ down off the mushroom, and crawled away in the grass, merely
1170
+ remarking as it went, `One side will make you grow taller, and
1171
+ the other side will make you grow shorter.'
1172
+
1173
+ `One side of WHAT? The other side of WHAT?' thought Alice to
1174
+ herself.
1175
+
1176
+ `Of the mushroom,' said the Caterpillar, just as if she had
1177
+ asked it aloud; and in another moment it was out of sight.
1178
+
1179
+ Alice remained looking thoughtfully at the mushroom for a
1180
+ minute, trying to make out which were the two sides of it; and as
1181
+ it was perfectly round, she found this a very difficult question.
1182
+ However, at last she stretched her arms round it as far as they
1183
+ would go, and broke off a bit of the edge with each hand.
1184
+
1185
+ `And now which is which?' she said to herself, and nibbled a
1186
+ little of the right-hand bit to try the effect: the next moment
1187
+ she felt a violent blow underneath her chin: it had struck her
1188
+ foot!
1189
+
1190
+ She was a good deal frightened by this very sudden change, but
1191
+ she felt that there was no time to be lost, as she was shrinking
1192
+ rapidly; so she set to work at once to eat some of the other bit.
1193
+ Her chin was pressed so closely against her foot, that there was
1194
+ hardly room to open her mouth; but she did it at last, and
1195
+ managed to swallow a morsel of the lefthand bit.
1196
+
1197
+
1198
+ * * * * * * *
1199
+
1200
+ * * * * * *
1201
+
1202
+ * * * * * * *
1203
+
1204
+ `Come, my head's free at last!' said Alice in a tone of
1205
+ delight, which changed into alarm in another moment, when she
1206
+ found that her shoulders were nowhere to be found: all she could
1207
+ see, when she looked down, was an immense length of neck, which
1208
+ seemed to rise like a stalk out of a sea of green leaves that lay
1209
+ far below her.
1210
+
1211
+ `What CAN all that green stuff be?' said Alice. `And where
1212
+ HAVE my shoulders got to? And oh, my poor hands, how is it I
1213
+ can't see you?' She was moving them about as she spoke, but no
1214
+ result seemed to follow, except a little shaking among the
1215
+ distant green leaves.
1216
+
1217
+ As there seemed to be no chance of getting her hands up to her
1218
+ head, she tried to get her head down to them, and was delighted
1219
+ to find that her neck would bend about easily in any direction,
1220
+ like a serpent. She had just succeeded in curving it down into a
1221
+ graceful zigzag, and was going to dive in among the leaves, which
1222
+ she found to be nothing but the tops of the trees under which she
1223
+ had been wandering, when a sharp hiss made her draw back in a
1224
+ hurry: a large pigeon had flown into her face, and was beating
1225
+ her violently with its wings.
1226
+
1227
+ `Serpent!' screamed the Pigeon.
1228
+
1229
+ `I'm NOT a serpent!' said Alice indignantly. `Let me alone!'
1230
+
1231
+ `Serpent, I say again!' repeated the Pigeon, but in a more
1232
+ subdued tone, and added with a kind of sob, `I've tried every
1233
+ way, and nothing seems to suit them!'
1234
+
1235
+ `I haven't the least idea what you're talking about,' said
1236
+ Alice.
1237
+
1238
+ `I've tried the roots of trees, and I've tried banks, and I've
1239
+ tried hedges,' the Pigeon went on, without attending to her; `but
1240
+ those serpents! There's no pleasing them!'
1241
+
1242
+ Alice was more and more puzzled, but she thought there was no
1243
+ use in saying anything more till the Pigeon had finished.
1244
+
1245
+ `As if it wasn't trouble enough hatching the eggs,' said the
1246
+ Pigeon; `but I must be on the look-out for serpents night and
1247
+ day! Why, I haven't had a wink of sleep these three weeks!'
1248
+
1249
+ `I'm very sorry you've been annoyed,' said Alice, who was
1250
+ beginning to see its meaning.
1251
+
1252
+ `And just as I'd taken the highest tree in the wood,' continued
1253
+ the Pigeon, raising its voice to a shriek, `and just as I was
1254
+ thinking I should be free of them at last, they must needs come
1255
+ wriggling down from the sky! Ugh, Serpent!'
1256
+
1257
+ `But I'm NOT a serpent, I tell you!' said Alice. `I'm a--I'm
1258
+ a--'
1259
+
1260
+ `Well! WHAT are you?' said the Pigeon. `I can see you're
1261
+ trying to invent something!'
1262
+
1263
+ `I--I'm a little girl,' said Alice, rather doubtfully, as she
1264
+ remembered the number of changes she had gone through that day.
1265
+
1266
+ `A likely story indeed!' said the Pigeon in a tone of the
1267
+ deepest contempt. `I've seen a good many little girls in my
1268
+ time, but never ONE with such a neck as that! No, no! You're a
1269
+ serpent; and there's no use denying it. I suppose you'll be
1270
+ telling me next that you never tasted an egg!'
1271
+
1272
+ `I HAVE tasted eggs, certainly,' said Alice, who was a very
1273
+ truthful child; `but little girls eat eggs quite as much as
1274
+ serpents do, you know.'
1275
+
1276
+ `I don't believe it,' said the Pigeon; `but if they do, why
1277
+ then they're a kind of serpent, that's all I can say.'
1278
+
1279
+ This was such a new idea to Alice, that she was quite silent
1280
+ for a minute or two, which gave the Pigeon the opportunity of
1281
+ adding, `You're looking for eggs, I know THAT well enough; and
1282
+ what does it matter to me whether you're a little girl or a
1283
+ serpent?'
1284
+
1285
+ `It matters a good deal to ME,' said Alice hastily; `but I'm
1286
+ not looking for eggs, as it happens; and if I was, I shouldn't
1287
+ want YOURS: I don't like them raw.'
1288
+
1289
+ `Well, be off, then!' said the Pigeon in a sulky tone, as it
1290
+ settled down again into its nest. Alice crouched down among the
1291
+ trees as well as she could, for her neck kept getting entangled
1292
+ among the branches, and every now and then she had to stop and
1293
+ untwist it. After a while she remembered that she still held the
1294
+ pieces of mushroom in her hands, and she set to work very
1295
+ carefully, nibbling first at one and then at the other, and
1296
+ growing sometimes taller and sometimes shorter, until she had
1297
+ succeeded in bringing herself down to her usual height.
1298
+
1299
+ It was so long since she had been anything near the right size,
1300
+ that it felt quite strange at first; but she got used to it in a
1301
+ few minutes, and began talking to herself, as usual. `Come,
1302
+ there's half my plan done now! How puzzling all these changes
1303
+ are! I'm never sure what I'm going to be, from one minute to
1304
+ another! However, I've got back to my right size: the next
1305
+ thing is, to get into that beautiful garden--how IS that to be
1306
+ done, I wonder?' As she said this, she came suddenly upon an
1307
+ open place, with a little house in it about four feet high.
1308
+ `Whoever lives there,' thought Alice, `it'll never do to come
1309
+ upon them THIS size: why, I should frighten them out of their
1310
+ wits!' So she began nibbling at the righthand bit again, and did
1311
+ not venture to go near the house till she had brought herself
1312
+ down to nine inches high.
modules/__init__.py ADDED
File without changes
modules/abstractive.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
3
+
4
+
5
+ def load_summarizers():
6
+ models = {
7
+ "Pegasus": "google/pegasus-large",
8
+ "T5": "Overglitch/t5-small-cnn-dailymail",
9
+ "BART": "facebook/bart-large-cnn",
10
+ }
11
+ summarizers = {}
12
+ for model_name, model_path in models.items():
13
+ model = AutoModelForSeq2SeqLM.from_pretrained(model_path).to("cuda" if torch.cuda.is_available() else "cpu")
14
+ tokenizer = AutoTokenizer.from_pretrained(model_path)
15
+ summarizers[model_name] = (model, tokenizer)
16
+ return summarizers
17
+
18
+
19
+ def abstractive_summary(summarizers, model_name, text, max_length, num_beams):
20
+ model, tokenizer = summarizers[model_name]
21
+ inputs = tokenizer(
22
+ text, return_tensors="pt", max_length=512, truncation=True
23
+ ).to(model.device)
24
+ outputs = model.generate(
25
+ inputs["input_ids"],
26
+ max_length=max_length,
27
+ num_beams=num_beams,
28
+ early_stopping=True,
29
+ )
30
+ return tokenizer.decode(outputs[0], skip_special_tokens=True)
modules/extractive.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ from sklearn.feature_extraction.text import TfidfVectorizer
3
+ from sklearn.metrics.pairwise import cosine_similarity
4
+ from summarizer import Summarizer
5
+ import networkx as nx
6
+
7
+
8
+ class TFIDFSummarizer:
9
+ @staticmethod
10
+ def summarize(sentences, preprocessed_sentences, num_sentences):
11
+ vectorizer = TfidfVectorizer()
12
+ tfidf_matrix = vectorizer.fit_transform(preprocessed_sentences)
13
+ scores = np.sum(tfidf_matrix.toarray(), axis=1)
14
+ ranked_indices = np.argsort(scores)[::-1]
15
+ return " ".join([sentences[i] for i in ranked_indices[:num_sentences]])
16
+
17
+
18
+ class TextRankSummarizer:
19
+ @staticmethod
20
+ def summarize(sentences, preprocessed_sentences, num_sentences):
21
+ vectorizer = TfidfVectorizer()
22
+ tfidf_matrix = vectorizer.fit_transform(preprocessed_sentences)
23
+ similarity_matrix = cosine_similarity(tfidf_matrix)
24
+ nx_graph = nx.from_numpy_array(similarity_matrix)
25
+ scores = nx.pagerank(nx_graph)
26
+ ranked_indices = sorted(scores, key=scores.get, reverse=True)
27
+ return " ".join([sentences[i] for i in ranked_indices[:num_sentences]])
28
+
29
+
30
+ class CombinedSummarizer:
31
+ @staticmethod
32
+ def summarize(sentences, preprocessed_sentences, num_sentences):
33
+ tfidf_summary = TFIDFSummarizer.summarize(
34
+ sentences, preprocessed_sentences, num_sentences
35
+ )
36
+ textrank_summary = TextRankSummarizer.summarize(
37
+ sentences, preprocessed_sentences, num_sentences
38
+ )
39
+ return f"{tfidf_summary} {textrank_summary}"
40
+
41
+
42
+ class BERTSummarizer:
43
+ def __init__(self):
44
+ self.model = Summarizer()
45
+
46
+ def summarize(self, text, num_sentences):
47
+ return self.model(text, num_sentences=num_sentences)
modules/preprocessing.py ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import re
3
+ import shutil
4
+ import time
5
+ from pathlib import Path
6
+ from datetime import date
7
+ from cleantext import clean
8
+ from doctr.io import DocumentFile
9
+ from doctr.models import ocr_predictor
10
+ from spellchecker import SpellChecker
11
+ import nltk
12
+
13
+ nltk.download('punkt')
14
+
15
+
16
+ class Preprocessor:
17
+ """Clase para preprocesar texto, realizar limpieza y correcciones."""
18
+
19
+ def __init__(self):
20
+ self.spell_checker = SpellChecker()
21
+
22
+ @staticmethod
23
+ def clean_text(text: str, lower: bool = False, lang: str = "en") -> str:
24
+ """
25
+ Limpia texto de ruido y caracteres no deseados.
26
+ """
27
+ return clean(
28
+ text,
29
+ fix_unicode=True,
30
+ to_ascii=True,
31
+ lower=lower,
32
+ no_line_breaks=True,
33
+ no_urls=True,
34
+ no_emails=True,
35
+ no_phone_numbers=True,
36
+ no_numbers=False,
37
+ no_digits=False,
38
+ no_currency_symbols=True,
39
+ no_punct=False,
40
+ lang=lang,
41
+ )
42
+
43
+ @staticmethod
44
+ def correct_spacing(text: str, exceptions=None) -> str:
45
+ """
46
+ Corrige espacios alrededor de signos de puntuación y excepciones.
47
+ """
48
+ if exceptions is None:
49
+ exceptions = ["e.g.", "i.e.", "etc.", "cf.", "vs.", "p."]
50
+
51
+ text = re.sub(r"\s+", " ", text)
52
+ text = re.sub(r'\s([?.!"](?:\s|$))', r"\1", text)
53
+ text = re.sub(r"\s,", r",", text)
54
+
55
+ for exception in exceptions:
56
+ text = text.replace(" ".join(exception.split()), exception)
57
+
58
+ return text.strip()
59
+
60
+ @staticmethod
61
+ def split_into_sentences(text: str) -> list:
62
+ """
63
+ Divide texto en oraciones usando NLTK.
64
+ """
65
+ from nltk.tokenize import sent_tokenize
66
+ return sent_tokenize(text)
67
+
68
+ def correct_spelling(self, text: str) -> str:
69
+ """
70
+ Corrige la ortografía del texto dado.
71
+ """
72
+ words = text.split()
73
+ corrected_words = [self.spell_checker.correction(word) for word in words]
74
+ return " ".join(corrected_words)
75
+
76
+ def preprocess_text(self, text: str) -> str:
77
+ """
78
+ Limpia, corrige ortografía y ajusta espacios en texto.
79
+ """
80
+ cleaned = self.clean_text(text)
81
+ corrected = self.correct_spelling(cleaned)
82
+ return self.correct_spacing(corrected)
83
+
84
+
85
+ class PDFProcessor:
86
+ """Clase para procesar archivos PDF y convertirlos a texto."""
87
+
88
+ def __init__(self, max_pages=20):
89
+ self.ocr_model = ocr_predictor(pretrained=True)
90
+ self.max_pages = max_pages
91
+
92
+ def pdf_to_text(self, file_path: str) -> str:
93
+ """
94
+ Convierte un archivo PDF a texto usando OCR.
95
+ """
96
+ pdf_file = Path(file_path)
97
+ doc = DocumentFile.from_pdf(pdf_file)
98
+ if len(doc.pages) > self.max_pages:
99
+ doc.pages = doc.pages[:self.max_pages]
100
+
101
+ result = self.ocr_model(doc)
102
+ raw_text = "\n".join(
103
+ [block.text for page in result.pages for block in page.blocks]
104
+ )
105
+ return Preprocessor().preprocess_text(raw_text)
106
+
107
+
108
+ class FileHandler:
109
+ """Clase para manejar archivos temporales y limpieza."""
110
+
111
+ @staticmethod
112
+ def save_temp_file(file_obj, temp_dir: Path = None) -> str:
113
+ """
114
+ Guarda un archivo temporalmente y retorna su ruta.
115
+ """
116
+ if temp_dir is None:
117
+ temp_dir = Path("temp")
118
+ temp_dir.mkdir(exist_ok=True)
119
+
120
+ file_path = Path(file_obj.name)
121
+ temp_path = temp_dir / file_path.name
122
+
123
+ with open(temp_path, "wb") as f:
124
+ f.write(file_obj.read())
125
+ return str(temp_path.resolve())
126
+
127
+ @staticmethod
128
+ def clear_temp_files(directory="temp", name_contains="RESULT_"):
129
+ """
130
+ Limpia archivos temporales en el directorio especificado.
131
+ """
132
+ temp_dir = Path(directory)
133
+ if not temp_dir.exists():
134
+ return
135
+
136
+ for file in temp_dir.iterdir():
137
+ if file.is_file() and name_contains in file.name:
138
+ file.unlink()
139
+
140
+ @staticmethod
141
+ def move_to_completed(from_dir: Path, filename: str, completed_dir="completed"):
142
+ """
143
+ Mueve un archivo procesado a la carpeta 'completed'.
144
+ """
145
+ completed_path = from_dir / completed_dir
146
+ completed_path.mkdir(exist_ok=True)
147
+ shutil.move(from_dir / filename, completed_path / filename)
modules/utils.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ def handle_long_text(text, model, tokenizer, max_length=2048, stride=128):
2
+ encoded_input = tokenizer(
3
+ text,
4
+ max_length=max_length,
5
+ stride=stride,
6
+ truncation=True,
7
+ return_overflowing_tokens=True,
8
+ return_tensors="pt",
9
+ )
10
+ summaries = []
11
+ for input_ids, attention_mask in zip(
12
+ encoded_input.input_ids, encoded_input.attention_mask
13
+ ):
14
+ output = model.generate(
15
+ input_ids.to(model.device),
16
+ attention_mask=attention_mask.to(model.device),
17
+ max_length=128,
18
+ num_beams=4,
19
+ )
20
+ summaries.append(tokenizer.decode(output[0], skip_special_tokens=True))
21
+ return " ".join(summaries)