Lingua-YaTeA

 view release on metacpan or  search on metacpan

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

package Lingua::YaTeA::InternalNode;
use strict;
use warnings;
use Lingua::YaTeA::Node;
use Lingua::YaTeA::Edge;
use UNIVERSAL;
use Scalar::Util qw(blessed);

our @ISA = qw(Lingua::YaTeA::Node Lingua::YaTeA::Edge);

our $VERSION=$Lingua::YaTeA::VERSION;

sub new
{
    my ($class,$level) = @_;
    my $this = $class->SUPER::new($level);
    $this->{FATHER} = ();
    bless ($this,$class);
    return $this;
}

sub setFather
{
    my ($this,$father) = @_;
    $this->{FATHER} = $father;
}

sub getFather
{
    my ($this) = @_;
    return $this->{FATHER};
}

sub updateLevel
{
    my ($this,$new_level) = @_;
    $this->{LEVEL} = $new_level++;

#     warn "Debug: Level in updateLevel: $new_level \n";

    if ($new_level < 50) { # Temporary added by Thierry Hamon 02/02/2007
	if ((blessed($this->getLeftEdge)) && ($this->getLeftEdge->isa('Lingua::YaTeA::InternalNode')))
	{
	    $this->getLeftEdge->updateLevel($new_level);
	}
	if ((blessed($this->getRightEdge)) && ($this->getRightEdge->isa('Lingua::YaTeA::InternalNode')))
	{
	    $this->getRightEdge->updateLevel($new_level);
	}
    } else {
	warn "updateLevel: Going out a deep recursive method call (more than 50 calls)\n";
    }
}

sub searchRoot
{
    my ($this) = @_;
    if ((blessed($this->getFather)) && ($this->getFather->isa('Lingua::YaTeA::RootNode')))
    {
	return $this->getFather;
    }
    
    return $this->getFather->searchRoot;
}




sub printFather
{
    my ($this,$fh) = @_;
    print $fh "\t\tfather: " . $this->getFather->getID . "\n"; 
}

1;

__END__

=head1 NAME

Lingua::YaTeA::InternalNode - Perl extension for internal nodes

=head1 SYNOPSIS

  use Lingua::YaTeA::InternalNode;
  Lingua::YaTeA::InternalNode->new($level);

=head1 DESCRIPTION

The module implements internal syntactic node. It inherits of the
module C<Lingua::YaTeA::Node> and C<Lingua::YaTeA::Edge>. The field
C<FATHER> records the father node.




( run in 1.709 second using v1.01-cache-2.11-cpan-97f6503c9c8 )