diff -r 377c84f956dc -r 193999e56a90 segLibB40.py --- a/segLibB40.py Tue May 26 11:43:51 2020 +0200 +++ b/segLibB40.py Thu Jun 08 09:40:19 2023 +0200 @@ -146,7 +146,7 @@ for p in g: if p > 0: klinkt.append (p) elif -p in klinkt: klinkt.remove (-p) - else: print 'unmatched off-message' + else: print('unmatched off-message') kgroep.append ((t, klinkt[:])) return kgroep @@ -167,7 +167,7 @@ return wtot def analyseK (kgroep, debug=0): - if debug: print 'aantal segmenten', len (kgroep) + if debug: print('aantal segmenten', len (kgroep)) #~ mkWeights (kgroep) #~ mkTemplates () @@ -189,14 +189,14 @@ s01, acc01, xs01 = s012, acc012, xs012 else: segs.append ((j0,j1,s0,acc0,xs0)) - if debug: print j0, j1, s0, acc0 + if debug: print(j0, j1, s0, acc0) j0, j1, j2 = j1, j2, j2 + 1 s0, acc0, xs0 = s1, acc1, xs1 s01, acc01, xs01 = s12, acc12, xs12 s1, acc1, xs1 = s2, acc2, xs2 if j0 < len (weights): segs.append ((j0,j1,s0,acc0,xs0)) - if debug: print j0, j1, s0, acc0 + if debug: print(j0, j1, s0, acc0) return segs, kgroep @@ -204,14 +204,14 @@ f = open ('mids/bwv539p.b40') xs = f.readlines () f.close () - def toint (xs): return map (lambda x: int (x), xs) - events = map (lambda x: toint (x.strip().split()), xs) + def toint (xs): return [int (x) for x in xs] + events = [toint (x.strip().split()) for x in xs] kgroep = readEvents (events) mkWeights (kgroep) mkTemplates () segs, kgroep = analyseK (kgroep, debug=0) - print '%d segs, %d groepen' % (len (segs), len (kgroep)) + print('%d segs, %d groepen' % (len (segs), len (kgroep))) for iseg, jseg, score, acc, rest in segs: - print '---', acc, score + print('---', acc, score) for t, ns in kgroep [iseg:jseg]: - print t, ', '.join (map (b40nm, ns)) + print(t, ', '.join (map (b40nm, ns)))