#!/local/bin/perl #### # # (c) 1998 Bruce Jakeway # # Return a list of all definitions of words of a particular part-of-speech tag. # Use the -f flag to specify a file to search. Eg, "-fl" searches the "l" # words. "-f l -fnew" searches both "l" and "new" words. # # sample run: # ./possearch v-t > defs.v-t # #### $pathname = '/nfs/v2/jakeway/custard/w1913/result/newdefs/'; @userletters = (); sub findword { local ($currpos) = 0; local ($f); local (@file); local ($foundpos) = 0; local (@hw) = (); local (@lines); local ($pos) = "\L$ARGV[0]\E"; if (@userletters) { foreach $letter (@userletters) { push (@file, $pathname . $letter . '.defs'); } } else { foreach $letter ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'new', 'o', 'pq', 'r', 's', 't', 'u', 'v', 'w', 'xyz') { push (@file, $pathname . $letter . '.defs'); } } foreach $f (@file, $pathname) { open (DICT, $f); while ($line = ) { if ($line =~ m##) { @lines = (); $inheader = 1; $foundpos = 0; } elsif ($line =~ m##) { $inheader = 0; if ($line =~ m#.*$pos.*#) { $currpos = 1; $foundpos = 1; } else { $currpos = 0; } } if ($inheader || $currpos) { push (@lines, $line); } if ($line =~ m## && $foundpos) { foreach $line (@lines) { print $line; } } } close (DICT); } } sub main { while (($letter) = $ARGV[0] =~ m/^-f([^ ]*)/) { shift @ARGV; if ($letter eq '') { $letter = $ARGV[0]; shift @ARGV; } push (@userletters, $letter); } while ($#ARGV >= 0) { &findword; shift @ARGV; } } &main;