Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Init

  • Loading branch information...
commit 31110cd45eac057722fae20e748d2fcb6dede8fd 0 parents
unknown authored
107 BartlettProcessor.py
@@ -0,0 +1,107 @@
+import re
+
+def main():
+ index = processQuotes('test', processIndex())
+ file = open('index.txt', 'w')
+
+ for key in index.keys():
+ file.write(key + index[key] + '\n')
+
+
+def processQuotes(index, keywordIndex):
+ file = open('quotesEdited.txt', 'r')
+ lines = file.readlines()
+ quote = ()
+ chapters = []
+ authorlist = []
+ booklist = dict()
+
+ for line in lines:
+ if(line.startswith('(')):
+ #comment ignore
+ continue
+
+ elif(line.startswith(' ')):
+ #new quote or part of a quote
+ quote = quote + (line,)
+
+ elif(line.startswith('_')):
+ #source for quote
+ book = line.strip('_\n') + ':' #all books end with :
+ chapter = (book,) + quote
+ quote = ()
+ #print(chapter)
+ chapters.append(chapter)
+
+
+ elif(line.endswith('_\n')):
+ #part of a chopped book title
+ continue
+
+ else:
+ #new author
+ #remove meta-data from author
+ author = re.sub('_[A-Za-z]*_','',line)
+
+ #check for false positives
+ if(re.search('[a-z]', author) != None and
+ re.search('[:]', author) == None):
+ continue
+
+ #format authorname
+ author = re.sub('[^A-Za-z]','',author)
+
+ #author added to list
+ authorlist.append(author)
+
+ for chapter in chapters:
+ #handle books
+ booklist[chapter[0]] = author
+ #handle keywords
+ #I need to find the quote that
+ # matches the key from keywords
+
+ #write out the last book of quotes
+ writeAuthor(author, chapters)
+ chapters = []
+
+ return booklist
+
+
+def writeAuthor(author, chapters):
+ #this code takes a book of quotes and an Author
+ # and writes out the Author's file
+ file=open('chapters/'+ author, 'w')
+
+ for chapter in chapters:
+ for line in chapter:
+ file.write(line)
+
+
+def processIndex():
+ keywords = dict()
+ index = open('keywords.txt', 'r')
+ lines = index.readlines()
+ k = 0
+
+ for line in lines:
+ if(line.endswith('.\n')):
+ #quote or key and quote
+ if(not line.startswith(' ')):
+ #key and quote
+ temp = line.split(' ',1)
+ keywords[temp[1].lower()] = temp[0].strip(',\n').lower()
+ else:
+ keywords[line.lower()] = key
+ #quote
+ elif(not line.isspace()):
+ #key or whitespace
+ key = line.strip(',\n').lower()
+ #else: just whitespace
+
+ return keywords
+
+
+if __name__ == "__main__":
+ main()
+
6,210 index.txt
6,210 additions, 0 deletions not shown
44,206 keywords.txt
44,206 additions, 0 deletions not shown
66,962 quotes.txt
66,962 additions, 0 deletions not shown
29,385 quotesEdited.txt
29,385 additions, 0 deletions not shown
30 stripFoot.py
@@ -0,0 +1,30 @@
+
+out = ()
+
+file = open('quotes.txt', 'r')
+lines = file.readlines()
+flag = bool(0)
+
+for line in lines:
+ if line.startswith(' '):
+ if not flag:
+ temp = line,
+ out = out + temp
+ elif line.startswith('['):
+ flag = bool(1)
+ elif line.startswith('FOOTNOTE'):
+ flag = bool(1)
+ elif line.startswith('\n'):
+ flag = flag
+ else:
+ flag = bool(0)
+ temp = line,
+ out = out + temp
+
+file = open('quotesEdited.txt', 'w')
+
+for line in out:
+ file.write(line.rstrip('[]1234567890-\n'))
+ file.write('\n')
+
+
490 test.txt
@@ -0,0 +1,490 @@
+GEOFFREY CHAUCER. 1328-1400.
+
+(_From the text of Tyrwhitt._)
+
+ WHANNE that April with his shoures sote
+ The droughte of March hath perced to the rote.
+
+_Canterbury Tales. Prologue. Line 1._
+
+
+ And smale foules maken melodie,
+ That slepen alle night with open eye,
+ So priketh hem nature in hir corages;
+ Than longen folk to gon on pilgrimages.
+
+_Canterbury Tales. Prologue. Line 9._
+
+
+ And of his port as meke as is a mayde.
+
+_Canterbury Tales. Prologue. Line 69._
+
+
+ He was a veray parfit gentil knight.
+
+_Canterbury Tales. Prologue. Line 72._
+
+
+ He coude songes make, and wel endite.
+
+_Canterbury Tales. Prologue. Line 95._
+
+
+ Ful wel she sange the service devine,
+ Entuned in hire nose ful swetely;
+ And Frenche she spake ful fayre and fetisly,
+ After the scole of Stratford atte bowe,
+ For Frenche of Paris was to hire unknowe.
+
+_Canterbury Tales. Prologue. Line 122._
+
+
+ A Clerk ther was of Oxenforde also.
+
+_Canterbury Tales. Prologue. Line 287._
+
+
+ For him was lever han at his beddes hed
+ A twenty bokes, clothed in black or red,
+ Of Aristotle, and his philosophie,
+ Than robes riche, or fidel, or sautrie.
+ But all be that he was a philosophre,
+ Yet hadde he but litel gold in cofre.
+
+_Canterbury Tales. Prologue. Line 295._
+
+
+ And gladly wolde he lerne, and gladly teche.
+
+_Canterbury Tales. Prologue. Line 310._
+
+
+ Nowher so besy a man as he ther n' as,
+ And yet he semed besier than he was.
+
+_Canterbury Tales. Prologue. Line 323._
+
+
+ His studie was but litel on the Bible.
+
+_Canterbury Tales. Prologue. Line 440._
+
+
+ For gold in phisike is a cordial;
+ Therefore he loved gold in special.
+
+_Canterbury Tales. Prologue. Line 445._
+
+
+ Wide was his parish, and houses fer asonder.
+
+_Canterbury Tales. Prologue. Line 493._
+
+
+ This noble ensample to his shepe he yaf,--
+ That first he wrought, and afterwards he taught.
+
+_Canterbury Tales. Prologue. Line 498._
+
+
+ But Cristes lore, and his apostles twelve,
+ He taught; but first he folwed it himselve.
+
+_Canterbury Tales. Prologue. Line 529._
+
+
+ And yet he had a thomb of gold parde.[2-1]
+
+_Canterbury Tales. Prologue. Line 565._
+
+
+ Who so shall telle a tale after a man,
+ He moste reherse, as neighe as ever he can,
+ Everich word, if it be in his charge,
+ All speke he never so rudely and so large;
+ Or elles he moste tellen his tale untrewe,
+ Or feinen thinges, or finden wordes newe.
+
+_Canterbury Tales. Prologue. Line 733._
+
+
+ For May wol have no slogardie a-night.
+ The seson priketh every gentil herte,
+ And maketh him out of his slepe to sterte.
+
+_Canterbury Tales. The Knightes Tale. Line 1044._
+
+
+ That field hath eyen, and the wood hath ears.[2-2]
+
+_Canterbury Tales. The Knightes Tale. Line 1524._
+
+
+ Up rose the sonne, and up rose Emelie.
+
+_Canterbury Tales. The Knightes Tale. Line 2275._
+
+
+ Min be the travaille, and thin be the glorie.
+
+_Canterbury Tales. The Knightes Tale. Line 2408._
+
+
+ To maken vertue of necessite.[3-1]
+
+_Canterbury Tales. The Knightes Tale. Line 3044._
+
+
+ And brought of mighty ale a large quart.
+
+_Canterbury Tales. The Milleres Tale. Line 3497._
+
+
+ Ther n' is no werkman whatever he be,
+ That may both werken wel and hastily.[3-2]
+ This wol be done at leisure parfitly.[3-3]
+
+_Canterbury Tales. The Marchantes Tale. Line 585._
+
+
+ Yet in our ashen cold is fire yreken.[3-4]
+
+_Canterbury Tales. The Reves Prologue. Line 3880._
+
+
+ The gretest clerkes ben not the wisest men.
+
+_Canterbury Tales. The Reves Tale. Line 4051._
+
+
+ So was hire joly whistle wel ywette.
+
+_Canterbury Tales. The Reves Tale. Line 4153._
+
+
+ In his owen grese I made him frie.[3-5]
+
+_Canterbury Tales. The Reves Tale. Line 6069._
+
+
+ And for to see, and eek for to be seie.[3-6]
+
+_Canterbury Tales. The Wif of Bathes Prologue. Line 6134._
+
+
+ I hold a mouses wit not worth a leke,
+ That hath but on hole for to sterten to.[4-1]
+
+_Canterbury Tales. The Wif of Bathes Prologue. Line 6154._
+
+
+ Loke who that is most vertuous alway,
+ Prive and apert, and most entendeth ay
+ To do the gentil dedes that he can,
+ And take him for the gretest gentilman.
+
+_Canterbury Tales. The Wif of Bathes Tale. Line 6695._
+
+
+ That he is gentil that doth gentil dedis.[4-2]
+
+_Canterbury Tales. The Wif of Bathes Tale. Line 6752._
+
+
+ This flour of wifly patience.
+
+_Canterbury Tales. The Clerkes Tale. Part v. Line 8797._
+
+
+ They demen gladly to the badder end.
+
+_Canterbury Tales. The Squieres Tale. Line 10538._
+
+
+ Therefore behoveth him a ful long spone,
+ That shall eat with a fend.[4-3]
+
+_Canterbury Tales. The Squieres Tale. Line 10916._
+
+
+ Fie on possession,
+ But if a man be vertuous withal.
+
+_Canterbury Tales. The Frankeleines Prologue. Line 10998._
+
+
+ Truth is the highest thing that man may keep.
+
+_Canterbury Tales. The Frankeleines Tale. Line 11789._
+
+
+ Full wise is he that can himselven knowe.[4-4]
+
+_Canterbury Tales. The Monkes Tale. Line 1449._
+
+
+ Mordre wol out, that see we day by day.[5-1]
+
+_Canterbury Tales. The Nonnes Preestes Tale. Line 15058._
+
+
+ But all thing which that shineth as the gold
+ Ne is no gold, as I have herd it told.[5-2]
+
+_Canterbury Tales. The Chanones Yemannes Tale. Line 16430._
+
+
+ The firste vertue, sone, if thou wilt lere,
+ Is to restreine and kepen wel thy tonge.
+
+_Canterbury Tales. The Manciples Tale. Line 17281._
+
+
+ The proverbe saith that many a smale maketh a grate.[5-3]
+
+_Canterbury Tales. Persones Tale._
+
+
+ Of harmes two the lesse is for to cheese.[5-4]
+
+_Troilus and Creseide. Book ii. Line 470._
+
+
+ Right as an aspen lefe she gan to quake.
+
+_Troilus and Creseide. Book ii. Line 1201._
+
+
+ For of fortunes sharpe adversite,
+ The worst kind of infortune is this,--
+ A man that hath been in prosperite,
+ And it remember whan it passed is.
+
+_Troilus and Creseide. Book iii. Line 1625._
+
+
+ He helde about him alway, out of drede,
+ A world of folke.
+
+_Troilus and Creseide. Book iii. Line 1721._
+
+
+ One eare it heard, at the other out it went.[6-1]
+
+_Troilus and Creseide. Book iv. Line 435._
+
+
+ Eke wonder last but nine deies never in toun.[6-2]
+
+_Troilus and Creseide. Book iv. Line 525._
+
+
+ I am right sorry for your heavinesse.
+
+_Troilus and Creseide. Book v. Line 146._
+
+
+ Go, little booke! go, my little tragedie!
+
+_Troilus and Creseide. Book v. Line 1798._
+
+
+ Your duty is, as ferre as I can gesse.
+
+_The Court of Love. Line 178._
+
+
+ The lyfe so short, the craft so long to lerne,[6-3]
+ Th' assay so hard, so sharpe the conquering.
+
+_The Assembly of Fowles. Line 1._
+
+
+ For out of the old fieldes, as men saithe,
+ Cometh al this new corne fro yere to yere;
+ And out of old bookes, in good faithe,
+ Cometh al this new science that men lere.
+
+_The Assembly of Fowles. Line 22._
+
+
+ Nature, the vicar of the Almightie Lord.
+
+_The Assembly of Fowles. Line 379._
+
+
+ O little booke, thou art so unconning,
+ How darst thou put thy-self in prees for drede?
+
+_The Flower and the Leaf. Line 59._
+
+
+ Of all the floures in the mede,
+ Than love I most these floures white and rede,
+ Soch that men callen daisies in our toun.
+
+_Prologue of the Legend of Good Women. Line 41._
+
+
+ That well by reason men it call may
+ The daisie, or els the eye of the day,
+ The emprise, and floure of floures all.
+
+_Prologue of the Legend of Good Women. Line 183._
+
+
+ For iii may keep a counsel if twain be away.[6-4]
+
+_The Ten Commandments of Love._
+
+
+FOOTNOTES:
+
+[2-1] In allusion to the proverb, "Every honest miller has a
+ golden thumb."
+
+[2-2] Fieldes have eies and woodes have eares.--HEYWOOD:
+ _Proverbes, part ii. chap. v._
+
+ Wode has erys, felde has sigt.--_King Edward and the Shepard, MS.
+ Circa 1300._
+
+ Walls have ears.--HAZLITT: _English Proverbs, etc._ (_ed. 1869_)
+ _p. 446._
+
+[3-1] Also in _Troilus and Cresseide, line 1587._
+
+ To make a virtue of necessity.--SHAKESPEARE: _Two Gentlemen of
+ Verona, act iv. sc. 2._ MATTHEW HENRY: _Comm. on Ps. xxxvii._
+ DRYDEN: _Palamon and Arcite._
+
+ In the additions of Hadrianus Julius to the _Adages_ of Erasmus,
+ he remarks, under the head of _Necessitatem edere_, that a very
+ familiar proverb was current among his countrymen,--"Necessitatem
+ in virtutem commutare" (To make necessity a virtue).
+
+ Laudem virtutis necessitati damus (We give to necessity the praise
+ of virtue).--QUINTILIAN: _Inst. Orat. i. 8. 14._
+
+[3-2] Haste makes waste.--HEYWOOD: _Proverbs, part i. chap. ii._
+
+ Nothing can be done at once hastily and prudently.--PUBLIUS SYRUS:
+ _Maxim 357._
+
+[3-3] Ease and speed in doing a thing do not give the work lasting
+ solidity or exactness of beauty.--PLUTARCH: _Life of Pericles._
+
+[3-4] E'en in our ashes live their wonted fires.--GRAY: _Elegy,
+ Stanza 23._
+
+[3-5] Frieth in her own grease.--HEYWOOD: _Proverbs, part i. chap.
+ xi._
+
+[3-6] To see and to be seen.--BEN JONSON: _Epithalamion, st. iii.
+ line 4._ GOLDSMITH: _Citizen of the World, letter 71._
+
+ Spectatum veniunt, veniunt spectentur ut ips� (They come to see;
+ they come that they themselves may be seen).--OVID: _The Art of
+ Love, i. 99._
+
+[4-1] Consider the little mouse, how sagacious an animal it is
+ which never entrusts his life to one hole only.--PLAUTUS:
+ _Truculentus, act iv. sc. 4._
+
+ The mouse that always trusts to one poor hole
+ Can never be a mouse of any soul.
+
+ POPE: _Paraphrase of the Prologue, line 298._
+
+[4-2] Handsome is that handsome does.--GOLDSMITH: _Vicar of
+ Wakefield, chap. i._
+
+[4-3] Hee must have a long spoon, shall eat with the
+ devill.--HEYWOOD: _Proverbes, part ii. chap. v._
+
+ He must have a long spoon that must eat with the
+ devil.--SHAKESPEARE: _Comedy of Errors, act iv. sc. 3._
+
+[4-4] Thales was asked what was very difficult; he said, "To know
+ one's self."--DIOGENES LAERTIUS: _Thales, ix._
+
+ Know then thyself, presume not God to scan;
+ The proper study of mankind is man.
+
+ POPE: _Epistle ii. line 1._
+
+[5-1]
+ Murder, though it have no tongue, will speak
+ With most miraculous organ.
+
+ SHAKESPEARE: _Hamlet, act ii. sc. 2._
+
+[5-2] Tyrwhitt says this is taken from the _Parabolae_ of ALANUS
+ DE INSULIS, who died in 1294,--Non teneas aurum totum quod
+ splendet ut aurum (Do not hold everything as gold which shines
+ like gold).
+
+ All is not golde that outward shewith bright.--LYDGATE: _On the
+ Mutability of Human Affairs._
+
+ Gold all is not that doth golden seem.--SPENSER: _Faerie Queene,
+ book ii. canto viii. st. 14._
+
+ All that glisters is not gold.--SHAKESPEARE: _Merchant of Venice,
+ act ii. sc. 7._ GOOGE: _Eglogs, etc., 1563._ HERBERT: _Jacula
+ Prudentum._
+
+ All is not gold that glisteneth.--MIDDLETON: _A Fair Quarrel,
+ verse 1._
+
+ All, as they say, that glitters is not gold.--DRYDEN: _The Hind
+ and the Panther._
+
+ Que tout n'est pas or c'on voit luire (Everything is not gold that
+ one sees shining).--_Li Diz de freire Denise Cordelier, circa
+ 1300._
+
+[5-3] Many small make a great.--HEYWOOD: _Proverbes. part i. chap.
+ xi._
+
+[5-4] Of two evils the less is always to be chosen.--THOMAS �
+ KEMPIS: _Imitation of Christ, book ii. chap. xii._ HOOKER:
+ _Polity, book v. chap. lxxxi._
+
+ Of two evils I have chose the least.--PRIOR: _Imitation of
+ Horace._
+
+ E duobus malis minimum eligendum (Of two evils, the least should
+ be chosen).--ERASMUS: _Adages._ CICERO: _De Officiis, iii. 1._
+
+[6-1] Went in at the tone eare and out at the tother.--HEYWOOD:
+ _Proverbes, part ii. chap. ix._
+
+[6-2] This wonder lasted nine daies.--HEYWOOD: _Proverbes, part
+ ii. chap. i._
+
+[6-3] Ars longa, vita brevis (Art is long: life is
+ brief).--HIPPOCRATES: _Aphorism i._
+
+[6-4] Three may keepe counsayle, if two be away.--HEYWOOD:
+ _Proverbes, part ii. chap. v._
+
+
+
+
+THOMAS � KEMPIS. 1380-1471.
+
+ Man proposes, but God disposes.[7-1]
+
+_Imitation of Christ. Book i. Chap. 19._
+
+
+ And when he is out of sight, quickly also is he out of mind.[7-2]
+
+_Imitation of Christ. Book i. Chap. 23._
+
+
+ Of two evils, the less is always to be chosen.[7-3]
+
+_Imitation of Christ. Book iii. Chap. 12._
Please sign in to comment.
Something went wrong with that request. Please try again.