Created
January 19, 2013 21:22
-
-
Save bjornkri/4575260 to your computer and use it in GitHub Desktop.
Sjálfvirkar lagfæringar fyrir prófarkalestur á http://profork.rafbokavefur.is
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import sys | |
import re | |
RULES = [ | |
(r'\n\s+', r'\n'), # Fjarlægja auka línubil fyrir | |
(r'\s+\n', r'\n'), # og eftir línuskil | |
(r'-\n([^\s]+)\s', r'\1\n'), # Sameina orð skipt milli lína | |
(r'—', r'--'), # Breyta þankastrikum í '--' | |
(r'[co]e', r'æ'), # Breyta ce og oe í 'æ' | |
] | |
text = "" | |
for f in sys.stdin: | |
text += f | |
for pattern, substitute in RULES: | |
text = re.sub(pattern, substitute, text) | |
print text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment