X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=6%2Fsrc%2Fremove-plurals;fp=6%2Fsrc%2Fremove-plurals;h=97823bfab0f66acfc78e05dacee5e31b4c76782e;hb=d5cbd5b855d8157fe44cd0979c2e517b93fb5004;hp=0000000000000000000000000000000000000000;hpb=0ba1587a200ebb44aea6355ee9330a720e3ecde2;p=deb_pkgs%2Fscowl.git diff --git a/6/src/remove-plurals b/6/src/remove-plurals new file mode 100755 index 0000000..97823bf --- /dev/null +++ b/6/src/remove-plurals @@ -0,0 +1,45 @@ +#!/usr/bin/perl + +sub strip_plurel() +{ + local $_ = $_[0]; + my @l; + push @l, "$1y" if /^(.+)ies$/; + push @l, "$1Y" if /^(.+)IES$/; + push @l, $1 if /^(.+)es$/i; + push @l, $1 if /^(.+)s$/i; + return @l; +} + +if ($#ARGV == -1) { + $in = STDIN; +} else { + $in = "IN"; + open $in, $ARGV[0] or die; +} + +while (<$in>) { + chop; + $lookup{$_} = 1; +} + +if ($#ARGV == -1) { + $out = STDOUT; +} else { + close $in; + $out = "OUT"; + open $out, ">$ARGV[0]" or die; +} + +foreach $w (keys lookup) +{ + my $dont_print = 0; + foreach $s (&strip_plurel($w)) + { + if (exists $lookup{$s}) + { + $dont_print = 1; + } + } + print $out "$w\n" unless $dont_print; +}