########################################################################## # 26.phrasal.category.ultimate.of.+1.following.token tier extractor for Wagon: # Written by Kyuchul Yoon ( kyoon@ling.osu.edu ) # Extracts from a set of .TextGrid.lab files 26.phrasal.category.ultimate.of.+1.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 25.phrasal.category.ultimate.of.-1.previous.token # and write the output files into 10.wagon-features\26.phrasal.category.ultimate.of.+1.following.token # The filename of the output files are .wagon.26 ########################################################################## form Select files word subFolderToProcess 10.wagon-features\25.phrasal.category.ultimate.of.-1.previous.token word fileExtOfDoneFiles wagon.25 integer phrCatTierToUse 27 word outputSubFolder 10.wagon-features\26.phrasal.category.ultimate.of.+1.following.token word tierNameToAdd +1.PhrCat.ult choice outputFileExt: 1 button wagon.26 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 one, then set the interval text to zero, otherwise # set it with the ultimate PhrCat one tokens away to the right if iToken < (numIntervals-1) phrCatUlt$ = Get label of interval... phrCatTierToUse (iToken+1) Set interval text... (numTiers+1) iToken 'phrCatUlt$' 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 ####