Skip to content

Commit 3891ff3

Browse files
committed
Add a mechanism to load example novels, add Pride and Prejudice from PG
1 parent 781377e commit 3891ff3

66 files changed

Lines changed: 13026 additions & 54 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from renard.resources.novels.novels import *

renard/resources/novels/novels.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import re
2+
import pathlib as pl
3+
4+
NOVELS = [
5+
path.name
6+
for path in pl.Path(__file__).parent.iterdir()
7+
if path.is_dir() and path.name != "__pycache__"
8+
]
9+
10+
11+
def load_novel_chapters(name: str) -> list[str]:
12+
chapters = []
13+
chapter_paths = (pl.Path(__file__).parent / name).glob("chapter_*.txt")
14+
chapter_paths = sorted(
15+
chapter_paths,
16+
key=lambda p: int(re.match(r"chapter_([0-9]+)\.txt", str(p.name)).group(1)),
17+
)
18+
for path in sorted((pl.Path(__file__).parent / name).glob("chapter_*.txt")):
19+
with open(path) as f:
20+
chapters.append(f.read())
21+
return chapters
22+
23+
24+
def load_novel(name: str) -> str:
25+
return "\n".join(load_novel_chapters(name))
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
It is a truth universally acknowledged, that a single man in possession
2+
of a good fortune, must be in want of a wife.
3+
4+
However little known the feelings or views of such a man may be on his
5+
first entering a neighbourhood, this truth is so well fixed in the minds
6+
of the surrounding families, that he is considered as the rightful
7+
property of some one or other of their daughters.
8+
9+
"My dear Mr. Bennet," said his lady to him one day, "have you heard that
10+
Netherfield Park is let at last?"
11+
12+
Mr. Bennet replied that he had not.
13+
14+
"But it is," returned she; "for Mrs. Long has just been here, and she
15+
told me all about it."
16+
17+
Mr. Bennet made no answer.
18+
19+
"Do not you want to know who has taken it?" cried his wife impatiently.
20+
21+
"_You_ want to tell me, and I have no objection to hearing it."
22+
23+
This was invitation enough.
24+
25+
"Why, my dear, you must know, Mrs. Long says that Netherfield is taken
26+
by a young man of large fortune from the north of England; that he came
27+
down on Monday in a chaise and four to see the place, and was so much
28+
delighted with it that he agreed with Mr. Morris immediately; that he is
29+
to take possession before Michaelmas, and some of his servants are to be
30+
in the house by the end of next week."
31+
32+
"What is his name?"
33+
34+
"Bingley."
35+
36+
"Is he married or single?"
37+
38+
"Oh! single, my dear, to be sure! A single man of large fortune; four
39+
or five thousand a year. What a fine thing for our girls!"
40+
41+
"How so? how can it affect them?"
42+
43+
"My dear Mr. Bennet," replied his wife, "how can you be so tiresome! You
44+
must know that I am thinking of his marrying one of them."
45+
46+
"Is that his design in settling here?"
47+
48+
"Design! nonsense, how can you talk so! But it is very likely that he
49+
_may_ fall in love with one of them, and therefore you must visit him as
50+
soon as he comes."
51+
52+
"I see no occasion for that. You and the girls may go, or you may send
53+
them by themselves, which perhaps will be still better, for as you are
54+
as handsome as any of them, Mr. Bingley might like you the best of the
55+
party."
56+
57+
"My dear, you flatter me. I certainly _have_ had my share of beauty, but
58+
I do not pretend to be any thing extraordinary now. When a woman has
59+
five grown up daughters, she ought to give over thinking of her own
60+
beauty."
61+
62+
"In such cases, a woman has not often much beauty to think of."
63+
64+
"But, my dear, you must indeed go and see Mr. Bingley when he comes into
65+
the neighbourhood."
66+
67+
"It is more than I engage for, I assure you."
68+
69+
"But consider your daughters. Only think what an establishment it would
70+
be for one of them. Sir William and Lady Lucas are determined to go,
71+
merely on that account, for in general you know they visit no new
72+
comers. Indeed you must go, for it will be impossible for _us_ to visit
73+
him, if you do not."
74+
75+
"You are over scrupulous surely. I dare say Mr. Bingley will be very
76+
glad to see you; and I will send a few lines by you to assure him of my
77+
hearty consent to his marrying which ever he chuses of the girls; though
78+
I must throw in a good word for my little Lizzy."
79+
80+
"I desire you will do no such thing. Lizzy is not a bit better than the
81+
others; and I am sure she is not half so handsome as Jane, nor half so
82+
good humoured as Lydia. But you are always giving _her_ the
83+
preference."
84+
85+
"They have none of them much to recommend them," replied he; "they are
86+
all silly and ignorant like other girls; but Lizzy has something more of
87+
quickness than her sisters."
88+
89+
"Mr. Bennet, how can you abuse your own children in such a way? You take
90+
delight in vexing me. You have no compassion on my poor nerves."
91+
92+
"You mistake me, my dear. I have a high respect for your nerves. They
93+
are my old friends. I have heard you mention them with consideration
94+
these twenty years at least."
95+
96+
"Ah! you do not know what I suffer."
97+
98+
"But I hope you will get over it, and live to see many young men of four
99+
thousand a year come into the neighbourhood."
100+
101+
"It will be no use to us, if twenty such should come since you will not
102+
visit them."
103+
104+
"Depend upon it, my dear, that when there are twenty, I will visit them
105+
all."
106+
107+
Mr. Bennet was so odd a mixture of quick parts, sarcastic humour,
108+
reserve, and caprice, that the experience of three and twenty years had
109+
been insufficient to make his wife understand his character. _Her_ mind
110+
was less difficult to develope. She was a woman of mean understanding,
111+
little information, and uncertain temper. When she was discontented she
112+
fancied herself nervous. The business of her life was to get her
113+
daughters married; its solace was visiting and news.

0 commit comments

Comments
 (0)