#!/usr/bin/perl -w

use Data::Dumper;

my @flags = ('A'..'Z','a'..'z',']','^','`');
my %flags = ();

open P, "paradigmas" or die $!;
while(<P>) {
  chomp;
  $flags{$_} = shift @flags;
}

open D, "latin.dic_" or die $!;
open O, ">latin.dic" or die $!;
while(<D>) {
  s!/(\w+)/$!exists($flags{$1})?"/$flags{$1}/":"/_/"!e;
  print O;
}
close O;
close D;

open D, "latin.aff_" or die $!;
open O, ">latin.aff" or die $!;
while(<D>) {
  s/flag\s+(\w+):/exists($flags{$1})?"flag $flags{$1}:":"flag _:"/e;
  print O;
}
close O;
close D;