#!/usr/bin/perl use strict; use warnings FATAL => "all"; #use diagnostics; require 'verbTenseChanger.pl'; ## -JUST FOR TESTING- ## my $chapter_section = "chpt"."31_4"; my $search_key = "move"; my $category_id = "all"; # --- Files --- # open(my $parse_corpus, '<', "parsed${chapter_section}.txt") or die $!; # --- 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 ""); } # --- Variables for Searching/working with parser and tagger --- # my @lines = <$parse_corpus>; my $chapternumber_value; my $sentencenumber_value; my @all_matches; my $sentence; my $grammar_relation; my $argument1; my $argument2; foreach my $line (@lines) { print "$line\n\n"; ##TEST ONLY## foreach my $verbform (@verbforms) { my $one_match_ref = []; #Chpt. num (Could check %seens): if ($line =~ /^Parsing file: (chpt\d+_\d+).txt/) { $one_match_ref->[0] = $1 ; ##Only once in file } if ($line =~ /\b$verbform\b/i) { #Sent. num: #SentSentences: if ($line =~ /^Parsing \[(sent. \d+) len. \d+\]: \[(.+)\]/) { $one_match_ref->[1] = $1; ##Multiple in file $one_match_ref->[2] = $2; $one_match_ref->[2] =~ s/,//g; } #Dependencies: if ($category_id eq "all") { if ($line =~ /subj\w*\(|obj\w*\(|prep\w*\(|xcomp\w*\(|agent\w*\(|purpcl\w*\(|conj_and\w*\(/) { if ($line =~ /(\w+)\((\w+)\-\d+\,\s(\w+)\-\d+\)/) { $one_match_ref->[3] = $1; $one_match_ref->[4] = $2; $one_match_ref->[5] = $3; } } } } # add the reference of match into array. push (@all_matches, $one_match_ref); } } # walk through all the matches. foreach my $array_ref (@all_matches) { foreach my $item (@{$array_ref}) { print "$item\n";# if (defined($item)); ##ERROR HERE!!!! } }