"# You should download the book text, clean it, and import it here\n",
"with open(\"pride.txt\", encoding=\"utf8\") as f:\n",
" file_contents = f.read()\n"
" file_contents = f.read()\n",
"print(f\"Length of file: {len(file_contents)} characters\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
@ -50,7 +42,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
@ -63,9 +55,43 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The 26 most positive sentences:\n",
"+ “What an excellent father you have, girls,” said she, when the door wasshut.\n",
"+ He walked here, and he walked there, fancying himself so verygreat!\n",
"+ Mr. Darcy replied, with great intrepidity,--“Miss Elizabeth Bennet.”“Miss Elizabeth Bennet!” repeated Miss Bingley.\n",
"+ “Your examination of Mr. Darcy is over, I presume,” said Miss Bingley;“and pray what is the result?”“I am perfectly convinced by it that Mr. Darcy has no defect.\n",
"+ Family pride, and _filial_ pride, for he is very proud of what hisfather was, have done this.\n",
"+ _That_ would be the greatest misfortune of all!\n",
"+ How wonderfully these sort of things occur!\n",
"+ She owed her greatest relief to her friend Miss Lucas, whooften joined them, and good-naturedly engaged Mr. Collins’s conversationto herself.\n",
"+ The improvement ofspending a night in London was added in time, and the plan became asperfect as plan could be.\n",
"+ She is avery great favourite with some ladies of my acquaintance, Mrs. Hurst andMiss Bingley.\n",
"+ It isdone, however, and it was done for the best.\n",
"+ I have the greatest dislike in theworld to that sort of thing.\n",
"+ Charlotte is anexcellent manager, I dare say.\n",
"+ “His father was an excellent man,” said Mrs. Gardiner.\n",
"+ “He is the best landlord, and the best master,” said she, “that everlived.\n",
"+ “He is perfectly well-behaved, polite, and unassuming,” said her uncle.\n",
"+ On reaching the house, they were shown through the hall into the saloon,whose northern aspect rendered it delightful for summer.\n",
"+ Our distress, my dear Lizzy, is very great.\n",
"+ And tell my dearLydia not to give any directions about her clothes till she has seen me,for she does not know which are the best warehouses.\n",
"+ “My dear, dear Lydia!” she cried: “this is delightful indeed!\n",
"+ Excellent parsonage-house!\n",
"+ But, however, he is very welcome to come toNetherfield, if he likes it.\n",
"+ Happy shall I be when his stay at Netherfield is over!”“I wish I could say anything to comfort you,” replied Elizabeth; “but itis wholly out of my power.\n",
"+ If I could but see you as happy!\n",
"+ He is perfectly amiable.\n",
"+ Your idea of theponies is delightful.\n"
]
}
],
"source": [
"print(\"The \" + str(len(positive_sentiment_sentences)) + \" most positive sentences:\")\n",
"for sentence in positive_sentiment_sentences:\n",
@ -74,14 +100,75 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The 14 most negative sentences:\n",
"- Everybody is disgusted with his pride.\n",
"- what canhave induced him to behave so cruelly?”“A thorough, determined dislike of me--a dislike which I cannot butattribute in some measure to jealousy.\n",
"- To finda man agreeable whom one is determined to hate!\n",
"- “I should like to know how he behaves among strangers.”“You shall hear, then--but prepare for something very dreadful.\n",
"- The pause was to Elizabeth’s feelingsdreadful.\n",
"- “Wickham sovery bad!\n",
"- The separationbetween her and her family was rather noisy than pathetic.\n",
"- It would be dreadful!\n",
"- can she be ignorant of what youand Jane seem so well to understand?”“Oh, yes!--that, that is the worst of all.\n",
"- “She is so fond of Mrs. Forster,” said she, “it will be quite shockingto send her away!\n",
"- It was all over before I arrived; so my curiosity was not so dreadfully racked as _yours_ seems to have been.\n",
"- He called it, therefore, his duty to step forward, and endeavour to remedy an evil which had been brought on by himself.\n",
"- How you must have hated me after _that_ evening!”“Hate you!\n",
"- You were disgusted with the women who were always speaking,and looking, and thinking for _your_ approbation alone.\n"
]
}
],
"source": [
"print(\"The \" + str(len(negative_sentiment_sentences)) + \" most negative sentences:\")\n",
"for sentence in negative_sentiment_sentences:\n",