X-Git-Url: http://iramuteq.org/git?p=iramuteq;a=blobdiff_plain;f=import_txm.py;fp=import_txm.py;h=0dfd1ebb82e7d61f50f8b3f4cbcef97f3921317d;hp=675a9c919d790ce67f779994e517c4934a3c2df5;hb=46fe1c98d3c43f5bce9d8acb6d0ee24b5299fd85;hpb=98bb81e8b6020fdaecdaaed835148ab86d9da728 diff --git a/import_txm.py b/import_txm.py index 675a9c9..0dfd1eb 100644 --- a/import_txm.py +++ b/import_txm.py @@ -9,12 +9,6 @@ import os import xml.sax import glob - - -#infiledir = '/home/pierre/TXM/corpus/voeux-bin/txm/VOEUX/' -#fileout = 'VOEUXExportfromTXM.txt' - - class TXMParser(xml.sax.ContentHandler) : def __init__(self, fileout, encodage_out) : self.fileout = fileout @@ -63,17 +57,14 @@ class TXMParser(xml.sax.ContentHandler) : self.fileout.write(sent.encode(self.encodage_out)) self.sent = [] - - -class TXM2IRA : - def __init__(self, pathin, fileout, encodage_in, encodage_out) : +def TXM2IRA(pathin, fileout, encodage_in, encodage_out) : parser = xml.sax.make_parser() files = glob.glob(os.path.join(pathin,'*.xml')) + if len(files) == 0 : + return 'nofile' with open(fileout, 'w') as fout : parser.setContentHandler(TXMParser(fout, encodage_out)) for f in files : parser.parse(open(f, 'r')) fout.write('\n\n') - print 'done' - -#TXM2IRA(infiledir, fileout) + return None \ No newline at end of file