#!/usr/bin/perl -w # 11/2001: Taal en Spraak: run a script # query string selects two numbers: # first selects script, second selects script line # numbers are all 1 based # this time adjusted for the experiment WITH the RC and its fillers! # for a static version: # for foo in {,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9} ; do export # QUERY_STRING=1\&$foo ; ./Exp1.cgi >$foo.html ; done my $statichtml = 0; if ($statichtml == 0) { print "Content-type: text/html\n\n"; } if (!defined $ENV{'QUERY_STRING'}) { $ENV{'QUERY_STRING'} = "1\&1"; } my $qs = $ENV{'QUERY_STRING'}; # export QUERY_STRING='42&bla&bla' my $cnt = 0; my $wo = "/.../exp-w-rc/"; # "/home/.../" or "" my $url = "http://.../Exp2.cgi"; my $item = "???"; # the sentence my $instr = "!?"; # the instruction if ( !( $qs =~ /^[1-3]\&[0-9-][0-9]*$/ ) ) { die "Illegal query string Error: Illegal query string"; } ($lognr,$linenr) = split(/\&/,$qs); # parse query string $url .= "?" . $lognr . "\&" . ($linenr+1); # next page will be... if ($statichtml != 0) { $url = "" . ($linenr+1) . ".html"; } ###################################################################### # pick the right line from the right script open(SCRIPTFILE,"<" . $wo . "script" . $lognr . ".log") || die "Read error Error: cannot read script file $wo script $lognr .log"; $cnt = 1; my $how = "finish"; # past the end -> 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); ###################################################################### # default possibility is "finish" $instr = "Het experiment is nu afgelopen"; $item = "Hartelijk bedankt voor je medewerking!"; ###################################################################### # one possibility: a real item if ($how eq "sentence") { open(SENTFILE,"<" . $wo . "sentences.txt") || die "Read error Error: cannot read item file"; $cnt = 1; my $np1 = "de A"; my $np2 = "met de B"; my $np3 = "met de C"; my $rc = "die bla is"; my $buf = "de bla"; foreach () { 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); $item = "$np1 $np2 $np3 $rc"; # this time WITH the RC # cases 2/3 need the first word to be # removed as they are PPs, not only NPs... # and case one needs downcase $instr = "Maak duidelijk dat het "; # new instructions if ($case == 1) { substr($np1,0,1) =~ tr/A-Z/a-z/; $instr .= $np1; }; if ($case == 2) { $buf = $np2; $buf =~ s/^[^_]*_//g; $instr .= $buf; } if ($case == 3) { $buf = $np3; $buf =~ s/^[^_]*_//g; $instr .= $buf; } $instr .= " is " . $rc; # new instructions # do not forget to make spaces from _ again $instr =~ tr/_/ /; $item =~ tr/_/ /; } ###################################################################### # another possibility: a filler with two possible cases - type one if ($how eq "filler1") { open(SENTFILE,"<" . $wo . "fillers2.1.txt") || die "Read error Error: cannot read filler type 1 file"; $cnt = 1; $np1 = "de A"; my $vp = "VERB ..."; $np2 = "de B"; my $comp = "met de C"; # instr or property... my $agree = "de"; foreach () { 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,$vp,$np2,$comp) = split(';',$dings); # the selected item } $cnt++; } } close(SENTFILE); $item = "$np1 $vp $np2 $comp"; # case 1 needs downcase # see source below for explanation of instr... $instr = "Maak duidelijk dat "; # new instructions # works only for past tense! if ($case == 1) { $agree = $np1; substr($agree,0,1) =~ tr/A-Z/a-z/; # downcase $instr .= $agree . " " . $comp; $agree = $vp; $agree =~ s/_[^_]*//g; # keep only the verb $instr .= " " . $agree; # Maak d. dat de A met de C VERB }; if ($case == 2) { $instr .= $np2 . " "; $comp =~ s/^[^_]*_//g; # remove the "met" $instr .= $comp . " had"; # Maak d. dat de B de C had } # do not forget to make spaces from _ again $instr =~ tr/_/ /; $item =~ tr/_/ /; } ###################################################################### # next possibility: a filler of type 2, again 2 possible cases if ($how eq "filler2") { open(SENTFILE,"<" . $wo . "fillers2.2.txt") || die "Read error Error: cannot read filler type 2 file"; $cnt = 1; $np1 = "de A"; $np2 = "die de B"; $vp = "gekust had"; # this time the ambiguity is: # which np is subj, which is obj? foreach () { 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,$vp) = split(';',$dings); # the selected item } $cnt++; } } close(SENTFILE); $item = "$np1 $np2 $vp"; # case 1 needs downcase and # case 2 needs the first word to be removed... $instr = "Maak duidelijk dat het "; if ($case == 1) { $agree = $np1; substr($agree,0,1) =~ tr/A-Z/a-z/; $instr .= $agree; }; if ($case == 2) { $agree = $np2; $agree =~ s/^[^_]*_//g; # remove the die/dat $instr .= $agree; } $agree =~ s/_[^_]*//g; # keep only the first word $instr .= " is "; if ($agree eq "de") # agreement de/die and het/dat { $instr .= "die " . $vp; } else { $instr .= "dat " . $vp; } # do not forget to make spaces from _ again $instr =~ tr/_/ /; $item =~ tr/_/ /; } ###################################################################### # last possibility: a filler of type 3, again 2 possible cases if ($how eq "filler3") { open(SENTFILE,"<" . $wo . "fillers2.3.txt") || die "Read error Error: cannot read filler type 3 file"; $cnt = 1; $np1 = "de A"; $np2 = "van de B"; $comp = "waar we leuk vinden"; # simple "stress one np" task foreach () { 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,$comp) = split(';',$dings); # the selected item } $cnt++; } } close(SENTFILE); $item = "$np1 $np2 $comp"; # case 1 needs downcase and # case 2 needs the first word to be removed... $instr = "Maak duidelijk dat het "; if ($case == 1) { $agree = $np1; substr($agree,0,1) =~ tr/A-Z/a-z/; $instr .= $agree; }; if ($case == 2) { $agree = $np2; $agree =~ s/^[^_]*_//g; $instr .= $agree; } $agree =~ s/_[^_]*//g; # keep only the first word $instr .= " is " . $comp; # no agreement needed this time # do not forget to make spaces from _ again $instr =~ tr/_/ /; $item =~ tr/_/ /; } ###################################################################### # log what we will be doing open(LOGFILE,">>" . $wo . "taal-exp2.log") || die "Write error Error: cannot write log file"; # exp2 log this time! print LOGFILE "" . localtime() . "\n"; # human readable timestamp print LOGFILE "" . time() . " $how $which $case $lognr $linenr\n"; # unix time, type, sentence, case, script, scriptline print LOGFILE "INST: " . $instr . "\n"; print LOGFILE "ITEM: " . $item . "\n"; close(LOGFILE); ###################################################################### print 'Taal en Spraak Experiment

 

 

'; print "\n" . $instr . "


\ \ " . $item . "\ \ 

"; print " doorgaan

\n"; exit 0;