Merge pull request 'Лабораторная работа 7' (#239) from orlov_artem_lab_7 into main

Reviewed-on: http://student.git.athene.tech/Alexey/IIS_2023_1/pulls/239
This commit is contained in:
Alexey 2023-12-07 16:22:14 +04:00
commit 5edaf776e8
4 changed files with 805 additions and 0 deletions

84
orlov_artem_lab_7/app.py Normal file
View File

@ -0,0 +1,84 @@
import numpy as np
import tensorflow as tf
from keras.models import Sequential
from keras.layers import Embedding, LSTM, Dense
from flask import Flask, request, jsonify, render_template
# Загрузка и предобработка данных
with open('your_text_file.txt', 'r', encoding='utf-8') as file:
text = file.read()
# Создание словаря символов
chars = sorted(list(set(text)))
char_to_idx = {char: idx for idx, char in enumerate(chars)}
idx_to_char = {idx: char for idx, char in enumerate(chars)}
# Подготовка данных для обучения
seq_length = 100
step = 3
sequences = []
next_chars = []
for i in range(0, len(text) - seq_length, step):
seq = text[i:i+seq_length]
target = text[i+seq_length]
sequences.append(seq)
next_chars.append(target)
# Преобразование данных в числовой формат
X = np.zeros((len(sequences), seq_length, len(chars)), dtype=bool)
y = np.zeros((len(sequences), len(chars)), dtype=bool)
for i, seq in enumerate(sequences):
for t, char in enumerate(seq):
X[i, t, char_to_idx[char]] = 1
y[i, char_to_idx[next_chars[i]]] = 1
# Построение более сложной модели
model = Sequential([
LSTM(256, input_shape=(seq_length, len(chars)), return_sequences=True),
LSTM(256),
Dense(len(chars), activation='softmax')
])
model.compile(optimizer='adam', loss='categorical_crossentropy')
# Увеличение количества эпох обучения
model.fit(X, y, epochs=100, batch_size=128)
# Функция для генерации текста с параметром температуры
def generate_text(seed_text, model, length=100, temperature=1.0):
generated_text = seed_text
for _ in range(length):
x = np.zeros((1, seq_length, len(chars)))
for t, char in enumerate(seed_text):
x[0, t, char_to_idx[char]] = 1
preds = model.predict(x, verbose=0)[0]
preds = np.log(preds) / temperature
exp_preds = np.exp(preds)
preds = exp_preds / np.sum(exp_preds)
next_index = np.random.choice(len(chars), p=preds)
next_char = idx_to_char[next_index]
generated_text += next_char
seed_text = seed_text[1:] + next_char
return generated_text
# Создание Flask-приложения
app = Flask(__name__)
# Эндпоинт для генерации текста
@app.route('/')
def index():
return render_template('index.html')
# Эндпоинт для генерации текста
@app.route('/generate_text', methods=['POST'])
def generate_text_endpoint():
data = request.get_json()
seed_text = data.get('seed_text', '')
generated_text = generate_text(seed_text, model)
return jsonify({'generated_text': generated_text})
# Запуск Flask-сервера
if __name__ == '__main__':
app.run(port=5000)

View File

@ -0,0 +1,29 @@
Общее задание:
Выбрать художественный текст (четные варианты русскоязычный, нечетные англоязычный) и обучить на нем рекуррентную нейронную сеть
для решения задачи генерации. Подобрать архитектуру и параметры так,чтобы приблизиться к максимально осмысленному результату. Далее
разбиться на пары четный-нечетный вариант, обменяться разработанными сетями и проверить, как архитектура товарища справляется с вашим текстом. В завершении подобрать компромиссную архитектуру, справляющуюся достаточно хорошо с обоими видами текстов.
Задание по вариантам:
нечетный вариант, художественным текстом был выбран фрагмент произведения "The Adventures of Tom Sawyer"
Запуск приложения: запуск файла app.py
Использованные технологии:
Python: Язык программирования, на котором написан код.
TensorFlow и Keras: Фреймворки для создания и обучения нейронных сетей.
Flask: Фреймворк для создания веб-сервисов на языке Python.
Описание работы программы:
Программа обучает рекуррентную нейронную сеть (RNN) на художественном англоязычный тексте из файла.
Веб-сервис Flask создается для обработки запросов на генерацию текста на основе введенного начального текста.
Пользователь вводит начальный текст в веб-интерфейсе, нажимает кнопку "Generate Text".
Введенный текст передается через HTTP POST-запрос на сервер Flask.
Сервер использует обученную RNN-модель для генерации продолжения текста и возвращает результат обратно в веб-интерфейс.
Пример входных данных:
Adventures
Пример выходных данных:
Adventures ti;ir ocsvvvy eslv;:ev, n nshe gv'ekvpr'g ey'vlat.tr-v:l eivee s ekgg d seovnve., ts kln

View File

@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>RNN Text Generation</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
margin: 50px;
}
#output {
margin-top: 20px;
}
</style>
</head>
<body>
<h1>RNN Text Generation</h1>
<label for="seed_text">Seed Text:</label>
<input type="text" id="seed_text" placeholder="Enter your seed text">
<button onclick="generateText()">Generate Text</button>
<div id="output"></div>
<script>
function generateText() {
const seedText = document.getElementById("seed_text").value;
fetch('http://127.0.0.1:5000/generate_text', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ seed_text: seedText }),
})
.then(response => response.json())
.then(data => {
document.getElementById("output").innerText = data.generated_text;
})
.catch(error => {
console.error('Error:', error);
});
}
</script>
</body>
</html>

View File

@ -0,0 +1,646 @@
The Adventures of
Tom Sawyer
MARK TWAIN
Level 1
Retold by Jacqueline Kehl
Series Editors: Andy Hopkins and Jocelyn Potter
Pearson Education Limited
Edinburgh Gate, Harlow,
Essex CM20 2JE, England
and Associated Companies throughout the world.
ISBN 0 582 41923 9
First published 1876
Published by Puffin Books 1950
This edition first published 2000
Copyright © Penguin Books 2000
Typeset by Digital Type, London
Set in 12/14ptBembo
Printed in Spain by Mateu Cromo, S. A. Pinto (Madrid)
All rights reserved; no part of this publication may be reproduced, stored
in a retrieval system, or transmitted in any form or by any means,
electronic, mechanical, photocopying, recording or otherwise, without the
prior written permission of the Publishers.
Published by Pearson Education Limited in association with Penguin Books Ltd, both
companies being subsidiaries of Pearson Plc
For a complete list of the titles available in the Penguin Readers series please write to your
local Pearson Education office or to: Marketing Department, Penguin Longman Publishing,
5 Bentinck Street, London W1M 5R.N.
Introduction
One Saturday afternoon Tom wanted to have an adventure
because he didnt want to think about Injun Joe. He went
to Huck and said, “Im going to look for treasure. Do you
want to come with me?”
Tom Sawyer loves adventures. He has a lot of adventures
at home, at school, and with his friends. He has one
adventure in a cave. But why is he there? What does he
see in the cave? And why is he afraid?
Mark Twain (1835-1910) is a famous American writer.
His name was Samuel Clemens. Young Samuel lived in
Hannibal, Missouri, a small town on the Mississippi River.
He loved the river and he liked watching the big boats
on it.
Samuel loved adventures. He worked on boats on the
Mississippi River for two years. Then he went to Nevada.
He looked for treasure, but he didnt find it. He worked for
a newspaper there. His stories were in the name of Mark
Twain, and people loved them.
Later, Samuel lived in New York. His book The
Adventures of Tom Sawyer (1876) is about a young boy in
a small town in the 1800s. Huck Finn is his friend. The
Adventures of Huckleberry Finn (1884) is about Hucks
adventures. These two books are very famous.
Today, many people visit Hannibal because they want to
see Mark Twains home and the Mark Twain Cave, the
cave in The Adventures of Tom Sawyer.
iii
Chapter 1 The Fence
Tom Sawyer lived with his aunt because his mother and
father were dead. Tom didnt like going to school, and he
didnt like working. He liked playing and having
adventures. One Friday, he didnt go to school—he went
to the river.
Aunt Polly was angry. “Youre a bad boy!” she said.
“Tomorrow you cant play with your friends because you
didnt go to school today. Tomorrow youre going to work
for me. You can paint the fence.”
Saturday morning, Tom was not happy, but he started to
paint the fence. His friend Jim was in the street.
Tom asked him, “Do you want to paint?”
Jim said, “No, I cant. Im going to get water.”
Then Ben came to Toms house. He watched Tom and
said, “Im going to swim today. You cant swim because
youre working.”
Tom said, “This isnt work. I like painting.”
“Can I paint, too?” Ben asked.
“No, you cant,” Tom answered. “Aunt Polly asked me
because Im a very good painter.”
Ben said, “Im a good painter, too. Please, can I paint? I
have some fruit. Do you want it?”
OK,” Tom said. “Give me the fruit. Then you can paint.”
Ben started to paint the fence. Later, many boys came to
Toms house. They watched Ben, and they wanted to
paint, too.
Tom said, “Give me some food and you can paint.”
1
Tom stayed in the yard, and the boys painted.
Tom stayed in the yard, and the boys painted. They
painted the fence three times. It was beautiful and white.
Tom went into the house. “Aunt Polly, can I play now?”
he asked.
Aunt Polly was surprised. “Did you paint the fence?”
she asked.
“Yes, I did,” Tom answered.
Aunt Polly went to the yard and looked at the fence. She
was very surprised and very happy. “Its beautiful!” she
said. “Yes, you can play now.”
Tom walked to his friend Joe Harpers house and played
with his friends there. Then he walked home again. There
was a new girl in one yard. She had yellow hair and blue
eyes. She was beautiful. Tom wanted to talk to her, but she
didnt see him. She went into her house. Tom waited, but
she didnt come out again.
Chapter 2 In the Graveyard
One morning before school, Toms friend Huck Finn
waited for him in the street. Huck didnt have a home, and
he never went to school. People in the town didnt like
him. But Tom liked Huck.
Huck said, “Lets have an adventure.”
“What can we do on our adventure?” Tom asked.
“Lets go to the graveyard at night—at twelve oclock!”
Huck answered.
Thats a good adventure,” Tom said. “Lets meet at
eleven oclock.”
Then Tom went to school, but he was late. The teacher
was angry. He asked, “Why are you late again?”
3
“Im late because I talked to Huck Finn,” Tom said.
Then the teacher was very angry. “Sit with the girls,” he
said to Tom.
Tom sat near the beautiful new girl. He was happy. He
looked at her.
“Whats your name?” he asked.
“Becky,” she answered.
Tom smiled and said, “My names Tom.”
The teacher was angry again. “Tom Sawyer, stop
talking! Go to your place now,” he said. Tom went to his
place.
At twelve oclock Tom and Becky didnt go home. They
stayed in the school yard and talked. Tom said, “I love
you. Do you love me?”
“Yes,” Becky answered.
“Good,” Tom said. “Then youre going to walk to
school with me every day. Amy always walked with me.”
“Amy!” Becky said angrily. “Do you love her?”
“No,” Tom answered. “I love you now. Do you want to
walk with me?”
But Becky was angry with Tom. She walked away and
didnt answer. Tom was unhappy. He didnt go to school
in the afternoon.
That night Tom went to bed at nine oclock, but he
didnt sleep. At eleven oclock he went out his bedroom
window to the yard. Huck was there. They walked to the
graveyard. They stopped behind some big trees and talked
quietly.
Suddenly, there was a noise. Three men came into the
graveyard—the doctor, Muff Potter, and Injun Joe. Injun
Joe and the doctor talked angrily. Then Injun Joe
Then Injun Joe killed the doctor with a knife.
killed the doctor with a knife. Tom and Huck watched.
Then they went away quickly because they were afraid.
They went to Toms yard. Huck said, “We cant talk
about this. Injun Joe can find us and kill us, too.”
“Thats right,” Tom said. “We cant talk about it.”
Tom went in his bedroom window. He went to bed, but
he didnt sleep well. Tom and Huck didnt talk to their
friends or Aunt Polly about that night because they were
afraid of Injun Joe.
Later, some men went to Muff Potter and said, “Youre
a bad man. You killed the doctor.”
Chapter 3 A Bad Day
Becky was sick and didnt go to school for many days.
Tom was very sad. One morning, he said to Aunt Polly,
“Im very sick, and I want to stay home from school.”
Aunt Polly said, “Heres some medicine. Take this and
you can get well quickly.”
But Tom didnt like the medicine. Peter, the cat, came
into the room and looked at Tom.
“Peter!” Tom said. ”Have some medicine!”
Peter had some medicine. He didnt like it! He went
quickly out the open window and into the yard.
Aunt Polly watched Peter. “Why did you do that, Tom?”
she asked angrily. “Youre a very bad boy! Go to school
now.”
Tom arrived at school early and he waited for Becky at
the school fence. She arrived early, too, but she didnt
6
Peter had some medicine. He didnt like it!
look at Tom. She went into school. Tom walked away. He
didnt want to go to school now. He was very sad.
Joe Harper was near the school. He was sad, too,
because his mother was angry with him. The two boys
walked and talked.
Tom said, “Lets run away.”
“Yes, lets!” Joe said.
The two boys went to the river. Huck Finn was there.
Tom and Joe said, “Were going to run away. Do you
want to come with us?”
“Yes,” Huck answered. “Lets go across the river. We
can have a good adventure there.”
The boys went home because they wanted to get food
for their adventure.
Chapter 4 Across the River
Tom, Joe, and Huck went to the river. There was a small
boat there. The boys went across the river in the small
boat. They said, “This is a good place because we can play
all day. Theres no school here.”
They played and then went to sleep.
In the morning, the boys were happy again. They said,
“Lets stay here for a long time.”
In the afternoon, they played near the river again.
Suddenly, there was a noise from a big boat on the river.
The boys stopped playing and watched the boat.
“Listen,” Tom said. “The men on the boat are talking
about us.”
8
The boys stopped playing and watched the boat.
The boys listened quietly. A man said, “The boys are in
the river. Theyre dead.”
Tom said, “Those men are looking for us in the river.
Were here, but they dont know that.”
That night, the boys were sad. Huck and Joe went to
sleep, but Tom didnt sleep. He went home in the small
boat. He quietly went in his bedroom window. Then he
went under his bed and stayed there.
Aunt Polly and her friends came into his room. Aunt
Polly said to her friends, “Tom was a good boy, and I
loved him. Now hes dead, and Im very sad.”
Tom wanted to say, “Im not dead.” But he stayed quiet.
Aunt Polly went to sleep. Tom went out the window
very quietly and went back across the river.
In the morning, Joe and Huck said, “Were not happy
here now. We want to go home.”
Tom said, “Lets go home on Sunday. We can go to
church. People are going to be very surprised!”
Sunday morning, many children were at church. They
talked about the three boys. They were sad because their
friends were dead. Becky was sad, too.
Suddenly, the three boys walked into the church. People
were very surprised, but they were very happy, too.
Chapter 5 At School
Monday morning, Tom went to school. The children
wanted to hear about his adventure, and Tom liked
10
talking about it. Becky wanted to talk to Tom, but he
didnt look at her.
Then Tom talked to Amy. Becky watched him and she
was angry. She said to her friends, “Im going to have an
adventure day. You can come on my adventure.” But she
didnt ask Tom.
Later in the morning, Tom talked to Amy again. Becky
talked to her friend Alfred and looked at a picture-book
with him. Tom watched them and he was angry with
Becky.
In the afternoon, Tom waited for Becky at the school
fence. He said, “Im sorry.”
But Becky didnt listen to him. She walked into the
school room. The teachers new book was on his table.
This book wasnt for children, but Becky wanted to look
at it. She opened the book quietly and looked at the
pictures.
Suddenly, Tom came into the room. Becky was
surprised. She closed the book quickly, and it tore. Becky
was angry with Tom and quickly went out of the room.
Then the children and the teacher came into the room
and went to their places. The teacher looked at his book.
“Who did this? Who tore my book?” he asked angrily.
The room was very quiet. The teacher started to ask
every child, “Did you do this?”
They answered, “No, I didnt.”
Then he looked at Becky “Becky, did you do this?”
11
“I did it. I tore your book.”
Tom wanted to help her. Suddenly he said, “I did it. I
tore your book.”
“Tom Sawyer, youre a very bad boy. Stay here after
school!” the teacher said angrily.
At five oclock Tom started to walk home. Becky waited
for him at the school fence. “Youre a very good friend,”
she said.
Tom smiled at her and they walked home.
Chapter 6 The Trial
Summer vacation started, and Becky went away with her
family. Tom was unhappy.
Then Muff Potters trial started. Tom and Huck
remembered the night in the graveyard. They were afraid
of Injun Joe again.
“Did you talk about the night in the graveyard?”
Tom asked Huck.
“No, I didnt,” Huck answered. “Did you?”
“No,” Tom answered. “But. Im sorry about Muff Potter.
Hes always friendly to us. He didnt kill the doctor. I
want to help him.”
“Lets take some food to him,” Huck said.
The boys visited Muff Potter. “Heres some food,” they
said.
Muff Potter said, “Thank you. Youre good boys.”
Tom and Huck went to the trial and listened for two
days. Tom didnt sleep well at night because he wanted to
help Muff Potter.
On day three of the trial Tom talked.
13
A man asked him, “Where were you on the night of
June 17th?”
“I was in the graveyard,” Tom answered.
“Did you see any people there?” the man asked:
“Yes. Injun Joe, the doctor, and Muff Potter were there.
They didnt see me because I was behind some big trees.”
“What did you see?” the man asked.
“Injun Joe and the doctor talked angrily,” Tom
answered. “Then Injun Joe killed the doctor with his knife.
Muff Potter didnt do it.”
The people at the trial were surprised. Injun Joe quickly
went out of the building.
Tom and Huck were very afraid. Tom said, “Now Injun
Joe knows about us. He can kill us, too.”
Many people wanted to hear about the boys adventure
in the graveyard. Tom liked talking about it. He was
happy, too, because he helped Muff Potter. But he didnt
sleep well because he was afraid of Injun Joe.
Chapter 7 Injun Joes Treasure
One Saturday afternoon, Tom wanted to have an adventure
because he didnt want to think about Injun Joe. He went
to Huck and said, “Im going to look for treasure. Do you
want to come with me?”
Huck always liked an adventure. “Oh, yes,” he said.
“Where can we look?”
14
“Lets start looking in the old house near Mrs. Douglass
house. Old houses are good places for treasure,” Tom
answered.
The boys went to the old house. They wanted to look at
every room. First they went into the kitchen, and then they
went into the bedroom.
Suddenly, two men came into the kitchen—Injun Joe
and his friend. The boys were afraid and stayed in the
bedroom very quietly.
Injun Joe walked across the kitchen. “We can put our
money here,” he said to his friend.
He started to dig under the floor with his knife.
“Whats this?” Injun Joe said. “Im going to get it out.”
There was a big box under the floor. He opened it with
his knife. There was a lot of money in the box.
“Look at that money!” his friend said. “Lets go now.
We can come back and get it tomorrow.”
“No,” Injun Joe said. “Were going to take it with us
now. We can take it to that place. You know—the place
under the cross.”
Then the men went out of the house. Injun Joe talked
quietly to his friend. The boys listened and were afraid.
Tom said, “Did you hear that? He wants to kill us.”
They went out of the house quietly and went home.
The boys were afraid of Injun Joe, but they wanted to
find his treasure. They watched his house every night, but
they didnt see Injun Joe or his treasure.
15
There was a lot of money in the box.
Chapter 8 Beckys Adventure Day
In August Beckys family came back from their vacation.
Tom was very happy and he didnt think about Injun Joes
treasure.
Beckys adventure day was Saturday. Her mother said,
“You can sleep at Susy Harpers house after your
adventure.
“Good,” Becky said.
Becky and her friends went on the river on a big boat.
The boat went down the river and across it. Then it
stopped. The children went out of the boat and played
games near the river. In the afternoon one boy asked,
“Who wants to go to the big cave?”
The children went to the cave. It was dark and cold
there, but they played games. In the evening they went
back to the boat and went home.
Sunday morning, Beckys mother and Aunt Polly talked
to Mrs. Harper at church. Beckys mother asked, “Wheres
my Becky? Did she sleep at your house?”
“No, she didnt,” Mrs. Harper answered. “I didnt see
her.”
Aunt Polly said, “My Tom didnt come home. Did he
stay at your house?”
“No, he didnt,” Mrs. Harper answered.
Then Aunt Polly and Beckys mother asked the children,
“Did Tom and Becky come home? Did you see them on
the boat?”
The children answered, “No, we didnt see them, but it
was dark.”
Then a boy said, “Maybe theyre in the cave!”
17
Two hundred men looked for Tom and Becky in the
cave. They looked for three days, but they didnt find
them. People in the town were very sad.
Chapter 9 Hucks Adventure
Huck didnt go on Beckys adventure. He stayed home
and watched Injun Joes house that night. At eleven
oclock Injun Joe and his friend came out and walked
down the street. There was a box in his friends hands.
Huck said quietly, “Maybe thats the treasure box.” He
went after the two men.
They walked to Mrs. Douglass house and stopped in her
yard. Huck stayed behind some small trees. The men
talked, and Huck listened to them.
Injun Joe was angry. “I want to kill her,” he said to his
friend. “Mr. Douglas was bad to me. Hes dead now, but I
remember.”
There are a lot of lights in the house. Maybe her
friends are visiting,” Injun Joes friend said. “We can
come back tomorrow.”
“No,” Injun Joe said. “Lets wait now.”
Huck liked Mrs. Douglas because she was always good
to him. He wanted to help her. He quietly walked away
and then he started to run to Mr. Joness house.
Mr. Jones opened the door. “What do you want?” he
asked Huck.
“Injun Joe and his friend are in Mrs. Douglass yard,”
Huck said. “They want to kill her. Can you go there and
help Mrs. Douglas?”
18
The men talked, and Huck listened to them.
“Yes. My sons and I can go there,” Mr. Jones
answered. “You can go home.”
In the morning, Huck went back to Mr. Joness house.
“Hows Mrs. Douglas?” he asked.
“Shes OK,” Mr. Jones answered. “The men went away
because we arrived.”
“Good,” Huck said. But he was afraid of Injun Joe.
“Please dont say my name to Mrs. Douglas.”
Mr. Jones looked at him, and then he said, “You arent
well. Go and sleep in my bedroom.”
Later, Mrs. Douglas visited Mr. Jones.
“You helped me yesterday night. Thank you,” she said.
“Youre a good man.”
Mr. Jones said, “We didnt know about the men in your
yard. A boy was there and he wanted to help you. He came
here, but I cant say his name.”
Mr. Jones and Mrs. Douglas went to church. People
there talked about Tom and Becky. Mr. Jones and his sons
went to the cave with the men, but on Monday morning
they went home. Huck was in bed and was very sick. The
men went back to the cave, but Mrs. Douglas stayed with
Huck.
Chapter 10 In the Cave
Saturday, Tom and Becky walked and played in the cave.
Then they stopped near some water.
“What time is it?” Becky asked.
“I dont know,” Tom said. “Lets go back now”
20
The two children walked and walked. But they didnt
find the door to the cave. Becky was afraid. She wanted to
sit down and eat. “Maybe theyre looking for us now,” she
said.
“Heres some food,” Tom said. “Eat this and wait here.
Im going to look for the door.”
Tom walked and walked. But he didnt find the cave
door. Suddenly, there was a man near him. Tom was
afraid, but he stayed quiet. He looked at the man. It was
Injun Joe!
Tom was very afraid and he made a noise. Injun Joe
went away quickly. Tom went back to Becky, but he
didnt talk to her about Injun Joe.
They were in the cave for three days. Tuesday, Becky
didnt want to walk. Again Tom said, “Stay here. Im
going to look for the door.”
This time he went to a new place. There was light there.
He went to the light. It came from a small door in the
cave.
Tom went out of the cave. Then he went back to Becky.
“Come with me,” he said. “We can go out of the cave
now.”
Tom and Becky went out of the cave. They were very
happy. They went to the river and waited there. Some men
in a small boat came to them.
Tom said, “We want to go home. Can you help us?”
The men answered, “Yes. We can take you home.”
Tom and Becky went in the boat with the men. They
arrived home very late Tuesday night, and people in the
town were very happy. Tom talked all night about their
adventure in the cave.
21
Tom went out of the cave.
Chapter 11 In the Cave Again
Tom and Becky stayed home for many days. Then, two
weeks after their adventure, Tom visited Becky and talked
to her father.
Mr. Thatcher said, “Youre a very good boy, Tom. You
helped Becky in the cave. Thank you. People cant go into
it now because it has a new big door.”
“But Injun Joes living in the cave!” Tom said.
Some men went down the river to the cave. Tom went
with them. They opened the new door. Injun Joe was
there, but he was dead.
Tom wanted to talk to Huck. Later in the week he went
to Mr. Joness house. The two boys talked about their
adventures.
“The money isnt in Injun Joes house,” Tom said. “Its
in the cave! I know, because Injun Joe was there. Lets get
it!”
Huck was afraid. “But maybe we cant find it.”
“I can find it again,” Tom said. “I know about a small
door at the back of the cave. Becky and I came out there.
We can go in that door, and I can find Injun Joes treasure.”
“OK,” Huck said. “Lets go today.”
That afternoon the boys went in a small boat to the back
of the cave. Tom walked first, and Huck went after him.
They walked and walked.
Then Tom said, “This is the right place! Injun Joe was
here.”
The boys looked for a good place for treasure.
Suddenly, Tom said, “Look! Theres a cross! Injun Joe
said, under the cross. Lets look there!”
“Look! Its the treasure box!”
The boys went to the place with the cross. Tom said,
“Im going to dig here with my knife ... Look! Its the
treasure box! Lets get it out now. The treasures ours!”
“This box is very heavy,” Huck said. “We cant take it
with us.”
“I have some small bags,” Tom said. “We can put the
money in them and take it home.”
The boys went out of the cave with the money.
Chapter 12 At Mrs. Douglass House
Tom said, “Lets take the money to the old house near
Mrs. Douglass house. Thats a good place for it.”
They started to walk to the old house. Mr. Jones was in
Mrs. Douglass yard. He called to the boys.
“A lot of people are waiting for you. Come with me,” he
said. They went into Mrs. Douglass house.
“Hello, boys,” Mrs. Douglas said. “Come with me.”
Tom and Huck went with her to a bedroom. There were
new shirts and jeans on the bed.
“Wash your hands and faces and put on these shirts and
jeans,” Mrs. Douglas said. “Then come to the big room.”
The boys went to the room. A lot of people were there.
Mrs. Douglas said, “First I want to say thank you to
Mr. Jones and his sons. They helped me. Theyre very
good people.”
“Huck helped, too,” Mr. Jones said.
Thank you, too, Huck,” Mrs. Douglas said. “Youre a
good boy, and I like you. I want to give you a home and
some money.”
25
“But Huck has a lot of money!” Tom said.
He went to the bedroom and came back with the bags of
money. “We have this money from the cave Theres a lot
of money in them, and its ours now.”
There was $12,000 in the bags. The people were very
surprised. They asked about the boys adventure.
Chapter 13 Hucks New Home
Huck lived in the big house with Mrs. Douglas. He was a
new person. He washed every day, and he went to school
and church. But he wasnt happy. He stayed there for three
weeks, and then he ran away.
Tom went to Huck. “Why did you run away?”
Huck answered, “Mrs. Douglas is a good woman. I like
her, but I cant live with her. I dont like washing every
day, and I dont like going to school and church. I dont
want to have a lot of money. But I want to be your friend.
OK?”
“No,” Tom said, “I cant be your friend, because the
boys at school dont want to play with you. Were
thinking about a lot of new adventures. Please live with
Mrs. Douglas and come to school. Then the boys at school
can play with you.”
“I want to be your friend,” Huck said, “and I want to
have adventures with you and the boys at school. Maybe I
can live with Mrs. Douglas. I dont know, but Im going to
try it again for a month.”
“Good,” Tom said. “The boys are meeting later, at
twelve oclock at night. You can come, too.”
“Good!” Huck said.
ACTIVITIES
Chapters 1-6
Before you read
1 Find the words in italics in your dictionary. They are all in the
story.
a Answer the questions.
What adventures are on TV? What adventures do you
have?
What are you afraid of?
Do you like cats?
What makes you sac/?
When are you surprised?
b Put a word on the left with a word on the right.
aunt dead
church family
fence sick
graveyard police
medicine picture
paint yard
trial Sunday
c Put these words in the sentences.
help kill tore (to tear)
The man is going to..... the animal with his knife.
Shes unhappy because she.......her new dress.
He likes to..... his mother with her work.
After you read
2 Why
a is Aunt Polly angry with Tom?
b do Tom and Joe want to run away?
c doesnt Becky talk to Tom?
27
d do Tom and Huck want to help Muff Potter?
e are Tom and Huck afraid of Injun Joe?
Chapters 7-13
Before you read
3 Are Tom and Huck going to see Injun Joe again?
4 Find the words in italics in your dictionary. Answer the questions.
a What can you buy in a box?
b Is it light or dark in a cave?
c The teacher put a cross on your answer. Is the answer
right or wrong?
d What can you dig with? A ticket, a book or a knife?
e What are your treasures?
After you read
5 Answer the questions.
a How many nights are Tom and Becky in the cave?
b Why is there a new big door on the cave?
c How is Huck a new person?
6 Where are they?
a Injun Joe finds the treasure box.
b Aunt Polly and Beckys mother talk to the children.
c Tom and Huck find the treasure box.
d There is a surprise for Huck.
Writing
7 Is Tom a good boy or a bad boy? Why? Write about it.
8 You are Tom or Huck. What are you going to do with your money
from the treasure box? Write about it.
Answers for the Activities in this book are published in our free resource packs for teachers,
the Penguin Readers Factsheets, or available on a separate sheet. Please write to your local
Pearson Education office or to: Marketing Department, Penguin Longman Publishing,
5 Bentinck Street, London W1M 5RN.
VISIT www.penguinreaders.com
The best place on the Internet to find
information about graded Readers
On our website you can:
• Find the best selection of graded Readers in
the world
• Read about your favourite writers and
film stars
• Download free teacher's resources
• Buy Penguin Readers online
• Do much more ... Website
BUY ONLINE AT w w w . p e n g u i n r e a d e r s . c o m
Tom Sawyer loves adventures. He has them at home,
at school, and with his friends—Huck Finn and Joe
Harper. Tom has one adventure in a graveyard, and one
in a cave. Who does he see there, and why is he afraid?
Penguin Readers are simplified texts designed in association with Longman,
the world famous educational publisher, to provide a step-by-step
approach to this joys of reading for pleasure. Each book has an
introduction and extensive activity material. They are published
at seven levels from Easystarts (200 words) to Advanced (3000 words).
Series Editors: Andy Hopkins and Jocelyn Potter
www.penguinreaders.com
Cover photograph © Frank Hopkinson 2000