########################################################################### # Wagon : predicted boundary inserter # Written by Kyuchul Yoon ( kyoon@ling.osu.edu ) # Inserts boundaries (including non-boundaries) to TextGrid files that correspond to .heldfile (held-out file). # The model (file-07.model) was created with file-07.ignore, .trainfile and tested against .heldfile, producing file-07.predicted, # from which the boundaries to be inserted got extracted. # The output textgrids will enable users to see what types of errors were committed by the Wagon model (file-07.model) # A new boundary tier (predicted) is inserted. # Irrelevant tiers (that are ignored by the .ignore file) are not displayed. # ignore file number: # (00) POS alone # (01) POS + PC1(ultimate) # (02) POS + distance # (03) POS + morph.identity # (04) POS + PC1 + distance # (05) POS + PC1 + morph.identity # (06) POS + distance + morph.identity # (07) POS + PC1 + distance + morph.identity <== 8th ignore file (filename: ignore-07.ignore) performed best # Tiers to be displayed # POS: -1 0 +1 # PC1: -3 -2 -1 0 +1 +2 +3 # distance: tok.len.in.sylls + dst.(syl,eoj).pr.AP + dst.(syl,eoj).pr.IP # morph.identity: itself ########################################################################## # Specify files and folders form Select files word subFolderToProcess test-TextGrid word fileExtOfDoneFiles wagon.36 word predictionFile file-07.predicted integer wordTier 1 integer existingBoundaryTier 2 word tierNameToInsert predicted.boundary word outputFileExt predicted word outFolder predicted-TextGrid endform # Get the list of filenames of TextGrid.done files Create Strings as file list... fileList 'subFolderToProcess$'\*.'fileExtOfDoneFiles$' Sort numFiles = Get number of strings pause 'numFiles' labeled textgrids identified. Continue? # Read the file-07.predicted file and initialize the line counter to 1 Read Strings from raw text file... 'predictionFile$' Rename... predictedFile numTotalLines = Get number of strings iLineOfPredictedFile = 1 # Loop throught each file select Strings fileList for iFile to numFiles select Strings fileList # Get the name for a TextGrid.done file doneFile$ = Get string... iFile Read from file... 'subFolderToProcess$'\'doneFile$' Rename... textgrid numTiers = Get number of tiers numIntervals = Get number of intervals... 1 # Compose outFile name outFilePrefix$ = doneFile$ - fileExtOfDoneFiles$ outFile$ = outFilePrefix$ + outputFileExt$ ## Ad-hoc removal of unnecessary tiers Remove tier... 41 Remove tier... 40 Remove tier... 39 Remove tier... 38 Remove tier... 37 Remove tier... 36 Remove tier... 35 Remove tier... 34 Remove tier... 26 Remove tier... 25 Remove tier... 22 Remove tier... 21 Remove tier... 19 Remove tier... 18 Remove tier... 17 Remove tier... 16 Remove tier... 11 Remove tier... 10 Remove tier... 9 Remove tier... 8 # Insert the prediction tier predictedBoundaryTier = existingBoundaryTier+1 Insert point tier... predictedBoundaryTier 'tierNameToInsert$' # Insert default points to the new tier according to the "end" time of the word tier for iToken from 2 to (numIntervals-1) endTimeWordTier = Get end point... wordTier iToken Insert point... predictedBoundaryTier endTimeWordTier select Strings predictedFile predictedBoundary$ = Get string... iLineOfPredictedFile select TextGrid textgrid Set point text... predictedBoundaryTier (iToken-1) 'predictedBoundary$' iLineOfPredictedFile = iLineOfPredictedFile + 1 endfor filedelete 'outFolder$'\'outFile$' Write to text file... 'outFolder$'\'outFile$' Remove endfor # Check if all the lines in file-07.predicted have been consumed if numTotalLines <> (iLineOfPredictedFile-1) linesRemaining = numTotalLines - (iLineOfPredictedFile-1) pause Some lines remain in file-07.predicted!!! echo Total 'numTotalLines' Lines remaining 'linesRemaining' endif select Strings fileList plus Strings predictedFile Remove #### END OF SCRIPT ####