X-Git-Url: http://iramuteq.org/git?p=iramuteq;a=blobdiff_plain;f=import_txm.py;h=bc55fc2a378ff6e18424a9ac622567d5dae798a4;hp=6ef0c2b439d824caf03bf65c06c93abe91685362;hb=94db7716520d397ab87a1a7730d2d0fd9f873da0;hpb=970a30c06f7399edfb9d0a6823776c611f066af1 diff --git a/import_txm.py b/import_txm.py index 6ef0c2b..bc55fc2 100644 --- a/import_txm.py +++ b/import_txm.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- #Author: Pierre Ratinaud #Copyright (c) 2013 Pierre Ratinaud -#Lisense: GNU/GPL +#License: GNU/GPL import os @@ -35,7 +35,7 @@ class TXMParser(xml.sax.ContentHandler) : pass def endElement(self, name) : - if name == 's' : + if name == 's' or name == 'w' : self.printsent() if name == 'p' : self.printsent() @@ -48,7 +48,7 @@ class TXMParser(xml.sax.ContentHandler) : #self.fileout.write(content.encode('utf8')) def text2stars(self, attrs) : - stars = ['_'.join(val).replace(' ', '_').replace("'", '_') for val in attrs.items()] + stars = ['_'.join(val).replace(' ', '_').replace("'", '_').replace('/','').replace('.','').replace(';', '').replace(':', '').replace(u'·','') for val in attrs.items()] stars = [''.join([u'*', val]) for val in stars] stars = u'**** ' + ' '.join(stars) self.fileout.write(stars.encode(self.encodage_out)) @@ -74,5 +74,6 @@ class TXM2IRA : for f in files : parser.parse(open(f, 'r')) fout.write('\n\n') + print 'done' #TXM2IRA(infiledir, fileout)