########################################################################## # 30.phrasal.category.penultimate.of.-3.previous.token tier extractor for Wagon: # Written by Kyuchul Yoon ( kyoon@ling.osu.edu ) # Extracts from a set of .TextGrid.lab files 30.phrasal.category.penultimate.of.-3.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 29.phrasal.category.penultimate.of.current.token # and write the output files into 10.wagon-features\30.phrasal.category.penultimate.of.-3.previous.token # The filename of the output files are .wagon.30 ########################################################################## form Select files word subFolderToProcess 10.wagon-features\29.phrasal.category.penultimate.of.current.token word fileExtOfDoneFiles wagon.29 integer phrCatTierToUse 34 word outputSubFolder 10.wagon-features\30.phrasal.category.penultimate.of.-3.previous.token word tierNameToAdd -3.PhrCat.penult choice outputFileExt: 1 button wagon.30 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, 3, and 4, then set the interval text to zero, otherwise # set it with the penultimate PhrCat three tokens away to the left if iToken <5 Set interval text... (numTiers+1) iToken 0 else phrCatPenult$ = Get label of interval... phrCatTierToUse (iToken-3) 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 ####