def fixEmDash(self): if not self.gettingSize: self.progress = "Fixing em-dashes..." document2 = self.document2 for paragraph in document2.paragraphs: for run in paragraph.runs: text = run.text text = text.replace('---"', u'---”') text = text.replace('"---', u'“---') text = text.replace("---", u"—") text = regexlib.replaceSub(text, " — ", "—") text = regexlib.replaceSub(text, " —", "—") text = regexlib.replaceSub(text, "— ", "—") run.text = text self.step += 1
def fixEmDash(self): if not self.gettingSize: self.progress = "Fixing em-dashes..." document2 = self.document2 for paragraph in document2.paragraphs: for run in paragraph.runs: text = run.text text = text.replace('---"',u'---”') text = text.replace('"---',u'“---') text = text.replace("---",u"—") text = regexlib.replaceSub(text," — ","—") text = regexlib.replaceSub(text," —","—") text = regexlib.replaceSub(text,"— ","—") run.text = text self.step += 1
def fixDoubleSpace(self): if not self.gettingSize: self.progress = "Fixing double spaces..." for paragraph in self.document2.paragraphs: for run in paragraph.runs: while regexlib.match(run.text, " ") != -1: run.text = regexlib.replaceSub(run.text, " ", " ") self.step += 1
def fixEllipses(self): if not self.gettingSize: self.progress = "Fixing ellipses..." for paragraph in self.document2.paragraphs: for run in paragraph.runs: text = run.text text = regexlib.replaceSub(text, " . . . . .", "...") text = regexlib.replaceSub(text, " . . . .", "...") text = regexlib.replaceSub(text, " . . .", "...") text = regexlib.replaceSub(text, ". . . . .", "...") text = regexlib.replaceSub(text, ". . . .", "...") text = regexlib.replaceSub(text, ". . .", "...") text = regexlib.replaceSub(text, ".....", "...") text = regexlib.replaceSub(text, "....", "...") text = regexlib.replaceSub(text, " . .", u'...”') text = regexlib.replaceSub(text, ". . ", u"“...") run.text = text self.step += 1
def fixEllipses(self): if not self.gettingSize: self.progress = "Fixing ellipses..." for paragraph in self.document2.paragraphs: for run in paragraph.runs: text = run.text text = regexlib.replaceSub(text," . . . . .", "...") text = regexlib.replaceSub(text," . . . .","...") text = regexlib.replaceSub(text," . . .","...") text = regexlib.replaceSub(text,". . . . .", "...") text = regexlib.replaceSub(text,". . . .","...") text = regexlib.replaceSub(text,". . .","...") text = regexlib.replaceSub(text,".....","...") text = regexlib.replaceSub(text,"....","...") text = regexlib.replaceSub(text," . .",u'...”') text = regexlib.replaceSub(text,". . ",u"“...") run.text = text self.step += 1
def fixWords(self): if not self.gettingSize: self.progress = "Fixing words..." for paragraph in self.document2.paragraphs: for run in paragraph.runs: text = run.text text = regexlib.replaceWord(text, "comer", "corner") text = regexlib.replaceWord(text, "bom", "born") text = regexlib.replaceWord(text, "modem", "modern") text = regexlib.replaceWord(text, "tiling", "thing") text = regexlib.replaceWord(text, "diat", "that") text = regexlib.replaceWord(text, "sec", "see") text = regexlib.replaceWord(text, "secs", "sees") text = regexlib.replaceWord(text, "Fd", "I'd") text = regexlib.replaceWord(text, "diem", "them") text = regexlib.replaceWord(text, "Modem", "Modern") text = regexlib.replaceSub(text, "‘Tm", "“I’m") text = regexlib.replaceSub(text, "Td", "“I’d") text = regexlib.replaceWord(text, "tire", "the") text = regexlib.replaceSub(text, "boy friend", "boyfriend") text = regexlib.replaceSub(text, "girl friend", "girlfriend") text = regexlib.replaceWord(text, "Pie", "He") text = regexlib.replaceWord(text, "Fie", "He") run.text = text self.step += 1
def fixWords(self): if not self.gettingSize: self.progress = "Fixing words..." for paragraph in self.document2.paragraphs: for run in paragraph.runs: text = run.text text = regexlib.replaceWord(text,"comer","corner") text = regexlib.replaceWord(text,"bom","born") text = regexlib.replaceWord(text,"modem","modern") text = regexlib.replaceWord(text,"tiling","thing") text = regexlib.replaceWord(text,"diat","that") text = regexlib.replaceWord(text,"sec","see") text = regexlib.replaceWord(text,"secs","sees") text = regexlib.replaceWord(text,"Fd","I'd") text = regexlib.replaceWord(text,"diem","them") text = regexlib.replaceWord(text,"Modem","Modern") text = regexlib.replaceSub(text,"‘Tm","“I’m") text = regexlib.replaceSub(text,"Td","“I’d") text = regexlib.replaceWord(text,"tire","the") text = regexlib.replaceSub(text,"boy friend","boyfriend") text = regexlib.replaceSub(text,"girl friend","girlfriend") text = regexlib.replaceWord(text,"Pie", "He") text = regexlib.replaceWord(text,"Fie", "He") run.text = text self.step += 1
def fixPunctuation(self): if not self.gettingSize: self.progress = "Fixing punctuation..." for paragraph in self.document2.paragraphs: for run in paragraph.runs: text = run.text #Hyphens text = regexlib.removeSub(text, " -") text = regexlib.replaceSub(text, "- ", "-") #Misc text = regexlib.replaceSub(text, "/", "I") text = regexlib.removeSub(text, "\\") text = regexlib.removeSub(text, "^") #Asterisks text = regexlib.replaceSub(text, "* * * *", "& & & &") text = regexlib.removeSub(text, "*") text = regexlib.replaceSub(text, "& & & &", "* * * *") # Periods and Spacing text = regexlib.replaceSub(text, "# .#", "# #") text = regexlib.replaceSub(text, " ", " ") text = regexlib.replaceSub(text, "“ ‘", "“‘") run.text = text self.step += 1
def fixPunctuation(self): if not self.gettingSize: self.progress = "Fixing punctuation..." for paragraph in self.document2.paragraphs: for run in paragraph.runs: text = run.text #Hyphens text = regexlib.removeSub(text," -") text = regexlib.replaceSub(text,"- ","-") #Misc text = regexlib.replaceSub(text,"/","I") text = regexlib.removeSub(text,"\\") text = regexlib.removeSub(text,"^") #Asterisks text = regexlib.replaceSub(text,"* * * *", "& & & &") text = regexlib.removeSub(text,"*") text = regexlib.replaceSub(text,"& & & &", "* * * *") # Periods and Spacing text = regexlib.replaceSub(text,"# .#","# #") text = regexlib.replaceSub(text," "," ") text = regexlib.replaceSub(text,"“ ‘","“‘") run.text = text self.step += 1
def fixApostrophes(self): if not self.gettingSize: self.progress = "Fixing apostrophes..." for paragraph in self.document2.paragraphs: for run in paragraph.runs: text = run.text text = regexlib.replaceSub(text, "''", "\"") text = regexlib.replaceSub(text, " '", u' ‘') text = regexlib.replaceSub(text, "' ", u'’ ') text = regexlib.replaceSub(text, ".'", u'.’') text = regexlib.replaceSub(text, ",'", u',’') text = regexlib.replaceSub(text, "!'", u'!’') text = regexlib.replaceSub(text, "?'", u'?’') text = regexlib.replaceSub(text, "...'", u'...’') text = regexlib.replaceSub(text, "'.", u'’.') text = regexlib.replaceSub(text, "#—'#", u'#—‘#') text = regexlib.replaceSub(text, "#'—#", u'#’—#') text = regexlib.replaceSub(text, "#—'", u'#—’') text = regexlib.replaceSub(text, "'—#", u'‘—#') text = regexlib.replaceSub(text, "',", u'’,') text = regexlib.replaceSub(text, "'!", u'’!') text = regexlib.replaceSub(text, "'?", u'’?') text = regexlib.replaceSub(text, "'...", u'’...') text = regexlib.replaceSub(text, "#'#", u'#’#') text = regexlib.replaceSub(text, "'", u'‘') run.text = text self.step += 1
def fixQuotations(self): if not self.gettingSize: self.progress = "Fixing quotations..." for paragraph in self.document2.paragraphs: for run in paragraph.runs: text = run.text text = regexlib.replaceSub(text, ' "', u' “') text = regexlib.replaceSub(text, '" ', u'” ') text = regexlib.replaceSub(text, '."', u'.”') text = regexlib.replaceSub(text, ',"', u',”') text = regexlib.replaceSub(text, '!"', u'!”') text = regexlib.replaceSub(text, '?"', u'?”') text = regexlib.replaceSub(text, '..."', u'...”') text = regexlib.replaceSub(text, '#—"#', u'#—“#') text = regexlib.replaceSub(text, '#"—#', u'#”—#') text = regexlib.replaceSub(text, '#—"', u'#—”') text = regexlib.replaceSub(text, '"—#', u'“—#') text = regexlib.replaceSub(text, '’"', u'’”') text = regexlib.replaceSub(text, '\'"', u'’”') text = regexlib.replaceSub(text, '";', u'”;') text = regexlib.replaceSub(text, '":', u'”:') text = regexlib.replaceSub(text, "' \"", u'’”') text = regexlib.replaceSub(text, "’ \"", u'’”') text = regexlib.replaceSub(text, '"', u'“') text = regexlib.replaceSub(text, "”’", u'’”') run.text = text self.step += 1
def fixApostrophes(self): if not self.gettingSize: self.progress = "Fixing apostrophes..." for paragraph in self.document2.paragraphs: for run in paragraph.runs: text = run.text text = regexlib.replaceSub(text,"''","\"") text = regexlib.replaceSub(text," '",u' ‘') text = regexlib.replaceSub(text,"' ",u'’ ') text = regexlib.replaceSub(text,".'",u'.’') text = regexlib.replaceSub(text,",'",u',’') text = regexlib.replaceSub(text,"!'",u'!’') text = regexlib.replaceSub(text,"?'",u'?’') text = regexlib.replaceSub(text,"...'",u'...’') text = regexlib.replaceSub(text,"'.",u'’.') text = regexlib.replaceSub(text,"#—'#",u'#—‘#') text = regexlib.replaceSub(text,"#'—#",u'#’—#') text = regexlib.replaceSub(text,"#—'",u'#—’') text = regexlib.replaceSub(text,"'—#",u'‘—#') text = regexlib.replaceSub(text,"',",u'’,') text = regexlib.replaceSub(text,"'!",u'’!') text = regexlib.replaceSub(text,"'?",u'’?') text = regexlib.replaceSub(text,"'...",u'’...') text = regexlib.replaceSub(text,"#'#",u'#’#') text = regexlib.replaceSub(text,"'",u'‘') run.text = text self.step += 1
def fixQuotations(self): if not self.gettingSize: self.progress = "Fixing quotations..." for paragraph in self.document2.paragraphs: for run in paragraph.runs: text = run.text text = regexlib.replaceSub(text,' "',u' “') text = regexlib.replaceSub(text,'" ',u'” ') text = regexlib.replaceSub(text,'."',u'.”') text = regexlib.replaceSub(text,',"',u',”') text = regexlib.replaceSub(text,'!"',u'!”') text = regexlib.replaceSub(text,'?"',u'?”') text = regexlib.replaceSub(text,'..."',u'...”') text = regexlib.replaceSub(text,'#—"#',u'#—“#') text = regexlib.replaceSub(text,'#"—#',u'#”—#') text = regexlib.replaceSub(text,'#—"',u'#—”') text = regexlib.replaceSub(text,'"—#',u'“—#') text = regexlib.replaceSub(text,'’"',u'’”') text = regexlib.replaceSub(text,'\'"',u'’”') text = regexlib.replaceSub(text,'";',u'”;') text = regexlib.replaceSub(text,'":',u'”:') text = regexlib.replaceSub(text,"' \"",u'’”') text = regexlib.replaceSub(text,"’ \"",u'’”') text = regexlib.replaceSub(text,'"',u'“') text = regexlib.replaceSub(text,"”’",u'’”') run.text = text self.step += 1