#! /usr/bin/gawk -f
# Last edited on 1999-12-08 07:59:00 by stolfi

# Reads a stream of words, one per line. Extracts
# the "dex" features.

/^ *$/{next;}
/./{ 
  gsub(/^[q]/, "", $0);
  
  # Replace tables and gallows by "X":
  
  gsub(/[ktpf]/, "X", $0);
  gsub(/[cs]hh*/, "X", $0);
  gsub(/[ic]Xhh*/, "X", $0);
  
  # Replace dealers and finals by "D"
  
  gsub(/[dlrsmngjxv]/, "D", $0);
  
  # Erase circles and sticks:
  
  gsub(/[aoyi]/, "", $0);
  
  # Replace empty strings by "_"
  
  gsub(/^$/, "_", $0);
  
  print $0;
}