############################################################### # predicted-actual-for-APs-based-on-space-delimitation.praat # Given textgrids, the script will create a text file with # two column, where the 1st column lists predicted AP # breaks based on orthographic spaces and the 2nd column # lists the actual observed AP breaks from K-ToBI labels. ############################################################### form Specify files and folders word inFolder_(with_textgrids) AP-confusion-table--05.lab.TextGrid.after.LTS.scheme.ALL-CORRECTED word outFile_(to_be_created) confusion-AP-prediction.raw-count natural wordTier 1 natural phonologyTier 3 endform Create Strings as file list... fileListObj 'inFolder$'/*.TextGrid Sort numFiles = Get number of strings fileappend 'outFile$' ACTUAL'tab$'PREDICTED'tab$'TEXTGRID'tab$'TOKEN'newline$' for iFile to numFiles select Strings fileListObj fileName$ = Get string... iFile Read from file... 'inFolder$'/'fileName$' Rename... textgridObj numIntervals = Get number of intervals... wordTier numPoints = Get number of points... phonologyTier for iToken from 2 to (numIntervals-1) tokenText$ = Get label of interval... wordTier iToken endTimeTokenText = Get end point... wordTier iToken iPoint = 1 flagFound = 0 while (flagFound = 0 and iPoint <= numPoints) timeOfPoint = Get time of point... phonologyTier iPoint if endTimeTokenText = timeOfPoint flagFound = 1 tobiLabel$ = Get label of point... phonologyTier iPoint fileappend 'outFile$' 'tobiLabel$''tab$'LHa'tab$' ...'fileName$''tab$''tokenText$''newline$' endif iPoint = iPoint + 1 endwhile # If still not found, then there's no AP label # at the end of the token. No observed AP break there. if flagFound = 0 fileappend 'outFile$' non-break'tab$'LHa'tab$' ...'fileName$''tab$''tokenText$''newline$' endif endfor Remove endfor select Strings fileListObj Remove ########## END