bmal has asked for the wisdom of the Perl Monks concerning the following question:
I need to match the nearest verb after a noun, within a sentence tagged with Part Of Speech, like this:
my code is sth. like this:$sentence = "happy JJ Boy NN kick VB jump VB";
if ($sentence =~ /(Boy\sNN)(.|\n}*(\w+\s\VB)/) { $node = $1.' '.$3; print $node; }
what I want to match is verb 'kick', but it match the second verb after the noun 'Boy'. how can I match the first verb after the noun? Any suggestion?
Thank you in advance.2001-12-26 Edit by Corion : Added formatting
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regexp, match the nearest verb.
by ariels (Curate) on Dec 26, 2001 at 18:16 UTC | |
by bmal (Novice) on Dec 27, 2001 at 13:52 UTC | |
by ariels (Curate) on Dec 28, 2001 at 17:55 UTC |