Skip to content

Instantly share code, notes, and snippets.

@bjornkri
Created January 19, 2013 21:22
Show Gist options
  • Save bjornkri/4575260 to your computer and use it in GitHub Desktop.
Save bjornkri/4575260 to your computer and use it in GitHub Desktop.
Sjálfvirkar lagfæringar fyrir prófarkalestur á http://profork.rafbokavefur.is
# -*- 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