Neustrukturierung der Python Skripte als Paket.
[wortliste.git] / skripte / python / lang_s / long_s_quasihyph.py
blob0099d8a234771edf71913ca298421eeae0cdb9e3
1 #!/usr/bin/env python
2 # -*- coding: utf8 -*-
3 # :Copyright: © 2011 Günter Milde.
4 # Released without warranty under the terms of the
5 # GNU General Public License (v. 2 or later)
6 # :Id: $Id: $
8 # long_s_quasihyph.py:
9 # ============================================================
11 u"""Filter zum Wandeln von Wörtern mit langem S in
12 Pseudo-Trennbeispiele (ausſagen -> auss-agen, eſſen -> es-s-en)."""
14 import sys, optparse, re
17 usage = u'%prog [Optionen]\n' + __doc__
18 parser = optparse.OptionParser(usage=usage)
19 parser.add_option('-e', '--encoding', dest='encoding',
20 help=u'Kodierung der Ausgabe, '
21 u'Vorgabe "iso-8859-15"',
22 default='iso-8859-15')
24 (options, args) = parser.parse_args()
26 lines = (line.decode('utf-8') for line in sys.stdin)
28 words = (word.replace(u'ſ', u's-').replace(u'S', u's-')
29 for word in lines)
31 sys.stdout.writelines(line.encode(options.encoding) for line in words)