#!/usr/bin/perl -wT #What is the T for in -wT? use strict; use CGI qw(:standard); use FCGI; use File::Find; require '/Users/jon/Desktop/stanford-postagger-full-2011-04-20/verbTenseChanger.pl'; #my $search_key = param('query'); my $search_key = "move"; # --- Different forms of the Searchword --- # my @temp_changeverbforms = map changeVerbForm( $search_key, 0, $_ ), 1..4; my @verbforms; push (@verbforms, $search_key); # Watch extra for loop foreach my $temp_changeverbforms (@temp_changeverbforms) { push (@verbforms, $temp_changeverbforms) unless ($temp_changeverbforms eq ""); } #my $c_verb = param('verb_only'); my $c_enabling = param('enabling'); my $c_subject = param('subject'); #my $c_object = param('object'); my $c_prep = param('prep'); my $c_adj = param('adjective'); #my $c_modnoun = param('modnoun'); my $category_id; # --- Variables for required info from parser --- # my $chapternumber; my $sentencenumber; my $sentence; my $grammar_relation; my $argument1; my $argument2; my @all_matches; ## RESULTS OF SEARCH #if ($c_verb eq 'on') # { # if ($c_enabling eq 'on') # {$category_id = 'xcomp';} # elsif ($c_subject eq 'on') # {$category_id = 'subj';} # elsif ($c_object eq 'on') # {$category_id = 'obj';} # elsif ($c_prep eq 'on') # {$category_id = 'prep';} $category_id = 'subj'; # --Files -- # #To change, keep curly at beginning, comment File::Find ,) at end, uncomment open ## readdir ## ##or glob ## ##or File::Find ## my $dir = '/Users/jon/Desktop/stanford-postagger-full-2011-04-20/'; opendir(my $dh, $dir) or die $!; # Use a lexical directory handle. my @files = grep { -f } #Just to check if file map { "$dir/$_" } #Just to check if file grep { /^parsed.*\.txt$/ } #if parsed text readdir($dh); ################ FCGI attempt #################### while (FCGI::accept >= 0 ) { for my $file (@files) { open(my $parse_corpus, '<', "$file") or die $!; my @entirechapter = <$parse_corpus>; my $entirechapter = join ('', @entirechapter); ##Flatten file (make one big string) #To get each sent. and info in one string: my @sentblocks = split (/Parsing\s/, $entirechapter); ##Remove "Parsing" which is on the line of the chptnumber $chapternumber = $1 if ($sentblocks[1] =~ /file:\s(\S+)\.txt/); foreach my $sentblock (@sentblocks) { foreach my $verbform (@verbforms) { ##blah blah regex's, conditions, subroutine ## output ## print header(); print start_html(); ##blah blah #print statements } #End of file loop Could be moved up for speed? print "
"; print end_html(); } ##END of FCGI while loop!