#! /usr/bin/gawk -f

# Usage: fix-words -f word-equiv.gawk \
#          [-v field=FIELDNUM] \
#          [-v stripq=BOOL] \
#          [-v equatekt=BOOL] \
#          [-v equatepf=BOOL] \

# Corrects transcription errors and calligraphic noise in a specified
# field.  The field is assumed to be an EVA string with no 
# comments or fillers, and whose word spaces are all ".".
#
# Removes "q" prefix if "stripq" is TRUE
# Maps "t" to "k" if "equatekt=1"
# Maps "f" to "p" if "equatepf=1"

BEGIN {
  if (field=="") { field=1; }
}

/./ { 
  $(field) = weq_reduce($(field))
  gsub(/[.]/, "", $(field));
  print;
}