#! /usr/bin/gawk -f # Last edited on 1999-07-21 16:21:34 by stolfi # Reads a list of records of the form FNUM BNUM where FNUM # is a page f-number (e.g. f85v2) and BNUM the corresponding # bifolio b-number (e.g. bM5). # # Assigns to each *biffolio* a distinct capital letter in sequence, A-Z. # Outputs a table FNUM BLET that maps each *page* to # the corresponding *bifolio* letter. BEGIN{ # Letters to be assigned in sequence s="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; # "bs[b]" is the index in "s" of the letter assigned to bifolio "b". split("",bs); n = 0; } /^[#]/{next;} /^ *$/{next;} /./{ f=$1; b=$2; if(b in bs) { i = bs[b]; } else { n += 1; bs[b] = n; i = n; } print $1, substr(s,i,1); }