Lingua-YaTeA

 view release on metacpan or  search on metacpan

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


    if(defined $this->{UNPARSED})
    {
	while ($phrase = pop @{$this->getUnparsed})
	{ 
	    $counter++;
	    #print $fh "\n\n";
 	    #print $fh "COUNTER: " . $counter . " \t" . $phrase->{'IF'} . "\n";
	    #$phrase->print($fh);
 
#  	    if (($phrase->{'IF'} eq "fonction ventriculaire gauche globale") || ($phrase->{'IF'} eq "fonction ventriculaire gauche systolique globale")) {
# 		print STDERR Dumper($phrase);
# 	    }
	    $complete = 0;
	    $corrected = 0;
	    $phrase->searchEndogenousIslands($this,$chunking_data,$tag_set,$lexicon,$sentence_set,$fh);
	    if(defined $phrase->getIslandSet)
	    {
		#$phrase->printIslands($fh);
#		($complete,$corrected) = $phrase->integrateIslands($chunking_data,$tag_set,$lexicon,$parsing_direction,$sentence_set,$fh);
		
		($complete,$corrected) = $phrase->integrateIslands($tag_set,$lexicon,$parsing_direction,$sentence_set,$fh);
	    }
	    if($corrected == 1)
	    {
		$this->updateRecord($phrase,$tag_set);
	    }
	   if($complete == 1)
	   {
	       $phrase->setParsingMethod('PROGRESSIVE');
	       $phrase->setTC(1);
	       $this->giveAccess($phrase);
	   }
	    else
	    {
		$phrase->plugInternalFreeNodes($parsing_pattern_set,$parsing_direction,$tag_set,$fh);
	       
		if($phrase->parseProgressively($tag_set,$parsing_direction,$parsing_pattern_set,$fh))
	       {
		   $phrase->setParsingMethod('PROGRESSIVE');
		   $phrase->setTC(1);
		   $this->giveAccess($phrase);
	       }
	       else
	       {
		   $phrase->setTC(0);
		   $this->addToUnparsable($phrase);
		   # $phrase->print($fh);

	       }
	       #	    $phrase->printForestParenthesised($fh);
	       #  print $fh "\n\n";
	       printf STDERR $message_set->getMessage('UNPARSED_PHRASES')->getContent($display_language) . "... %0.1f%%   \r", (scalar(@{$this->getUnparsed}) / $Unparsed_size) * 100 ;
	   }
	}
	print STDERR "\n";
    }
    
}

sub updateRecord
{
    my ($this,$phrase,$tag_set) = @_;
    my $key;
    my $reference;
    
    $key = $phrase->buildKey;
    
    if(exists $this->getPhrases->{$key})
    {
	delete $this->getPhrases->{$key};

    }

    $phrase->buildLinguisticInfos($phrase->getWords,$tag_set);
    $key = $phrase->buildKey;
    
     if(exists $this->getPhrases->{$key})
    {
	$reference = $this->getPhrases->{$key};
	$reference->addOccurrences($phrase->getOccurrences);
	
    }
    else
    {
	$this->getPhrases->{$key} = $phrase;
    }
}


sub getUnparsable
{
    my ($this) = @_;
    return $this->{UNPARSABLE};
}



sub getIFaccess
{
    my ($this) = @_;
    return $this->{IF_ACCESS};
}

sub addTermCandidates
{
    my ($this,$option_set) = @_;
    my $phrase;
    my $phrase_set;
    my $term_candidate;
    my $tc_max_length = $option_set->getTCMaxLength;
    my %mapping_from_phrases_to_TCs_h;
    my %monolexical_transfer;
   
  
    if(defined $this->getIFaccess)
    {
	foreach $phrase_set (values (%{$this->getIFaccess}))
	{
	    foreach $phrase (@$phrase_set){
		$phrase->addTermCandidates($this->getTermCandidates,\%mapping_from_phrases_to_TCs_h,$tc_max_length,$option_set,$this->getPhrases,\%monolexical_transfer);



( run in 1.960 second using v1.01-cache-2.11-cpan-c966e8aa7e8 )