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" ; } }

In reply to Matching arbitrary keys across arrays by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.