NAME
Lingua::NegEx - Perl extension for finding negated phrases in text and identifying the scope of negation.
SYNOPSIS
use Lingua::NegEx;
my $scope = negation_scope( 'There is no pulmonary embolism.' );
print $scope; # prints '3 - 4'
my $scope = negation_scope( 'fever, cough, and pain denied.' );
print $scope; # prints '0 - 3'
DESCRIPTION
This is a perl implementation of Wendy Chapman's NegEx algorithm which uses a list of phrases to determine if a negation exists in a sentence and to identify the scope of the given negation.
The one exported function, negation_scope(), takes a sentence as input and returns '0' if no negation is found or returns the range of word indices that make up the scope of the negation.
This is a port from the java code authored by Junebae Kye made available online. I've changed variable names and tried to improve readability of the original code. A couple of deviations from the original: 1) input text is forced into lowercase 2) non-word characters are stripped from the input text as well (non-word characters are also stripped from phrases so they can still match) 3) eliminated '-2' as an output for pre phrases being found in last position of a string, here this returns "0 - $last_position".
EXPORT
negation_scope( $text ); # returns 0 if no negation or /\d - \d/ which is the scope of negation
SEE ALSO
The NegEx documentation and downloads for java implementation can be found here:
http://code.google.com/p/negex/
Background information:
http://www.ncbi.nlm.nih.gov/pubmed?cmd=Retrieve&db=PubMed&dopt=AbstractPlus&list_uids=12123149
AUTHOR
Eduardo Iturrate, <ed@iturrate.com>
COPYRIGHT AND LICENSE
Copyright (C) 2013 by Eduardo Iturrate
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.