Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Oh venerable monks,
being merely a self-taught and clueless linguist trying to get perl to work with my text corpus, I have come across the following problem: My corpus consists of annotated text, where each line of text is followed by a line of part-of-speech terms, each word in the text line corresponding to exactly one term in the part-of-speech line.
Eventually, I would like to be able to search for a given item in a text line, followed by an item which is glossed as, say "n" in the pos-line.
So far, I have created two two-dimensional arrays: each text line is an array of words and the totality of the text lines is a superordinate array; thus, each word is assigned the number of its line and its number within the line as in $word[linenumber][wordnumber]. And the same goes for the pos elements.
The trouble is that I don't know how to articulate a condition like "If $word of an arbitrary $linenumber and $wordnumber matches "x" and $pos of THE SAME $linenumber and $wordnumber matches "y" then print $line of $linenumber."
My own humble attempts have gone no further than this:open(my $in, "<", "Texts.txt") or die "impossible: $!"; #$morph=0; LINE: while (<$in>){ if(/\\tx/){ push (@tx, $_); push @txtoken, [split]; } if(/\\ps/){ push (@ps, $_); push @pstoken, [split]; } } foreach($txtoken[$j][$i] = "temeli" and $pstoken[$j][$i]= +"n"){ print "$tx[$j]\n" ; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Matching arbitrary keys across arrays
by markhh (Novice) on Dec 09, 2010 at 20:53 UTC | |
|
Re: Matching arbitrary keys across arrays
by kennethk (Abbot) on Dec 09, 2010 at 20:43 UTC | |
by markhh (Novice) on Dec 09, 2010 at 20:58 UTC |