################################################################################## # 36.romanized.current.token tier extractor for Wagon: # Written by Kyuchul Yoon ( kyoon@ling.osu.edu ) # Extracts from a set of .TextGrid.lab files 36.romanized.current.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 35.phrasal.category.penultimate.of.+3.following.token # and write the output files into 10.wagon-features\36.romanized.current.token # The filename of the output files are .wagon.36 ################################################################################## form Select files word subFolderToProcess 10.wagon-features\35.phrasal.category.penultimate.of.+3.following.token word fileExtOfDoneFiles wagon.35 word outputSubFolder 10.wagon-features\36.romanized.current.token word tierNameToAdd rom.tok choice outputFileExt: 1 button wagon.36 endform # Get the list of filenames of TextGrid.lab 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.lab 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 ############# Loop through each interval (eojeol) and extract info ############### for iToken from 2 to (numIntervals-1) tempIntervalText$ = Get label of interval... (numTiers+1) iToken indexOfSlash = index(tempIntervalText$, "/") intervalText$ = left$(tempIntervalText$, (indexOfSlash-1)) Set interval text... (numTiers+1) iToken 'intervalText$' endfor Edit pause Write to text file... 'outputSubFolder$'\'filePrefix$''outputFileExt$' Remove endfor select Strings fileList Remove #### END OF SCRIPT ####