#! /usr/bin/gawk -f # Last edited on 2026-07-03 17:33:07 by stolfi # Deletes from an SBJ pinyin file those parts that apparently # were systematically omitted by the VMS author. # Assumes each line starts with a locus ID and # keywords like [ BEGIN { printf "doing n055_delete_omitted_bencao_fields.gawk ...\n" > "/dev/stderr" } /^ *([#]|$)/ { next; } /^[<]/ { loc = $1; $1 = "" gsub(/\[ *zhǔ +zhì *\]/, "[zhǔ]", $0) gsub(/\[ *wèi *\][^][]*[.,]/, " ", $0) gsub(/\[ *shēng *\][^][]*[.,]/, " ", $0) gsub(/\[ *yī +míng *\] [^][,.]*[,.]/, " ", $0) gsub(/[(][^][()]*[)]/, " ", $0) gsub(/[<][%$][>]/, " ", $0) gsub(/[][,.:;!*'-]/, " ", $0) $0 = (loc " " $0) gsub(/[>] */, "> ", $0) gsub(/[ ][ ]+/, " ", $0) gsub(/[ ]*$/, " ", $0) print next } // { data_error("invalid line format") }