1 # -*- coding: utf-8 -*-
2 #Author: Pierre Ratinaud
3 #Copyright (c) 2012, Pierre Ratinaud
10 def __init__(self, parent, corpus, classe, cmd = False) :
13 self.corpus = self.corpus_from_classe(corpus, classe, False)
15 def corpus_from_classe(self, corpus, classe, lem) :
17 ucis_paras_uces = corpus.make_ucis_paras_uces_lems()
19 ucis_paras_uces = corpus.ucis_paras_uces
21 for i, lc in enumerate(corpus.lc) :
24 for uce in corpus.lc0 :
26 ucecltri = ucecl.keys()
27 #ucecltri = [[int(val) for val in uce] for uce in ucecltri]
29 res = [[u'**** *classe_%i ' % ucecl[uce] + ' '.join(corpus.etoiles[uce[0]][uce[1]][uce[2]]), ' '.join(ucis_paras_uces[uce[0]][uce[1]][uce[2]])] for uce in ucecltri if ucecl[uce] == classe]
30 fileout = os.path.dirname(corpus.dictpathout['ira'])
31 fileout = os.path.join(fileout, 'corpus_classe_%i.txt' % classe)
33 with open(fileout,'w') as f :
34 f.write('\n'.join(['\n'.join(uce) for uce in res]))
35 self.parent.filename = fileout
37 self.parent.OpenText()