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
In reply to looping in 2d array by Linguist
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |