#! /usr/bin/gawk -f # Last edited on 1998-09-15 23:44:14 by stolfi # Reads a list of pairs SECX.FNUMX SECY.FNUMY where each SEC is a # section tag and each FNUM is a page f-number. # The pairs must be sorted by SECX. # Prints the count of pairs (FNUMX, FNUMY) in tabular format. BEGIN{ npg = 0; split("", pgt); split("", pgs); split("", tb); ps = ""; } /./ { s = $1; gsub(/[.].*$/, "", s); if (s != ps) { if (ps != "") { npg++; pgs[npg]=""; } ps = s; } x = $1; gsub(/^.*[.]/, "", x); if (! (x in pgt)) { pgt[x]=1; npg++; pgs[npg]=x; } y = $2; gsub(/^.*[.]/, "", y); tb[x,y]++; } END { for (i=1;i<=npg;i++) { x=pgs[i]; printf "%-6s", x; if (x != "") { for (j=1;j<=npg;j++) { y=pgs[j]; if ( y != "") { n=tb[x,y]; # hack to correct for duplication of same-page pairs: if (x == y) { n /= 2; } printf " %s", (n == 0 ? "." : n ); } else { printf " "; } } } printf "\n"; } }