#!/usr/local/bin/perl #unshift (@INC, "/home/global-language/PERL"); &parse_form_data (*simple_form); $query = $simple_form{'query'}; $frametype = $simple_form{'frametype'}; $type = $simple_form{'type'}; $search = $simple_form{'search'}; $skel = $simple_form{'skel'}; $ctext = $simple_form{'ctext'}; $format = $simple_form{'format'}; $CAT = "/bin/cat"; $SED = "/bin/sed"; $EGREP = "/bin/egrep"; $ZCAT = "/bin/zcat"; $GZCAT = "/bin/zcat"; $SKEL = "/home/global-language/bin/enhaml"; $TAB = "/home/global-language/bin/tab2html"; $GREEK = "/home/global-language/bin/wwwgreek"; $SGMLGREP = "/home/global-language/bin/sgmlgrep3"; #$CGREP = "/home/global-language/bin/fooctextgrep"; $CGREP = "/home/global-language/bin/ctextgrep"; #$CGREP = "/usr/local/share/bin/cgrep"; $MATCH = "/home/global-language/bin/enhammatch.perl"; $VARP = "/home/global-language/bin/varp"; $enfile = "/home/global-language/HTML/enham2.html"; &printheader (); #unless ($frametype eq "frames") { # &printoedbar (); #} if ($frametype eq "frames") { $page = "corpusframe"; $align = "top"; } else { $page = "corpus"; $align = "left"; } if ( $ARGV[0] eq '-p' ) { shift; $printit = 1; } else { $printit = 1; } if ($frametype eq "frames") { # require ("quicksearchframe.pl"); } else { # require ("quicksearch.pl"); } if ($type eq "F1") { $filetype = "First Folio"; $color = "red"; $enfile = "/home/global-language/HTML/F1.hamlet.html"; } elsif ($type eq "Q2") { $filetype = "Second Quarto"; $color = "green"; } elsif ($type eq "F1 Only") { $opt = "F1"; $filetype = "First Folio Only"; $skel = "yes"; $color = "red"; } elsif ($type eq "Q2 Only") { $opt = "Q2"; $filetype = "Second Quarto Only"; $skel = "yes"; $color = "green"; } else { $filetype = "Enfolded"; $color = "blue"; } #require ("authillus.pl"); if ($search eq "yes") { $format = "Exact Spellings"; $qquery = $query; unless ($query =~ /^[0-9]*$/) { if ($ctext > 100) { $ctext = 100; } } if ($query =~ /^[0-9]*$/) { $query =~ s/^/\\b/g; $query =~ s/$/\\b/g; $format = "Exact Spellings"; } if ($format eq "Variant Spellings") { $query = `/home/global-language/bin/varp \"$query\"`; # print "

Variant query is: $query

\n"; } else { $query =~ s/ /\.\*/g; } } if ($search eq "yes" && $skel eq "yes") { unless (open(TARGFILE, "$CAT $enfile | $CGREP -$ctext \"$query\" | $MATCH \"$query\" | $SKEL -$opt | $TAB | $EGREP \"<$opt>|
|
  • \" |")) { die ("could not open target file\n"); } } elsif ($search eq "yes") { unless (open(TARGFILE, "$CAT $enfile | $CGREP -$ctext \"$query\" | $TAB | $MATCH \"$query\" |")) { die ("could not open target file\n"); } } elsif ($skel eq "yes") { unless (open(TARGFILE, "$CAT $enfile | $SKEL -$opt | $TAB | $EGREP \"<$opt>\" |")) { die ("could not open target file\n"); } } else { unless (open(TARGFILE, "$TAB < $enfile |")) { die ("could not open target file\n"); } } if ($search eq "yes") { $header = "Search for \"$qquery\""; } else { $header = "Text"; } print "Enfolded Hamlet: $filetype $header\n"; if ($search eq "yes") { &fulltexts(); } print "

    Enfolded Hamlet: $filetype $header

    \n"; &printhamlettpage(); if ($search eq "yes") { print "
      \n"; } while () { if ($type eq "F1") { s//<\!-- $&/g; s/<\/Q2>/$& -->/g; s//
      $&/g; } elsif ($type eq "Q2") { s//<\!-- $&/g; s/<\/F1>/$& -->/g; } else { s//\{/g; s/<\/Q2>/\}<\/font>/g; s//\</g; s/<\/F1>/\><\/font>/g; s//\|<\/font>/g; } #s/ /\ \ \ \ \ \ \ \ /; #if (/^(.* )/ { # $lnum = length($1); # s/ / /; # for ($count=1; $count <= ($lnum + 8); $count++) { # s/ /\ /; # } #} if (/ *)/) { $tabnum = length($1); for ($count=1; $count <= ($tabnum - 1); $count++) { s/ /\ /; } } ##if (/GB/) { ## s/ ([A-Z][a-z]*)<\/dAuthor>/ $1<\/A><\/dAuthor>/; ## } s//\[$&/; s//\[$&/; s/<\/stage>/$&\]/g; s//$&/g; s/<\/dDate>/$&<\/b>/g; s//
      $&/g; s/<\/quote>/$&<\/blockquote>/g; s//
      $&/g; s/<\/tPage>/$&<\/center>/g; s//{$&/g; s/<\/gloss>/$&}/g; s//[$&/g; s/<\/trailer>/$&]/g; s//$&/g; s/<\/spkr>/$&<\/i>/g; #s//$&<\/a>/g; #s/

      /$&<\/a>/g; s//$&<\/a>/g; s/

      /$&<\/a>/g; s//$&<\/a>/g; s//$2<\/a>/g; s//

      $2<\/a>/g; s/\&th;/\þ/g; s/\&Th;/\Þ/g; s/\&Thorn;/\Þ/g; s/\&ygh;/3/g; s/\&Ygh;/3/g; s/\œ/oe/g; s/\&Oelig;/Oe/g; s/\&asper;\´/\&asperacute;/g; s/\&asper;\`/\&aspergrave;/g; s/\&lenis;\´/\&lenisacute;/g; s/\&lenis;\`/\&lenisgrave;/g; s/\&asper\.//g; s/\&lenis\.//g; s/(a-z)\`/\&$1grave;/g; s/(a-z)\´/\&$1acute;/g; s/\&odq;/``/g; s/\&cdq;/''/g; s/\&onq;/`/g; s/\&cnq;/'/g; s/\&es;/\ /g; s/\—/\-/g; s///g; s/<\/su>/<\/sup>/g; s//

      /g; s/<\/head>/<\/h3>/g; s/^$&/; s/>
    1. \-
      /

    2. [EH]/; s/

    3. \-
      /



    4. [EH]/; if ( $printit eq "1" ) { print; } } close(TARGFILE); if ($search eq "yes") { print "
    \n"; unless ($frametype eq "frames") { &newsearch(); } } sub printoedbar { ($titletext = $enfile) =~ s/\/u\/triggs\/TEXTS\/...\///; print "OED Historical Corpus - %s\n", $titletext; print "
    \n"; print "\"Home\n"; print "
    \n"; print "\"\"\n"; print "
    \n"; print "
    \n"; print "
    \n"; print "
    \n"; } sub printheader { print "Content-type: text/html\n\n"; if ($type eq "F1") { print "\n"; } elsif ($type eq "Q2") { print "\n"; } else { print "\n"; } print "\n"; } sub parse_form_data { local (*FORM_DATA) = @_; local ( $request_method, $query_string, @key_value_pairs, $key_value, $key, $value); $request_method = $ENV{'REQUEST_METHOD'}; if ($request_method eq "GET") { $query_string = $ENV{'QUERY_STRING'}; } elsif ($request_method eq "POST") { read (STDIN, $query_string, $ENV{'CONTENT_LENGTH'}); } else { print "Unknown method\n"; exit (1); } @key_value_pairs = split (/&/, $query_string); foreach $key_value (@key_value_pairs) { ($key, $value) = split (/=/, $key_value); $value =~ tr/+/ /; $value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg; if (defined($FORM_DATA{$key})) { $FORM_DATA{$key} = join ("\0", $FORM_DATA{$key}, $value); } else { $FORM_DATA{$key} = $value; } } } sub authillus { $page="corpus"; $align="left"; if ($enfile =~ /^.*Austen..*$/) { print ""; } elsif ($enfile =~ /^.*Bronte.J.*$/) { print ""; } elsif ($enfile =~ /^.*Cather..*$/) { print ""; } elsif ($enfile =~ /^.*Chaucer..*$/) { print ""; } elsif ($enfile =~ /^.*\/ColWork.*$/) { print ""; } elsif ($enfile =~ /^.*\/Coleridge..*$/) { print ""; } elsif ($enfile =~ /^.*Cooper..*$/) { print ""; } elsif ($enfile =~ /^.*Crane..*$/) { print ""; } elsif ($enfile =~ /^.*Crevecoeur..*$/) { print ""; } elsif ($enfile =~ /^.*Darwin..*$/) { print ""; } elsif ($enfile =~ /^.*Dickens.C.*$/) { print ""; } elsif ($enfile =~ /^.*Dickens.[G-Z].*$/) { print ""; } elsif ($enfile =~ /^.*Donne..*$/) { print ""; } elsif ($enfile =~ /^.*Doy.*$/) { print ""; } elsif ($enfile =~ /^.*Douglass..*$/) { print ""; } elsif ($enfile =~ /^.*Dou[A-R].*$/) { print ""; } elsif ($enfile =~ /^.*Eliot.Prufrock.*$/) { print ""; } elsif ($enfile =~ /^.*Eliot.Poems.*$/) { print ""; } elsif ($enfile =~ /^.*Eliot..*$/) { print ""; } elsif ($enfile =~ /^.*Emerson..*$/) { print ""; } elsif ($enfile =~ /^.*Fra[A-Z2].*$/) { print ""; } elsif ($enfile =~ /^.*Franklin..*$/) { print ""; } elsif ($enfile =~ /^.*Frost.*$/) { print ""; } elsif ($enfile =~ /^.*FroPoem.*$/) { print ""; } elsif ($enfile =~ /^.*Godwin..*$/) { print ""; } elsif ($enfile =~ /^.*Hardy..*$/) { print ""; } elsif ($enfile =~ /^.*Hawthorne..*$/) { print ""; } elsif ($enfile =~ /^.*Irving..*$/) { print ""; } elsif ($enfile =~ /^.*James..*$/) { print ""; } elsif ($enfile =~ /^.*.Jam.*$/) { print ""; } elsif ($enfile =~ /^.*Jefferson..*$/) { print ""; } elsif ($enfile =~ /^.*Jonson..*$/) { print ""; } elsif ($enfile =~ /^.*Kip.*$/) { print ""; } elsif ($enfile =~ /^.*\/London..*$/) { print ""; } elsif ($enfile =~ /^.*Melville..*$/) { print ""; } elsif ($enfile =~ /^.*Milton.A.*$/) { print ""; } elsif ($enfile =~ /^.*Milton.P.*$/) { print ""; } elsif ($enfile =~ /^.*Milton.S.*$/) { print ""; } elsif ($enfile =~ /^.*Milton.Th.*$/) { print ""; } elsif ($enfile =~ /^.*Mil67PL.*$/) { print ""; } elsif ($enfile =~ /^.*\/Poe.*$/) { print ""; } elsif ($enfile =~ /^.*Scott.*$/) { print ""; } elsif ($enfile =~ /^.*ScoCasD*.*$/) { print ""; } elsif ($enfile =~ /^.*ScoPoem.*$/) { print ""; } elsif ($enfile =~ /^.*Shakespeare.*$/) { print ""; } elsif ($enfile =~ /^.1609Son.*$/) { print ""; } elsif ($enfile =~ /^.*Q..*$/) { print ""; } elsif ($enfile =~ /^.*Shaw..*$/) { print ""; } elsif ($enfile =~ /^.*Stevenson..*$/) { print ""; } elsif ($enfile =~ /^.*Stowe..*$/) { print ""; } elsif ($enfile =~ /^.*Thoreau..*$/) { print ""; } elsif ($enfile =~ /^.*Trollope..*$/) { print ""; } elsif ($enfile =~ /^.*Twain..*$/) { print ""; } elsif ($enfile =~ /^.*TwaMiss..*$/) { print ""; } elsif ($enfile =~ /^.*Wells..*$/) { print ""; } elsif ($enfile =~ /^.*Wollstonecraft.*$/) { print ""; } elsif ($enfile =~ /^.*WolM.*$/) { print ""; } elsif ($enfile =~ /^.*Woolf.*$/) { print ""; } elsif ($enfile =~ /^.*Woo[D-IK-Z].*$/) { print ""; } elsif ($enfile =~ /^.*Wordsworth.Coleridge.*$/) { print " "; } #if ($enfile =~ /^.*\/Wordsworth..*$/) { # print ""; #} elsif ($enfile =~ /^.*Wordsworth.Excursion.*$/) { print ""; } elsif ($enfile =~ /^.*Wordsworth.Prelude.*$/) { print ""; } elsif ($enfile =~ /^.*Wordsworth.Immortality.*$/) { print ""; } elsif ($enfile =~ /^.*Yea[E,P].*$/) { print ""; } } sub printhamlettpage { print "
    \n"; print "\"\"\"\"\n"; print "
    \n"; print "
    \n"; print "
    \n"; if ($frametype eq "frames") { print "\"Enfolded\n"; # print "\"Enfolded\n"; # print "\"Enfolded\n"; } else { # print "\"\"\n"; print "\"\"\n"; # print "\"\"\n"; } print "

    The Tragedie of
    H A M L E T

    \n"; print "

    Prince of Denmarke.

    \n"; @otypes = ('Enfolded','F1','F1 Only','Q2','Q2 Only'); print "
    \n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
    "; if ($search eq "yes") { print "Context: \n"; } print "\n"; print "
    "; print "
    \n"; print "
    \n"; print "
    \n"; } sub newsearch { @otypes = ('Enfolded','F1','F1 Only','Q2','Q2 Only'); print "
    \n"; print "Enter a word, phrase, or through-line number:
    \n"; print "\n"; print "\n"; print "
    Surrounding lines of context: \n"; print "Text display type:\n"; print "\n"; if ($format eq "Variant Spellings") { print "\n\n"; } else { print "\n\n"; } print "
    \n"; } sub fulltexts { print "
    \n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
    Q2EnfoldedF1
    \n"; print "
    \n"; print "
    \n"; print "\"\"\"\"\n"; print "
    \n"; #print "
    \n"; }