renster has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to use Lingua::LinkParser 1.05. Everything seems to have installed correctly. However when I run the small piece of code shown in perldoc(direct cut and paste - forgive the use strict badness):

use Lingua::LinkParser; our $parser = new Lingua::LinkParser; my $sentence = $parser->create_sentence("This is the turning point."); my @linkages = $parser->linkages; foreach $linkage (@linkages) { print ($parser->get_diagram($linkage)); }

I get the following error:

Can't locate auto/Lingua/LinkParser/linkages.al in @INC @INC contains: /usr/lib/perl5/5.6.0/i386-linux /usr/lib/perl5/5.6.0 /usr/lib/perl5/site_perl/5.6.0/i386-linux /usr/lib/perl5/site_perl/5.6.0 /usr/lib/perl5/site_perl .) at test.pl line 9

Line 9 is my @linkages = $parser->linkages;.Does anyone know why this might be happening? Linkages.al doesn't seem to exist. I've tried running this on two installs of linux. Can anyone else recreate this error? There could be some whacky .al thing I have no idea about...

As an extra - If I change line 9 to my @linkages = $sentence->linkage(1) (as per an example from TPJ) it parses the sentence and shows the diagram as expected.

However my @linkages = $sentence->linkage(1) only parses a limited set of sentences that have 1 (or more) linkages in the sentence. In the case where a word cannot be linked (a null linkage as in "This is so the turning point.") the parser also freaks out with Assertion failed: index out of range because naturally there is a word "so" with a null link.

I cannot stop this error using any of the supplied processing options, e.g.$parser->opts('allow_null') even though this sentence can be parsed using the compiled Link Grammar Parser that Lingua::LinkParser requires. Link Grammar Parser can handle this sentence because it ignores "so" tries to parse the sentence without it.

Basically, I'm stuck with an option that doesn't really give me all the power of Lingua::LinkParser and I want to parse sentences that use "so" and similar null links

Thanks

renster

Replies are listed 'Best First'.
Re: Lingua::LinkParser
by renster (Initiate) on Dec 22, 2001 at 11:52 UTC

    After enquiring on perl.misc I decided to send an email to the author (Daniel Brian) who promptly replied.

    The POD appears to have a typo so that..

    my @linkages = $parser->linkages;

    should be ...

    my @linkages = $sentence->linkages;

    This example code given in the POD will now work with all types of sentences. It won't spit back any results for sentences with null linked words. To parse these you need to use the $parser->opts and change 'max_null_count'. Look in the '/scripts/parse.pl' for an example of how to do this and don't make the newbie mistake that I did and not look at all the files and dirs in the tarball.

    Thanks to Dan for the prompt reply.