This node is here to demonstrate how upgrading your Perl can automagically make your life easier. The following code does not work as expected in 5.8.0, but does so in 5.8.6
sub sequential { my $self = shift; my $sl_ctl = $self->{slctl}; my $sl_len = scalar(@$sl_ctl); my $mode = $self->{params}->{mode}; my $m_clust = $mt_param{$mode}->{cluster}; my @tl_rtl = (); &log("mt: entering sequential, mode >$mode<...\n"); $m_clust = &get_maxval([1, $m_clust]); for(my $i = 0; $i < $sl_len; $i++) { my $idx_la = &get_minval([$sl_len-1, $i + $m_clust]); my $phrase; my $rawtr; retry: &log("I: $i IDX_LA: $idx_la\n"); $phrase = join ' ', @$sl_ctl[$i..$idx_la]; $rawtr = $self->get_rawtr($phrase); if(@$rawtr) { my $disam = $self->disambiguate($phrase, $rawtr, $i,$idx_la); push @tl_rtl, $disam; } else { if($idx_la > $i) { $idx_la--; goto retry; } push @tl_rtl, $phrase; } $i = $idx_la; } @tl_rtl = &trim(@tl_rtl); $self->{tlrtl} = \@tl_rtl; return TRUE; }
In correct operation, the log looks like this, You see, $idx_la is always defined
Tue Feb  8 20:22:00 2005: mt: entering sequential, mode >level0<...
Tue Feb  8 20:22:00 2005: I: 0 IDX_LA: 1
Tue Feb  8 20:22:00 2005: mt: get_rawtr for >i am< lexl: >xx<.
Tue Feb  8 20:22:00 2005: mt: gives result ><.
Tue Feb  8 20:22:00 2005: I: 0 IDX_LA: 0
Tue Feb  8 20:22:00 2005: mt: get_rawtr for >i< lexl: >xx<.
Tue Feb  8 20:22:00 2005: mt: gives result >ich<.
Tue Feb  8 20:22:00 2005: mt: disambig mode: >0<
Tue Feb  8 20:22:00 2005: I: 1 IDX_LA: 2
Tue Feb  8 20:22:00 2005: mt: get_rawtr for >am going< lexl: >xx<.
Tue Feb  8 20:22:00 2005: mt: gives result ><.
Tue Feb  8 20:22:00 2005: I: 1 IDX_LA: 1
Tue Feb  8 20:22:00 2005: mt: get_rawtr for >am< lexl: >xx<.
Tue Feb  8 20:22:00 2005: mt: gives result >bin<.
Tue Feb  8 20:22:00 2005: mt: disambig mode: >0<
Tue Feb  8 20:22:00 2005: I: 2 IDX_LA: 3
Tue Feb  8 20:22:00 2005: mt: get_rawtr for >going to< lexl: >xx<.
Tue Feb  8 20:22:00 2005: mt: gives result ><.
Tue Feb  8 20:22:00 2005: I: 2 IDX_LA: 2
Tue Feb  8 20:22:00 2005: mt: get_rawtr for >going< lexl: >xx<.
Tue Feb  8 20:22:00 2005: mt: gives result >gehend<.
Tue Feb  8 20:22:00 2005: mt: disambig mode: >0<
Tue Feb  8 20:22:00 2005: I: 3 IDX_LA: 4
Tue Feb  8 20:22:00 2005: mt: get_rawtr for >to sweden< lexl: >xx<.
Tue Feb  8 20:22:00 2005: mt: gives result ><.
Tue Feb  8 20:22:00 2005: I: 3 IDX_LA: 3
Tue Feb  8 20:22:00 2005: mt: get_rawtr for >to< lexl: >xx<.
Tue Feb  8 20:22:00 2005: mt: gives result >zu nach<.
Tue Feb  8 20:22:00 2005: mt: disambig mode: >0<
Tue Feb  8 20:22:00 2005: I: 4 IDX_LA: 5
Tue Feb  8 20:22:00 2005: mt: get_rawtr for >sweden today< lexl: >xx<.
Tue Feb  8 20:22:00 2005: mt: gives result ><.
Tue Feb  8 20:22:00 2005: I: 4 IDX_LA: 4
Tue Feb  8 20:22:00 2005: mt: get_rawtr for >sweden< lexl: >xx<.
Tue Feb  8 20:22:00 2005: mt: gives result ><.
Tue Feb  8 20:22:00 2005: I: 5 IDX_LA: 5
Tue Feb  8 20:22:00 2005: mt: get_rawtr for >today< lexl: >xx<.
Tue Feb  8 20:22:00 2005: mt: gives result >heute<.
Tue Feb  8 20:22:00 2005: mt: disambig mode: >0<
Tue Feb  8 20:22:00 2005: mt: restore_punc.
Tue Feb  8 20:22:00 2005: mt: synthesize.
Tue Feb  8 20:22:00 2005: mt: synthesize: tformat.
Tue Feb  8 20:22:00 2005: mt: writefile & mtinfo.
Tue Feb  8 20:22:00 2005: Time for command 'mt en:de level0 mt_en.txt': 0
On Perl 5.8.0 it does this
Tue Feb  8 20:45:09 2005: mt: entering sequential, mode >level0<...
Tue Feb  8 20:45:09 2005: I: 0 IDX_LA: 1
Tue Feb  8 20:45:09 2005: mt: get_rawtr for >i am< lexl: >xx<.
Tue Feb  8 20:45:09 2005: mt: gives result ><.
Tue Feb  8 20:45:09 2005: I: 0 IDX_LA: 0
Tue Feb  8 20:45:09 2005: mt: get_rawtr for >i< lexl: >xx<.
Tue Feb  8 20:45:09 2005: mt: gives result >ich<.
Tue Feb  8 20:45:09 2005: mt: disambig mode: >0<
Tue Feb  8 20:45:09 2005: I: 1 IDX_LA: 2
Tue Feb  8 20:45:09 2005: mt: get_rawtr for >am going< lexl: >xx<.
Tue Feb  8 20:45:09 2005: mt: gives result ><.
Tue Feb  8 20:45:09 2005: I: 1 IDX_LA:
Tue Feb  8 20:45:09 2005: mt: get_rawtr for >< lexl: >xx<.
Tue Feb  8 20:45:09 2005: mt: gives result ><.
Tue Feb  8 20:45:09 2005: I: 1 IDX_LA: 2
Tue Feb  8 20:45:09 2005: mt: get_rawtr for >am going< lexl: >xx<.
Tue Feb  8 20:45:09 2005: mt: gives result ><.
Tue Feb  8 20:45:09 2005: I: 1 IDX_LA:
Tue Feb  8 20:45:09 2005: mt: get_rawtr for >< lexl: >xx<.
Tue Feb  8 20:45:09 2005: mt: gives result ><.
Tue Feb  8 20:45:09 2005: I: 1 IDX_LA: 2
Tue Feb  8 20:45:09 2005: mt: get_rawtr for >am going< lexl: >xx<.
Tue Feb  8 20:45:09 2005: mt: gives result ><.
Tue Feb  8 20:45:09 2005: I: 1 IDX_LA:
Tue Feb  8 20:45:09 2005: mt: get_rawtr for >< lexl: >xx<.
Tue Feb  8 20:45:09 2005: mt: gives result ><.
Tue Feb  8 20:45:09 2005: I: 1 IDX_LA: 2
ad infinitum...

Bye
 PetaMem
    All Perl:   MT, NLP, NLU


In reply to Do yourself a favor and upgrade (Bug in 5.8.0) by PetaMem

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.