#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-import re
import os
import optparse
-import codecs
-
-REGEXES = [
- (r'<rdf:RDF[^>]*>(.|\n)*?</rdf:RDF>', ''),
- (r'<motyw[^>]*>(.|\n)*?</motyw>', ''),
- ('<(begin|end)\\sid=[\'|"][b|e]\\d+[\'|"]\\s/>', ''),
- (r'<extra>((<!--<(elementy_poczatkowe|tekst_glowny)>-->)|(<!--</(elementy_poczatkowe|tekst_glowny)>-->))</extra>', ''),
- (r'<uwaga>[^<]*</uwaga>', ''),
- (r'<p[a|e|r|t]>(.|\n)*?</p>', ''),
- (r'<[^>]+>', ''),
- (r'/$', ''),
- (r'---', u'—'),
- (r'--', u'-'),
- (r',,', u'„'),
- (r'"', u'”'),
-]
+from librarian import text
if __name__ == '__main__':
print input_filename
output_filename = os.path.splitext(input_filename)[0] + '.txt'
-
- xml = codecs.open(input_filename, 'r', encoding='utf-8').read()
- for pattern, repl in REGEXES:
- # print pattern, repl
- xml, n = re.subn(pattern, repl, xml)
- # print n
-
- output = codecs.open(output_filename, 'w', encoding='utf-8')
- output.write(xml)
+ text.transform(input_filename, output_filename)