git @ Cat's Eye Technologies NaNoGenLab / 4818bb6
Treat `,` and `--` and clause seperators. Chris Pressey 10 years ago
2 changed file(s) with 7 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
6363 Future work
6464 -----------
6565
66 Treat `,` and `--` and clause seperators.
67
68 Keep tweaking the score. Don't swap "that" and "what".
66 Keep tweaking the score. Don't swap "that" and "what". Also problematic:
67 "and" (using it or resulting in it, e.g. swapping off the "h" in "hand".)
68 Should dock the scores for those.
103103
104104
105105 def adjust_case(new, orig):
106 if all([x.isupper() for x in orig]):
106 if all([x.isupper() for x in orig if x.isalpha()]):
107107 return new.upper()
108108 if orig[0].isupper():
109109 return new.capitalize()
130130 for filename in filenames:
131131 with open(filename, 'r') as f:
132132 for line in SentinelCleaner(f, pre=options.pre).lines():
133 line = line.replace('--', ' -- ')
133 line = line.replace('--', '-- ')
134134 words.extend(line.split())
135135 if line == '' and words[-1] is not PARAGRAPH_BREAK:
136136 words.append(PARAGRAPH_BREAK)
149149 if word.endswith(('"', "'")):
150150 word = word[:-1]
151151 sentence.append(word)
152 if word not in ('Mr.', 'Mrs.', 'Dr.') and word.endswith(('.', '!', '?', ';', ':')):
152 if (word not in ('Mr.', 'Mrs.', 'Dr.') and
153 word.endswith(('.', '!', '?', ';', ':', ',', '--'))):
153154 sentences.append(sentence)
154155 sentence = []
155156