-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwiki_text_cleanup.py
More file actions
641 lines (631 loc) · 17.7 KB
/
wiki_text_cleanup.py
File metadata and controls
641 lines (631 loc) · 17.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
#!/usr/bin/python
# -*- coding: utf-8 -*-
import re
import collections
from AppKit import NSPasteboard,NSObject,NSStringPboardType
def sendToClipBoard(string):
pasteboard = NSPasteboard.generalPasteboard()
emptyOwner = NSObject.alloc().init()
pasteboard.declareTypes_owner_([NSStringPboardType], emptyOwner)
pasteboard.setString_forType_(string, NSStringPboardType)
def replaceRomanNumerals(string):
dict = collections.OrderedDict()
dict['VIII'] = '8'
dict['VII'] = '7'
dict['VI'] = '6'
dict['IV'] = '4'
dict['V'] = '5'
dict['IX'] = '9'
dict['X'] = '10'
dict['III'] = '3'
dict['II'] = '2'
dict['I'] = '1'
for i, v in dict.items():
string = string.replace(str(i), str(v))
return string
def replaceRomanNumerals(string):
dict = collections.OrderedDict()
dict['VIII'] = '8'
dict['VII'] = '7'
dict['VI'] = '6'
dict['IV'] = '4'
dict['V'] = '5'
dict['IX'] = '9'
dict['X'] = '10'
dict['III'] = '3'
dict['II'] = '2'
dict['I'] = '1'
for i, v in dict.items():
string = string.replace(str(i), str(v))
return string
def replaceRomanNumeralsOrdinal(string):
dict = collections.OrderedDict()
dict['VIII'] = 'the eighth'
dict['VII'] = 'the seventh'
dict['VI'] = 'the sixth'
dict['IV'] = 'the fourth'
dict['V'] = 'the fifth'
dict['IX'] = 'the ninth'
dict['X'] = 'the tenth'
dict['III'] = 'the third'
dict['II'] = 'the second'
dict['I'] = 'the first'
for i, v in dict.items():
string = string.replace(str(i), str(v))
return string
filename = '/Users/oknate2/Downloads/sample.txt'
searchreplace1 = {
'é ' : 'ay ',
'mise en scène' : 'me zon sen',
'née' : 'nay',
'naïve' : 'naive',
'René Descartes' : 'run "A" day cart',
'Blaise Pascal' : 'Blaze poz cal',
'Jean-Jacques Rousseau' : 'Zhan Jacques Rooso',
'Françoise' : 'frons was',
'de la ' : 'duh la',
'Château' : 'shat toe',
' des ' : ' day ',
'Guillaume' : 'ghee yome',
'Peña' : 'Pain yah',
'Iñárritu' : 'een ya re two',
'González' : 'goensa less',
'Zoë' : 'zo E',
'Joan Miró' : 'jewan mi-roh',
'Slavoj Žižek' : 'slah-voi zhe-zhek',
'Étienne' : 'et tea yen',
'Cuarón' : 'qua rone',
'Mallarmé' : 'Mall are may',
}
searchreplace2 = {
'Fiennes' : 'Fines',
'Alicia Vikander' : 'ah lissia vickander',
'Vikander' : 'vickander',
'Redmayne' : 'Red main',
'tbsp' : 'table spoon',
'Charlize' : 'shar lease',
'[T]he' : 'The',
'Alejandro' : 'ah lay hondro',
'Ralph Fines' : 'Rafe Fines',
'Scorsese' : 'Score Sazie',
'Anthony Hopkins' : 'Ann tonnie Hopkins',
'André Gide' : 'On dray jeed',
'Andre Gide' : 'On dray jeed',
'Fernando' : 'Fair nondo',
'Julio' : 'who leo',
'Castillo' : 'Cass tea oh',
'Dalí' : 'Doll E',
'Moebius' : 'murbi use',
'sangre' : 'sahn gray',
'Santa' : 'sahn tah',
'Laurentiis' : 'lowren tiss',
'Fransoise' : 'Fran swa',
'Blanchett' : 'Blan shet',
'Thomas Hobbes' : 'Thomas Hobs',
'Andree' : 'on dray',
'Breton' : 'brutone',
'Mme ' : "ma dom",
"Mlle " : 'Mod ma zell',
'temps' : 'tom',
'Chiwetel' : 'Chewy tell',
'Ejiofor' : 'Edge E oh four',
'Nolte': 'noll tea',
'Baruchel' : 'Baroo shell',
'Rene Descartes' : 'rennay day cart',
'Descartes' : 'day cart',
'Theroux' : 'Thero',
'Pantoliano' : 'pant O lea on O',
'Warner Bros.' : 'Warner Brothers',
'Galifianakis' : 'gall lif fee a nakis',
'Mathieu' : 'Matt hew',
'Genghis Khan' : 'Gang gus Con',
'Barthes' : 'Bart',
'Haneke' : 'Haneka',
'Nicodemus' : 'Nickadeemus',
'Richard III' : 'Richard the third',
'Von Trier' : 'von treer',
'DVD' : 'Dee Vee Dee',
'Kylo' : 'Kai lo',
'Cuaron' : 'qua rone',
'Alfonso' : 'all-fawn-so',
'Chewbacca' : 'Chew bocka',
'Kasdan' : 'Kazden',
'Sidious' : 'sid dee us',
'Anakin' : 'Anna kin',
'Jedi' : 'Jeddeye',
'Dameron' : 'demer ron',
'Kanata' : 'kan notta',
'von Trier' : 'von treer',
'Jean Genet' : 'Zhan Zhun nay',
'Genet' : '\'ngine nay',
'Cassavetes' : 'Cassa vet ease',
'Friedrich' : 'free drish',
'Wilhelm' : 'Vil hailm',
'Dürrenmatt' : 'durenmott',
'Arrabal' : 'Ah rah ball',
'Palahniuk' : 'pahl-uh-nik',
'Picoult' : 'pee-coe',
'Havel' : 'Hov vell',
'Albert Camus' : 'All bear commu',
'François Truffaut' : 'Frons wah tru fo',
'Truffaut' : 'tru fo',
'Jodorowsky' : 'hoeder offsky',
'phoneticist' : 'phonetisist',
'Simone de Beauvoir' : 'See moan duh Buv wa',
'Beauvoir' : 'Buv wa',
'cliché' : 'klee shay',
"bipolarity" : "by polarity",
"oxymoronic" : 'ocksie moronic',
"Gena Rowlands" : "Jeana Rowlands",
'Raimi' : 'ray me',
'Anschluss' : 'on schluss',
'rima facie' : 'rima fasha',
' Lorre' : ' Lorrie',
'Americain' : 'American',
'C.E.O.s' : ' sea E ohs',
'Jacques' : 'Jock',
'Cicero' : 'sisser roe',
'Ehrmantraut' : 'air min trout',
'Odenkirk' : 'oden kirk',
'Anime' : 'annie may',
'Yoknapatawpha' : 'Yok napa tawfa',
"Baudelaire" : "Bo delair",
'Ratatouille' : 'rata too E',
'Siodmak' : 'sea odd mack',
'Cahiers' : 'ca yey',
"dramedy" : "drama dee",
'Georges Sorel' : 'George So rel',
'Kant' : 'Kont',
'Bologna' : 'Bolone yuh',
"dramady" : "drama dee",
'reminisc' : 'reminiss',
'montillado' : 'montiyado',
'Cyrano de Bergerac' : 'Seer a know duh barejairack',
'Nouvelle Vague' : 'noo vel vahg',
'(Full Content Review for Parents also available)' : '',
'Kazan' : 'Kuzaan',
'fiancée' : 'fiance',
'von Sydow' : 'von siddo',
'Ibsen' : 'ibs sen',
'Elia Kuzaan' : 'eelia kuzaan',
'Roger Ebert' : 'Roger "E" bert',
'bons-mot' : 'bone mo',
'Salome' : 'Sal oh may',
"s's" : 's',
'Gwendolen' : 'Gwen dull in',
'[who?]' : '',
'.com' : ' dot com',
'Capt.' : 'Captain',
'[this quote needs a citation]' : '',
'sync' : 'sink',
'Yeats' : 'Yates',
'Achebe' : 'Ah chay bay',
'Chinua' : 'chin oo wah',
'Celtic' : 'Kell tick',
'fatale' : 'fa\'tall',
'Geoffery' : 'Jeffry',
'Guion' : 'Script',
'Cybill' : 'Sibbul',
'Teri Garr' : 'Teri Gaar',
'Leigh' : 'Lee',
'Cannes' : 'Can',
'Iran' : 'ear ronn',
'Robard' : 'Roe Bard',
'Rhys' : 'Reece',
"IMAX" : "eye max",
'paraplegic' : 'para plee jik',
'Brolin' : 'brole lin',
'Capote' : 'cup poe tea',
'Peckinpah' : 'peck in paw',
'the ID' : 'the id',
'the Id' : 'the id',
'Chile' : 'cheelay',
'BAFTA' : 'bafta',
'pedophile' : 'peddophile',
'Washington, D.C.' : 'Washington Dee Sea',
'Colin ' : 'Call in ',
'Keitel' : 'kite tell',
'Wiest' : 'Weest',
'Coppola' : 'Cope uh luh',
'Cesar Award' : 'say zar award',
'Flaubert' : 'Flow bear',
'ingenue' : 'on gen oo',
'Charlize' : 'shar lease',
'pensione' : 'pen see own A',
'Ruffalo' : 'Rough a low',
'Spacek' : "spay sick",
'racecar' : 'race car',
'Dreiser' : 'Dry zer',
'Proust' : 'Proost',
'Henri Bergson' : 'On re bairg sone',
'Augie' : 'Oggy',
'Sergio Leone' : 'Sair-Joe Lay-own-E',
'psychoses' : 'sike oh sieze',
'chrissake' : 'cry sake',
'vuitton' : 'voo E tone',
'Buscemi' : 'Boo shemmy',
'Quixote' : 'kee ho tay',
"Groucho" : "grout cho",
'Werner' : 'Veirner',
"WASP" : 'wasp',
"Nighy" : 'Nigh he',
"Le Carre" : 'Lacar ray',
'relatable' : 'relate a bull',
'Ramis' : 'Raymis',
'codependency' : 'co dependency',
'protege' : 'protadjay',
'Roland' : 'Role ind',
'Rivendell' : 'Riven dell',
'Elvenking' : 'Elven king',
'Gyllenhaal' : 'Jill in hall',
'McConaughey' : 'muck con a hey',
'Salinger' : 'sal in djer',
'Metacritic' : 'meta critic',
"Chabon" : 'Shay bon',
'Paulo Coelho' : 'paw-lu co-ay-u',
'Coetzee' : 'koot-zee-uh',
'Mihaly Csikszentmihalyi' : 'me-high cheek-sent-me-high',
'JSON' : 'jay sawn',
'the DOM' : 'the domm',
'Sigmund' : 'zeeg munt',
'instantiate' : 'in stan she ate',
'.js' : ' jay ess',
'ECMA' : 'E C M "A"',
'AngularJS' : 'Angular Jay Ess',
'RESTful' : 'rest full',
'the UI' : 'the you eye',
'JavaScript' : 'java script',
'Luis Bunuel' : 'Lou ees boon you el',
'Bunuel' : 'boon you el',
'unmissable' : 'un miss a bull',
'PEN/Faulkner' : 'Pen, Faulkner',
'Tomei' : 'Toe May',
'Stephanides' : 'Steff on a Deez',
"Washington, D.C." : "Washington D sea",
'Liotta' : 'Lee oata',
'Fiennes' : 'Fines',
'cherubim' : 'shara beam',
'Benigni' : 'Ben knee knee',
'S.H.I.E.L.D.' : 'shield',
'Sacha' : 'sasha',
'Rylance' : 'rye lince',
'WWI' : 'World War One',
'WWII' : 'World War Two',
'Tucci' : 'toot tchi',
'Liev Schreiber' : 'Lee yev Schreiber',
'Saoirse' : 'Seer shaw',
'Shyamalan' : 'Shama lawn',
'Malkovich' : 'Malkovitch',
'Swayze' : 'Sway zee',
'Pesci' : 'Peshy',
'Bonham' : 'Bonnum',
', Jr.' : ' Junior, ',
'Jung' : 'Yoong',
'Huston' : 'Houston',
'Pynchon' : 'Pinch on',
'postmodernism' : 'post modernism',
'Cassel' : 'Cass El',
'Sr.' : 'Senior',
'Jr.' : 'Junior',
'Lt.' : 'Lieutenant',
'Stephanides' : 'Steff on a deez',
'Teutonic' : 'two tonic',
'Halle' : 'Hally',
'Linklater' : 'Link later',
'Fritz Lang' : 'Fritz Long',
'Nazi' : 'not see',
'Riefenstahl' : 'Reefenschtall',
'UNESCO' : 'you ness co',
'[citation needed]' : '',
'[source needed]' : '',
'i.e.' : 'in other words',
'e.g.' : 'for example',
'LaBeouf' : 'luh buff',
'rimbaud' : 'rombo',
'(s)' : 's',
" 's" : "'s",
'Federico' : 'Fed air E co',
'amongst' : 'among',
'eschew' : 'eshew',
'Jacobi' : 'Jack o bee',
'Uma Thurman' : 'ooma Thurman',
'Giamatti' : 'gia motti',
'Phillippe' : 'fulleep',
'Rev.' : 'Reverend',
'[edit]' : '; ; ',
'Jean-Luc Godard' : 'Zhan Luke Go dard',
'Jonze' : 'Jones',
'fiancée' : 'fiance',
'Cotillard' : 'Coat eeyard',
'Dreyfuss' : 'Dreifus',
'Eugenides' : 'yujennadeez',
'Geena' : 'Jeena',
'Palme d\'Or' : 'palm duh or',
'Beatty' : 'Batey',
'Styron' : "Sty run",
'Tolkien' : 'Tolken',
'Nazgiul' : 'Naz gull',
'Gondor' : 'gone door',
'Balrog' : 'ball rog',
'Boromir' : 'boro mere',
'Gamgee' : 'Sam jhee',
'Saruman' : 'Sarue min',
'Isildur' : 'eye sull door',
'Legolas' : 'lego less',
'Lothloyrien' : 'loth lorry an',
'Isengard' : 'eye zin guard',
'Orthanc' : 'or thank',
'Mordor' : 'more door',
'Appomattox' : 'Appo maticks',
'Depardieu' : 'Dup parr diu',
'Lacan' : 'La con',
'Georges' : 'George',
'Daenerys' : 'done heiress',
'Targaryen' : 'Tar gary in',
'Khaleesi' : 'call leesi',
'Tyrion' : 'tearie-un',
'Viserys' : 'viss heiress',
'Heinrich Heine' : 'hine rick hine uh',
'Dieter' : 'Deeter',
'Cersei' : 'sir say',
'Drogo' : 'dro go',
'Berenger' : 'Baron jur',
'Willem' : 'Will um',
'Dafoe' : "Dufoe",
'Benicio' : 'Beneece seeyo',
'Euripides' : 'your rip id dease',
'F. Scott' : 'eff scott',
'Aeschylus' : 'es skull less',
'Intl.' : 'international',
'NAACP' : 'N double A C P',
'their lives' : 'their lyves',
'our lives' : 'our lyves',
'the lives' : 'the lyves',
'many lives' : 'many lyves',
'Kabul' : 'Cobble',
'Khaled' : 'Ha led',
'Hosseini' : 'Ho sane E',
'Wachowski' : 'Walk cow ski',
'your lives' : 'your lyves',
'Nietzschean' : 'neatcha ian',
'Ayn Rand' : 'I yin Rand',
'Lt. Col.' : 'Lieutenant colonel',
'DiCaprio' : 'Decap rio',
'Poitier' : 'Puwa tea A',
'DeMille' : 'dumb ill',
'A. O. Scott' : 'A O Scott',
'Carell' : 'car L',
'4.0' : 'four point oh',
'Zemeckis' : 'Zemeck iss',
'J. K. Simmons' : 'jay kay simmons',
'Les Misérables' : 'lay me zarabla',
'Les Miserables' : 'lay me zarabla',
'Kunis' : 'Kooniss',
'widescreen' : 'wide screen',
'S/M' : 'ess and em',
'sadomaso' : 'saidoe maso',
'Oedipus' : 'Edapus',
'Oedipal' : 'Edapull',
'Weisz' : 'Vice',
'Chrissake' : 'Cry sake',
'Stradlater' : 'Stradd ladder',
'crumby' : 'crummy',
'Josef' : 'Yo zuf',
'DeLuise' : 'Del lou-ease',
'crumbier' : 'crummier',
'Mercutio' : 'mur kiu she oh',
'Mrs ' : 'Mrs. ',
'Antolini' : 'antoleenie',
"Brolin" : "brole lin",
"Domhnall" : "Dominull",
'Eilis' : '"A" lish',
"Ejiofor" : "edgy oh four",
'Jean-Paul' : 'Zhan Paul',
'candide' : 'con deed',
"Cervantes" : "sair-von tess",
"Goethe" : 'gurta',
'Thomas Mann' : 'Toe moss Munn',
'Saint-Exupery' : 'Sawn Tek Soup parie',
'Mallarmé' : 'Mall arm may',
'Stéphane' : 'Steff on',
"Paglia" : "Palia",
"Maugham" : "maw um",
'Prokofiev' : 'prokofe eeyev',
'Gogol' : 'go goal',
'entendre' : 'on ton dra',
"Nyong'o" : "knee on go",
'Zooey' : 'Zo E',
'Deschanel' : 'Dayshan El',
'Corey Haim' : 'Corey Hame',
'Iwo Jima' : 'E wo jima',
'Edvard Munch' : 'Ed vard Moonk',
'Zelig' : 'zellig',
'verite' : 'very tay',
'Guillermo' : 'ghee yermo',
'Tannhauser' : 'Tahn hoi zer',
'Tannhäuser' : 'Tahn hoi zer',
'Preminger' : 'Preming gur',
'Giacchino' : 'jah kino',
'Madame' : 'Mad am',
'Wiig' : 'Wig',
'Damon' : 'Day min',
"Pinter" : "Pinnter",
"9/11" : 'nine eleven',
'Rogen' : 'Roegen',
'whilst' : 'while',
" vs. " : ' versus ',
'Aykroyd' : 'ack a roid',
'je ne sais quoi' : 'junna say kwa',
'Prufrock' : 'proo frock',
'Cronenberg' : 'Crone in berg',
'Sartre' : 'Sart truh',
'Husserl' : 'Huss earl',
'Michel Foucault' : 'Me shell Foo co',
'Foucault' : 'Foo co',
'Vaclav Havel' : 'vat-slav hah-vell',
'Frankl' : 'Frankel',
'Wagner' : 'Vahgner',
'schl' : 'shell',
'croquet' : 'crow kay',
'Godot' : 'go doe',
'camus' : 'cahm moo',
'Geena' : 'djina',
'baglady' : 'bag lady',
'Prospero' : 'Prosper owe',
'Ovid' : 'Ah vid',
'Herzog' : 'Hairt sog',
'Laurent' : 'low ront',
'Aidan' : '"A" den',
'fiancé' : 'fiance',
"exposé" : 'ex poe zay',
'Onegin' : 'on yeggin',
'Rimbaud' : 'ram bo',
"Nietzsche" : 'neatcha',
'½' : ' and a half',
"John F. Kennedy": "John F Kennedy",
'Goldblum' : 'Gold Bloom',
'Charlize' : 'shar lease',
'Cazale' : 'Cuzzale',
'Bette Davis' : 'Betty Davis',
'John Huston' : 'John Houston',
'Kerouac' : 'care oh whack',
'sonuvabitch' : 'son of a bitch',
'Dickensian' : 'Dick kenzian',
'Wuddaya' : 'wudda yuh',
'°F' : ' degrees Fahrenheit',
'Montaigne' : 'mawn tain',
'Jamesian' : 'James ian',
'Thucydides' : 'Thoo sid did dease',
'fellatio' : 'fellay show',
'Diderot' : 'Deed a row',
'Huguenot' : 'Hew gun Oh',
'Jeunet' : 'Junnay',
'a.k.a.' : 'ay kay ay',
'Jean' : 'Zhan',
'Piaget' : 'pee a jay',
'verité' : 'very tay',
'wunderkind' : 'voonder kinned',
'Chomsky' : 'Tchahmski',
'Hesse' : 'Hess uh',
'Hermann' : 'Hair mon',
'[clarification needed]' : '',
'/' : ', ',
'[...]' : ', ',
'–' : '-',
'…' : ', ',
"’" : "'",
'[' : ', ',
']' : ', ',
"‘" : "'",
'“' : '"',
'”' : '"',
"—" : ', ',
"…" : ', ',
'è' : 'e',
'ł' : 'l',
'á' : 'a',
'Á' : 'A',
'â' : 'a',
'â' : 'a',
'Â' : 'A',
'à' : 'a',
'À' : 'A',
'å' : 'a',
'Å' : 'A',
'ã' : 'a',
'Ã' : 'A',
'ä' : 'a',
'Ä' : 'A',
'æ' : 'ae',
'Æ' : 'ae',
'ç' : 's',
'Ç' : 'S',
'ð' : 'o',
'Ð' : 'D',
'é' : 'e',
'É' : 'E',
'ê' : 'e',
'Ê' : 'E',
'è' : 'e',
'È' : 'E',
'ë' : 'e',
'Ë' : 'E',
'í' : 'i',
'Í' : 'I',
'î' : 'i',
'Î' : 'I',
'ì' : 'i',
'Ì' : 'I',
'ï' : 'i',
'Ï' : 'I',
'ñ' : 'ni',
'Ñ' : 'N',
'ó' : 'o',
'Ó' : 'O',
'ô' : 'o',
'Ô' : 'O',
'ò' : 'o',
'Ò' : 'o',
'ø' : 'o',
'Ø' : 'O',
'õ' : 'o',
'Õ' : 'O',
'ö' : 'o',
'Ö' : 'O',
'ß' : 'ss',
'þ' : 'b',
'š' : 's',
'Š' : 'S',
'Þ' : 'b',
'ú' : 'u',
'Ú' : 'U',
'û' : 'u',
'Û' : 'U',
'ù' : 'u',
'Ù' : 'U',
'ü' : 'u',
'Ü' : 'U',
'Ō' : 'O',
'ō' : 'o',
'ý' : 'y',
'Ý' : 'Y',
'ÿ' : 'y',
'Brontë' : 'Bron tay',
'Bronte' : 'Bron tay',
'menage a trois' : 'may nadge a trois',
}
clipboard = '';
f1 = open(filename, 'r')
for line in f1:
newline = line
for i, v in searchreplace1.items():
newline = newline.replace(str(i), str(v))
for i, v in searchreplace2.items():
newline = newline.replace(str(i), str(v))
newline = re.sub('\[\d+\]', '', newline);
newline = re.sub('Chapter (IX|IV|V?I{0,3})\b', lambda match: "Chapter {0} ".format(replaceRomanNumerals(match.group(1))), newline);
newline = re.sub('(Act[s]?) (IX|IV|V?I{0,3})(\n|\s|[,.])', lambda match: "{0}".format(match.group(1) + " " + replaceRomanNumerals(match.group(2))) + match.group(3), newline);
newline = re.sub('Scene (IX|IV|V?I{0,3})\b', lambda match: "Scene {0} ".format(replaceRomanNumerals(match.group(1))), newline);
newline = re.sub('([A-Z][a-z]+) (IX|IV|V?I{0,3})\b', lambda match: "{0} {1} ".format(match.group(1), replaceRomanNumeralsOrdinal(match.group(2))), newline);
newline = re.sub('£(\d+)', r'\1 pounds', newline);
newline = re.sub('\[note\s[0-9]+\]', '', newline);
newline = re.sub('\(([0-9][0-9]{0,2})\)', r'', newline); # remove spaces after initials
newline = re.sub('([A-Z])\.([A-Z])\.', r'\1 \2 ', newline); # remove spaces after initials
newline = re.sub('([A-Z])\.\s([A-Z])\.\s', r'\1 \2 ', newline); # remove spaces after initials
newline = re.sub('\$(\d+)\.([0-9])\smillion', r'\1 point \2 million dollars', newline); # remove spaces after initials
newline = re.sub('(\d+)-(\d+)', r'\1 to \2', newline);
newline = re.sub('\(i\)','(1),', newline);
newline = re.sub('\(ii\)','(2),', newline);
newline = re.sub('\(iii\)','(3),', newline);
newline = re.sub('\(iv\)','(4),', newline);
newline = re.sub('\(v\)','(5),', newline);
newline = re.sub('\(vi\)','(6),', newline);
newline = re.sub('\(vii\)','(7),', newline);
newline = re.sub('\(viii\)','(8),', newline);
newline = re.sub('\(ix\)','(9),', newline);
newline = re.sub('([A-Z])\.\s', r'\1 ', newline); # remove dot after single capital letter
#newline = re.sub('([A-Z]\w+)\s\(([A-Z]\w+(\s)?)+\)', r'\1', newline); # gets rid of actor names with first and last name
newline = re.sub('\n','; ; \n', newline);
clipboard = clipboard + newline;
f1.close()
sendToClipBoard(clipboard)