Lingua-YaTeA

 view release on metacpan or  search on metacpan

lib/Lingua/YaTeA/Node.pm  view on Meta::CPAN

    }
    else
    {
	$$analysis_r .= ")";
    }
}




sub searchLeaf
{
    my ($this,$index,$depth_r) = @_;
    my $node;
    my $position;
    #  print STDERR "SL1\n";
    $$depth_r++;
    if ($$depth_r < 50) { # Temporary added by sophie Aubin 14/01/2008
	
	if(( blessed($this->getLeftEdge)) && ($this->getLeftEdge->isa('Lingua::YaTeA::Node')))
	{
	    #  print STDERR "SL2a\n";
	    ($node,$position) = $this->getLeftEdge->searchLeaf($index,$depth_r);
	}
	else
	{
	    #  print STDERR "SL2b\n";
	    if($this->getLeftEdge->getIndex == $index)
	    {
		return ($this,"LEFT");
	    }
	}
	#  print STDERR "SL3\n";
	
	if(!defined $node)
	{
	    if ((blessed($this->getRightEdge)) && ($this->getRightEdge->isa('Lingua::YaTeA::Node')))
	    {
		#  print STDERR "SL4a\n";
		($node,$position) = $this->getRightEdge->searchLeaf($index,$depth_r);
	    }
	    else
	    {
		#  print STDERR "SL4b\n";
		if($this->getRightEdge->getIndex == $index)
		{
		    return ($this,"RIGHT");
		}
	    }
	}
    }
    else
    {
	warn "searchLeaf: Going out a deep recursive method call (more than 50 calls)\n";
	return undef;
    }
    #  print STDERR "SL5\n";
    return ($node,$position); 
}

sub updateLeaves
{
    my ($this,$counter_r,$index_set) = @_;
    
    if ((blessed($this->getLeftEdge)) && ($this->getLeftEdge->isa('Lingua::YaTeA::TermLeaf')))

    {
	$this->{LEFT_EDGE} = Lingua::YaTeA::TermLeaf->new($index_set->getIndex($$counter_r++));
    }
    else
    {
	$this->getLeftEdge->updateLeaves($counter_r,$index_set);
    }
    
    if (defined $this->getPreposition)
    {
	$this->{PREP} = Lingua::YaTeA::TermLeaf->new($index_set->getIndex($$counter_r++));
    }
    if (defined $this->getDeterminer)
    {
	$this->{DET} = Lingua::YaTeA::TermLeaf->new($index_set->getIndex($$counter_r++));
    }
    if ((blessed($this->getRightEdge)) && ($this->getRightEdge->isa('Lingua::YaTeA::TermLeaf')))
    {
	$this->{RIGHT_EDGE} = Lingua::YaTeA::TermLeaf->new($index_set->getIndex($$counter_r++));
    }
    else
    {
	$this->getRightEdge->updateLeaves($counter_r,$index_set);
    }
}


sub buildTermList
{
    my ($this,$term_candidates_a,$words_a,$phrase_occurrences_a,$phrase_island_set,$offset,$maximal) = @_;
   
    my $left;
    my $right;

#     map {print STDERR "++>" . $_->getIF()} @$words_a;
 
    my $term_candidate = Lingua::YaTeA::MultiWordTermCandidate->new;
#     print STDERR "\nID : " . $term_candidate->getID . "\n";

    my %abr = ("MODIFIER" => "M", "HEAD" => "H", "COORDONNE1" => "C1", "COORDONNE2" => "C2");
    
    $term_candidate->editKey("( ");
    
    $term_candidate->setOccurrences($phrase_occurrences_a,$$offset,$maximal);

    my $old_offset = $$offset;

    $$offset = 0;

    # left edge is a term leaf
    if ((blessed($this->getLeftEdge)) && ($this->getLeftEdge->isa('Lingua::YaTeA::TermLeaf')))
    {
# 	print STDERR $this->getLeftEdge->getIF($words_a) . "\n";
	$term_candidate->editKey($this->getLeftEdge->getIF($words_a) . "<=" . $abr{$this->getLeftEdgeStatus} . "=" . $this->getLeftEdge->getPOS($words_a) . "=" . $this->getLeftEdge->getLF($words_a). "> ");



( run in 1.746 second using v1.01-cache-2.11-cpan-5b529ec07f3 )