#!/usr/bin/perl -w # from 11/2001: Taal en Spraak: convert a script to a perceived # attachment questionnaire # now 12/2001: convert all scripts to html templates where we can # make notes about phonology my $cnt = 0; my $lognr = 1; # which script my $item=""; for ($lognr=1;$lognr<=6;$lognr++) { open(QUESTFILE,">phon-notes" . $lognr . ".txt") || die "Could not write phonology notes template\n"; print QUESTFILE "Phonology: Script $lognr\r\n\r\n"; if ($lognr<4) { print QUESTFILE "(without relative clauses)\r\n\r\n"; } else { print QUESTFILE "(with relative clauses)\r\n\r\n"; } $linenr=0; $scpeof=0; while ($scpeof==0) { $linenr++; ###################################################################### # pick the right line from the right script open(SCRIPTFILE," my $which = 1; my $case = 1; foreach () { chomp; if (/......./) { # ignore empty lines if ($cnt == $linenr) { ($how,$which,$case) = split(/\;/); # the selected line } $cnt++; } } close(SCRIPTFILE); if ($how =~ /finish/) { $scpeof = 1; print "Script $lognr had $linenr sentences\n"; } ###################################################################### # default possibility is "finish" ###################################################################### # one possibility: a real item if ($how eq "sentence") { open(SENTFILE,") { chomp; tr/\011/;/; # convert TAB to ; tr/ /_/; # change space to _ s/_*\;/\;/g; # remove trailing spaces s/\;_*/\;/g; # remove leading spaces $dings = $_; if ($dings =~ /................../) { # ignore short lines if ($cnt == $which) { ($np1,$np2,$np3,$rc) = split(';',$dings); # the selected item } $cnt++; } } close(SENTFILE); if ($lognr<4) { # first 3 are w/o RC $item = "$np1 $np2 $np3"; } else { $item = "$np1 $np2 $np3 $rc"; } $item =~ tr/_/ /; print QUESTFILE "$item\r\n\r\n"; } ###################################################################### if ($how =~ /filler/) { print QUESTFILE "--- FILLER ---\r\n\r\n"; } ###################################################################### } # end while script print QUESTFILE "--- END OF FILE ---\r\n\r\n"; close QUESTFILE; } # end for scripts exit 0;