Package medite :: Package mulce :: Module mulce
[hide private]
[frames] | no frames]

Source Code for Module medite.mulce.mulce

 1  # -*- coding: iso-8859-1 -*- 
 2  # Copyright 20003 - 2008: Julien Bourdaillet (julien.bourdaillet@lip6.fr), Jean-Gabriel Ganascia (jean-gabriel.ganascia@lip6.fr) 
 3  # This file is part of MEDITE. 
 4  # 
 5  #    MEDITE is free software; you can redistribute it and/or modify 
 6  #    it under the terms of the GNU General Public License as published by 
 7  #    the Free Software Foundation; either version 2 of the License, or 
 8  #    (at your option) any later version. 
 9  # 
10  #    MEDITE is distributed in the hope that it will be useful, 
11  #    but WITHOUT ANY WARRANTY; without even the implied warranty of 
12  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
13  #    GNU General Public License for more details. 
14  # 
15  #    You should have received a copy of the GNU General Public License 
16  #    along with Foobar; if not, write to the Free Software 
17  #    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
18   
19  import os,re 
20   
21 -class Extracteur(object):
22 - def extractionApprenantClavardage(self, personne, seance):
23 """Extrait des fichiers texte d'une sessions de clavardage les interventions 24 des chaque apprenant 25 26 @param personne: nom de la personne à extraire 27 @param fichier: nom du fichier de la session de clavardage""" 28 fichier = os.path.join(os.getcwd(), 'mulce', seance + ".txt") 29 fout = os.path.join(os.getcwd(), 'mulce', seance + "_" + personne + ".txt") 30 dz = open(fichier, 'r') 31 out = open(fout,'w') 32 33 ldz = dz.readlines() 34 dz.close() 35 lLines = ldz 36 if len(lLines)==0: raise ValueError,u"Fichier vide" 37 # recherche la personne, case sensitive 38 regex = re.compile("^"+personne) 39 nb_ligne = 0 40 for ligne in lLines: 41 if regex.match(ligne): 42 # match le début réel de l'interventino de la personne 43 pos_dialogue = ligne.find('>>') 44 out.write(ligne[pos_dialogue+2:]) 45 nb_ligne += 1 46 out.close() 47 if nb_ligne == 0: 48 os.remove(fout)
49 50 if __name__ == '__main__': 51 ex = Extracteur() 52 gens = ['Alba', 'Alan','Annie', 'Matt', 'Niels', 'Camille', 'Gary', 'Raymond', 'Ben', 'Sabrina'] 53 seances = ['e0a3_clavardage','e2a4_clavardage', 'e2a4menu'] 54 for personne in gens: 55 for seance in seances: 56 ex.extractionApprenantClavardage(personne, seance) 57