Linguist has asked for the wisdom of the Perl Monks concerning the following question:
I am attempting to do pattern matching for linguistic analysis using a 2 dimensional array. In one dimension are the words in English, in the second are all the grammar codes. I am new to PERL and programming in general, so I'm not sure if my problem is with the logic or the code.
Here is the part of the code that isn't doing what I expect it to. I have also left in my comments so you can see what I intend to do. Please let me know if you need more of my code to make any sense of this
Any suggestions would be great. Thanks!
$textarray[$iwrdnum][1] = $tagfields[0]; #the member located i +n the position 0 of the tagfields array, is placed into position 1 in + the textarray array $textarray[$iwrdnum][2] = $tagfields[1]; $textarray[$iwrdnum][3] = $tagfields[2]; $textarray[$iwrdnum][4] = $tagfields[3]; $textarray[$iwrdnum][5] = $tagfields[4]; $iwrdnum++; }#end loop 2 for ($i = 0; $i <@textarray; $i++) {#start loop 3 if ($textarray[$i][1] =~ /\b(nn|nns|nvbg|np|nps|npl)\b/) {#start if conditon for ($i3=1; $i3<=9; $i3++) #HERE IS WHERE I THINK + THE PROBLEM MUST BE. What I think I'm doing is starting at the next + row to the 9th row down, looking row by row { #start for loop if ($textarray[$i][1] =~ /\b(at|ati)\b/ ) #if +the tag is at or ati then {#start if condition print (OUTFILE "$textarray[$i][0]$textarra +y[$i+1][0]$textarray[$i+2][0]$textarray[$i+3][0]$textarray[$i+4][0]$t +extarray[$i+5]\n "); }#end if condition }#end for loop }#end if condition }#end loop 3
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: looping in 2d array
by Laurent_R (Canon) on Nov 01, 2014 at 18:59 UTC | |
|
Re: looping in 2d array
by hippo (Archbishop) on Nov 01, 2014 at 16:42 UTC | |
|
Re: looping in 2d array
by AnomalousMonk (Archbishop) on Nov 01, 2014 at 20:28 UTC | |
|
Re: looping in 2d array
by toolic (Bishop) on Nov 01, 2014 at 16:47 UTC | |
|
Re: looping in 2d array
by GotToBTru (Prior) on Nov 01, 2014 at 21:51 UTC | |
by AnomalousMonk (Archbishop) on Nov 02, 2014 at 22:24 UTC | |
|
Re: looping in 2d array
by FloydATC (Deacon) on Nov 02, 2014 at 09:28 UTC | |
by ww (Archbishop) on Nov 02, 2014 at 12:41 UTC | |
by FloydATC (Deacon) on Nov 02, 2014 at 13:55 UTC | |
by ww (Archbishop) on Nov 02, 2014 at 15:33 UTC | |
by AnomalousMonk (Archbishop) on Nov 02, 2014 at 21:51 UTC |