new-words

view grep-sentences.pl @ 20:23f949c03f95

Usage information, oneliners prototype script, autoraising of the words that are similar to known
author Igor Chubin <igor@chub.in>
date Wed Apr 28 21:00:38 2010 +0300 (2010-04-28)
parents c6efd17741aa
children 7db7bbf96fad
line source
1 #!/usr/bin/perl
4 $regexp=$ARGV[0];
5 $page=$ARGV[1];
6 #if (open(PAGE, "lynx -dump '$page'|")) {
7 if (open(PAGE, "$page")) {
8 local $/;
9 $text=<PAGE>;
10 $text =~ s@http://[a-zA-Z&_.:/0-9%?=,\#+()\[\]~-]*@@g;
11 $text =~ s@\n@@g;
12 $text =~ s@(Mr|Mrs)\.@\1POINT@g;
13 @sentences=split /[.!?]/, $text;
14 for (@sentences) {
15 s@(Mr|Mrs)POINT@\1.@g;
16 s/^\s*//;
17 s/\s*$//;
18 s/\[[0-9]+\]//g;
19 s/\s+/ /g;
20 print "$_.\n\n" if /\b$regexp\b/;
21 }
22 }