########################################################################## # 34.phrasal.category.penultimate.of.+2.following.token tier extractor for Wagon: # Written by Kyuchul Yoon ( kyoon@ling.osu.edu ) # Extracts from a set of .TextGrid.lab files 34.phrasal.category.penultimate.of.+2.following.token data field for Wagon training # The script assumes that you already have the TextGrid files labelled by professional K-ToBI labelers. # The script will read in all the TextGrid.lab files one by one from the directory 33.phrasal.category.penultimate.of.+1.following.token # and write the output files into 10.wagon-features\34.phrasal.category.penultimate.of.+2.following.token # The filename of the output files are .wagon.34 ########################################################################## form Select files word subFolderToProcess 10.wagon-features\33.phrasal.category.penultimate.of.+1.following.token word fileExtOfDoneFiles wagon.33 integer phrCatTierToUse 34 word outputSubFolder 10.wagon-features\34.phrasal.category.penultimate.of.+2.following.token word tierNameToAdd +2.PhrCat.penult choice outputFileExt: 1 button wagon.34 endform # Get the list of filenames of TextGrid. files Create Strings as file list... fileList 'subFolderToProcess$'\*.'fileExtOfDoneFiles$' Sort numFiles = Get number of strings pause 'numFiles' labeled textgrids identified. Continue? # Loop throught each file for iFile to numFiles select Strings fileList # Get the name for a TextGrid file doneFile$ = Get string... iFile filePrefix$ = doneFile$ - fileExtOfDoneFiles$ Read from file... 'subFolderToProcess$'\'doneFile$' Rename... textGrid numIntervals = Get number of intervals... 1 # Get the number of tiers so that you can add an additional tier at the end numTiers = Get number of tiers Duplicate tier... 1 (numTiers+1) 'tierNameToAdd$' # Set the first/last interval text to naught Set interval text... (numTiers+1) 1 Set interval text... (numTiers+1) numIntervals for iToken from 2 to (numIntervals-1) # If iToken is the last two, then set the interval text to zero, otherwise # set it with the penultimate PhrCat two tokens away to the right if iToken < (numIntervals-2) phrCatPenult$ = Get label of interval... phrCatTierToUse (iToken+2) Set interval text... (numTiers+1) iToken 'phrCatPenult$' else Set interval text... (numTiers+1) iToken 0 endif endfor Edit pause Write to text file... 'outputSubFolder$'\'filePrefix$''outputFileExt$' Remove endfor select Strings fileList Remove #### END OF SCRIPT ####