NAME
Lingua::NegEx - Perl extension for finding negated phrases in text and identifying the scope of negation.
SYNOPSIS
use Lingua::NegEx qw( negation_scope );
my $scope = negation_scope( 'There is no pulmonary embolism.' );
print join ', ', @$scope; # '3, 4'
my $scope = negation_scope( 'Fever, cough, and pain denied.' );
print join ', ', @$scope; # '0, 3'
my $scope = negation_scope( 'The patient reports crushing substernal chest pain' );
print $scope; # undef
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 an array reference with 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 refactored the original code in an effort to simplify and improve readability. A couple of substantive 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) return value is now \@scope 4) 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 [ $first_position, $last_position ]
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.