#!/bin/sh -- # This comment tells perl not to loop! eval 'exec /usr/imports/bin/perl5 -S $0 ${1+"$@"}' if 0; ################################################################ # Takes experiment materials specifying items and/or fillers # for a verbs-in-context ratings study, and produces two ratings # survey forms. # # The final_materials.txt input file should contain lines of # the form: # # code verb: item-to-be-rated # Ex. 2 understood: The babysitter and the mother understood the couple. # # This signifies that this stimulus item goes on list 2, that the # verb is 'understood', and that the sentence "The babysitter..." # is what should be rated. The possible codes are: # # 1: include this item in list 1 # 2: include this item in list 2 # B: include this item in both lists # F: include this item in both lists, and it's a filler item # ################################################################ use English; $OUTPUT_AUTOFLUSH = 1; # Handle command-line arguments $numargs = @ARGV; if ($numargs != 2) { die "Usage: $0 final_materials.txt outfile_prefix\n"; } $infile = $ARGV[0]; $outprefix = $ARGV[1]; # Construct materials for the two lists foreach $list (1,2) { # Construct names of the output files $output_list = "$outprefix$list.txt"; $output_key = "$outprefix$list.key"; # Open up the input file and the output files open(IN, "< $infile") || die "Unable to read $infile\n"; open(OUT, "> $output_list") || die "Unable to write $output_list\n"; open(KEY, "> $output_key") || die "Unable to write $output_key\n"; # Initialize counter $counter = 0; # Print top of survey form print OUT "SURVEY FORM\n"; print OUT "Please rate each item on a scale from 1 to 5 according\n", "to how natural the sentence sounds.\n\n"; # Main loop through materials file while ($line = ) { chomp $line; if (($type,$verb,$stimulus) = ($line =~ /([12BFx])\s+(\S+):\s+(.*)\s*$/)) { if ($type eq "$list" || $type eq "B" || $type eq "F") { ++$counter; printf OUT ("Item %2d: 1 2 3 4 5 %s\n"), $counter, $stimulus; print KEY "$counter: $type ($verb)\n"; } } else { die "Line not in correct format: $line\n"; } } # Bottom of survey form print OUT "\nThank you for participating in this survey!\n"; close(IN); close(OUT); close(KEY); }