in reply to phrase match
Thank you all Monks for your comments.
Here is my reworked solution, it seems to work on my sample sentences, but I am not really sure if it will work in all types of situations. If you see any glitch with this solution, please let me know.
Thanks once again.
my @phrases = ( 'kinase i', 'hib', 'tor', 'tor SET6', 'SET6', 'p16(INK +4A)', 'cell', 'MAP', 'H1 inhibitor' ); my $sentence='kinase inhibitor SET6 MAP H1 inhibitor activates p16(INK +4A) in cell-wall'; for (my $i=0;$i<=$#phrases;$i++) { $phrases[$i]=~s/\s+/ /g; } my $phrases_re = join '|', map { quotemeta } @phrases; $sentence=~s/\s+/ /g; $sentence=' '.$sentence.' '; $sentence =~ s/\s($phrases_re)\s/ \#$1\# /g; $sentence=~s/\s+/ /g; $se +ntence =~ s/^\s+|\s+$//g; print "$sentence\n"; #Output: 'kinase inhibitor #SET6# #MAP# #H1 inhibitor# activates #p16( +INK4A)# in cell-wall'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: phrase match
by AnomalousMonk (Archbishop) on Dec 13, 2009 at 22:13 UTC | |
by newbio (Beadle) on Dec 14, 2009 at 15:34 UTC | |
by AnomalousMonk (Archbishop) on Dec 14, 2009 at 16:13 UTC |