#!/usr/local/bin/perl -w #PERL-CGI to parse sentences inputted from HTML forms "DIPETT on the Web" using #dipw #Last modified: October 30, 1997. #Author: Kong Wei Yew $dip = "/local/apache/cgi-bin/dipett/dipw1"; #$empty = "/home/kaml1/usr5/tanka/share/public_html/cgi-bin/empty.txt"; $refer = $ENV{'HTTP_REFERER'}; $refer =~ s:[^/]*$::; $refer = "http://www.site.uottawa.ca/" unless $refer; ### to change all "%__" strings into legible characters and putting them into ### associative arrays foreach (split('&', $ENV{'QUERY_STRING'})){ s/\+/ /g; ($name, $value) = split('=', $_, 2); $name =~ s/%(..)/sprintf("%c",hex($1))/ge; $value =~ s/%(..)/sprintf("%c",hex($1))/ge; $in{$name} .= "," if defined($in{$name}); $in{$name} .= $value; } ### check to go to error screen when no sentence input if ($in{'s'} eq ""){ $load = 'error0fr.html'; } ### check to go to error screen when bad time allowance input elsif ($in{'t'} =~ /\D/){ $load = 'error1fr.html'; } else { $inputsentence = $in{'s'}; ### to get rid of " and to replace ` with ' $in{'s'} =~ s/\"//ge; $in{'s'} =~ s/\`/\'/ge; ### to prepare sentence for dip executable $in{'s'} =~ s/(\W)/\\$1/g; ### to add a period if missing if ($in{'s'} =~ /\w$/){ $in{'s'} .= "."; } ### to add " to beginning and end of sentence(s) $tempstring = "\"" . $in{'s'} . "\""; $in{'s'} = $tempstring; ### time allowance defaults and maxima if ($in{'t'} eq ""){ $in{'t'} = 30; } if ($in{'t'} > 180){ $in{'t'} = 180; } if ($in{'t'} eq "0"){ $in{'t'} = 30; } $options = "-t$in{'t'}"; if ($in{'p'} eq "y"){ $options .= " -pr"; } # open(INFO, $empty); ###open for comparison # @empty = ; # close(INFO); ###parse sentence using dip, then collect dip output open(DIP, qq[echo $options "$in{'s'}" | $dip |]); while (){@dip = ;} close(DIP); if (@dip eq ""){ $load = 'error2fr.html'; ###when dip has no output } ###error2fr.html may be obsolete and never used, but just in case else { $load = 'done'; ###when everything is ok } } if ($load ne 'done'){ ###to show error screen(s) print < Parsing... EOF } else{ ### to print final legible output for user to see print < Parser Return

Parser Return

Inputted Sentence(s): $inputsentence
Inputted time allowance: $in{'t'} second(s)
Options: $options
Query String: $ENV{'QUERY_STRING'}

Parsed Data:

@dip


All parse time values are in milliseconds. If you do not see a parse tree for a sentence, it means that DIPETT has been unable to parse that sentence: go back to the parser screen, modify the structure of that sentence, and parse again.

Thank you for using DIPETT on the Web.

[Back to Parser Screen]

EOF } ###end