########################################################################## # 32.phrasal.category.penultimate.of.-1.previous.token tier extractor for Wagon: # Written by Kyuchul Yoon ( kyoon@ling.osu.edu ) # Extracts from a set of .TextGrid.lab files 32.phrasal.category.penultimate.of.-1.previous.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 31.phrasal.category.penultimate.of.-2.previous.token # and write the output files into 10.wagon-features\32.phrasal.category.penultimate.of.-1.previous.token # The filename of the output files are .wagon.32 ########################################################################## form Select files word subFolderToProcess 10.wagon-features\31.phrasal.category.penultimate.of.-2.previous.token word fileExtOfDoneFiles wagon.31 integer phrCatTierToUse 34 word outputSubFolder 10.wagon-features\32.phrasal.category.penultimate.of.-1.previous.token word tierNameToAdd -1.PhrCat.penult choice outputFileExt: 1 button wagon.32 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 2, then set the interval text to zero, otherwise # set it with the penultimate PhrCat one tokens away to the left if iToken <3 Set interval text... (numTiers+1) iToken 0 else phrCatPenult$ = Get label of interval... phrCatTierToUse (iToken-1) Set interval text... (numTiers+1) iToken 'phrCatPenult$' endif endfor Edit pause Write to text file... 'outputSubFolder$'\'filePrefix$''outputFileExt$' Remove endfor select Strings fileList Remove #### END OF SCRIPT ####