def testTGA(self): # This is one of the samples proposed in-line by Dafydd path = os.path.join(SAMPLES,"tga.TextGrid") trs = annotationdata.io.read(path) tier = trs.Find('Syllables') t = TierTGA( tier ) t.append_separator('_') tga = t.tga() occurrences = tga.len() self.assertEqual(34, len(occurrences)) total = tga.total() mean = tga.mean() median = tga.median() stdev = tga.stdev() npvi = tga.nPVI() reglin = tga.intercept_slope_original() self.assertEqual(3, occurrences['tg_1']) self.assertEqual(0.57, round(total['tg_1'],2)) self.assertEqual(0.19, round(mean['tg_1'],2)) self.assertEqual(0.14, round(median['tg_1'],2)) self.assertEqual(0.13928, round(stdev['tg_1'],5)) self.assertEqual(94, round(npvi['tg_1'],0)) i,s = reglin['tg_1'] self.assertEqual(0.025, round(i,3)) self.assertEqual(0.165, round(s,3)) self.assertEqual(4, occurrences['tg_33']) self.assertEqual(0.78, round(total['tg_33'],2)) self.assertEqual(0.195, round(mean['tg_33'],3)) self.assertEqual(0.06062, round(stdev['tg_33'],5)) self.assertEqual(53, round(npvi['tg_33'],0)) i,s = reglin['tg_33'] self.assertEqual(0.156, round(i,3)) self.assertEqual(0.026, round(s,3))
# ---------------------------------------------------------------------------- trs = annotationdata.io.read(fileinput) if tieridx < 0 or tieridx > trs.GetSize(): print 'Error: Bad tier number.\n' sys.exit(1) tier = trs[tieridx] # ---------------------------------------------------------------------------- tg = TierTGA( tier ) for s in separators: tg.append_separator( s ) ds = tg.tga() ls = tg.labels() occurrences = ds.len() total = ds.total() mean = ds.mean() median = ds.median() stdev = ds.stdev() npvi = ds.nPVI() regressp = ds.intercept_slope_original() regresst = ds.intercept_slope() # ----------------------------------------------------------------------------