#!/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 = "move"; # --- Different forms of the Searchword --- # # I made a refinement here that eliminated a step. my @verbforms = ( $search_key, map { changeVerbForm( $search_key, 0, $_ ) || (); } 1 .. 4 ); my $category_id = 'subj'; # --- Variables for required info from parser --- # my ( $chapternumber, $sentencenumber, $sentence, $grammar_relation, $argument1, $argument2 ); my @all_matches; ## RESULTS OF SEARCH my $dir = '/Users/jon/Desktop/stanford-postagger-full-2011-04-20/'; opendir(my $dh, $dir) or die $!; # Use a lexical directory handle. # I made a change here where the first grep handles both tests. # That eliminates one loop. my @files = map { "$dir/$_" } grep { -f && /^parsed.*\.txt$/ } readdir($dh); while (FCGI::accept >= 0 ) { local $/ = 'Parsing'; # Why slurp/split when we can read it by 'Parsing' record? print header(); print start_html(); foreach my $file ( @files ) { open my $parse_corpus_fh, '<', $file or die $!; # Eliminate slurp, join, split (3 implicit loops) # replaced by one 'while' loop. while ( my $sentblock = <$parse_corpus_fh> ) { chomp $sentblock; if ( $sentblock =~ /file: \s(\S+)\.txt/ ) { $chapternumber = $1; } foreach my $verbform( @verbforms ) { # blah blah # I don't know what you put here. # Here is an opportunitiy to print per verbform. } # You may have had stuff here too. # Here is an opportunity to print per record. } #Here is an opportunity to print per file. } # Here is an opportunity to print per FCGI iteration. print "
"; print end_html(); }