#!/usr/bin/perl -w

chdir "r/alt12dicts";

open IN, "abbr.txt";
open OUT, ">abbr.lst";
while (<IN>) 
{
    next if /~/;
    y/:\r//d;
    print OUT;
}
close OUT;

open IN, "variant.txt";
open OYES  , ">variant-yes.lst";
open OMAYBE, ">variant-maybe.lst";
open BYES  , ">nonamer-yes.lst";
open BMAYBE, ">nonamer-maybe.lst";
while (<IN>) {
    ($w, $f, $s) = /^(.+):?\t(.)([!?]?)\r?\n/ or die "Bad Line: $_";
    next unless $w =~ /^[A-Za-z\']+$/;
    if ($s eq '!' || $s eq '') {
	print OYES $w, "\n" if $f eq '#';
	print BYES $w, "\n" if $f eq '&';
    } else {
	print OMAYBE $w, "\n" if $f eq '#';
	print BMAYBE $w, "\n" if $f eq '&';
    }
}

close OYES;
close OMAYBE;

open IN, "2of12full.txt";
open O02, ">02of12.lst";
open O06, ">05of12.lst";
open O11, ">11of12.lst";
open U, ">4of12upper.lst";
open ONA, ">not-abbr.lst";

while (<IN>)
{
    ($n, $w, $a) 
	= /^(..): .. ..\# ..\&   (.+?)([:.]?)\r?\n/ or die "Bad Line:$_";
    $_ = $w;
    next unless /^[A-Za-z\']+$/;
    $_ .= "\n";
    print ONA if ($a eq '' && $n >= 5);
    if ($n >= 11) {
	print O11;
    } elsif ($n >= 5) {
	print O06;
    } elsif ($n >= 4 && /^[A-Z]+/ && $a eq '') {
	print U;
    } elsif ($n >= 2) {
	print O02;
    } else {
	die "This should not happen: $n $_\n";
    }
}

close ONA;

qx'cat not-abbr.lst | sort | uniq  \
    | comm -23 - variant-yes.lst   \
    > not-variant.lst'






