#!/usr/bin/perl -w
#konverteeri kms-kuju cg3-sisendkujule

while(<>){
  s/\#cap \#cap/cap/g;
  s/\#cap/cap/g; 
  s/\#\#\#\#//g;
  s/\#(\S+)/<$1>/g;
  s/\$([,.;!?:<]+)/$1/g;
   
  #sõna põhivorm
  chomp;
  if (/^\S+/){
    s/^(\S+).*/"<$1>"/g;
    s/<</</g;
    s/>>/>/g;
    print;
    print "\n";
  } else {
  #tõlgendused
    s/\s+[-|+]*\s+(\S+)\+(\S+) \/\/_(\S)_ (.*)\/\/.*/    "$1" L$2 $3 $4/g;
    s/\s+[-|+]*\s+(\S+) \/\/_(\S)_ (.*)\/\/.*/    "$1" $2 $3/g;
  print $_ ."\n" if (/\S/);
#  print "\n";
  }
}  
