#! /usr/bin/gawk -f # Last edited on 2004-07-15 22:45:54 by stolfi BEGIN { dashes = "-------------------------------------------------------------"; vtag_maj = "A"; # version tag for majority version maxlen_left = 18; # Max length of left context maxlen_word = 17; # Max length of label maxlen_rite = 18; # Max length of right context color_hdr = "\"#ff5522\""; # New label header color_dsh = "\"#777777\""; # Color for dashes in header color_ctx = "\"#dddddd\""; # Color for context strings color_word_ord = "\"#ccbb33\""; # Color for label in ordinary versions color_word_maj = "\"#ffee33\""; # Color for label in majority version color_loc_use = "\"#33bbdd\""; # Color for location code of usage occurence color_loc_def = "\"#aaffff\""; # Color for location code of defining occurrence color_sec = "\"#33cc22\""; # Color for section titles color_cmt = "\"#ffdd88\""; # Color for unit comments curword = ""; print_html_header("Voynich Manuscript stuff - Label concordance"); } (NF == 14) { fnum = $1; utag = $2; lnum = $3; vtag = $4; ocstart = $5; oclength = $6; lctx = $7; word = $8; rctx = $9; def = $10; unum = $11; ucmt = $12; pnum = $13; stag = $14; # Rejoin the components of the line loacator {loc}: loc = ( fnum "." utag "." lnum ); # Cleanup the comment field: gsub(/[_]/, " ", ucmt); gsub(/^[ ]+/, "", ucmt); gsub(/[ ]+$/, "", ucmt); gsub(/[ ][ ]+/, " ", ucmt); gsub(/^[-]$/, " ", ucmt); gsub(/^fig labels omitted[?]$/, "", ucmt); if (word != curword) { if (curword != "") { print_word_header(word); } curword = word; } print_entry(stag, loc, vtag, lctx, word, rctx, ucmt, def); next; } // { data_error(("bad line format \"" $0 "\"")); } END { print_html_tailer(); } function print_html_header(title) { printf "\n"; printf "\n"; printf " \n"; printf "%s\n", title; printf "\n"; printf ""; printf "\n"; printf "\n"; printf "Generated %s by stolfi\n", strftime("%Y-%m-%d %H:%M:%S", systime()); printf "\n"; printf "\n"; printf "

A concordance for the VMS labels

\n"; printf "\n"; printf "

Color key

\n"; printf "
\n";
  printf "  Section code\n", color_sec; 
  printf "  Location of occurrence in text\n", color_loc_use; 
  printf "  Location of occurrence as label\n", color_loc_def; 
  printf "  Labelword occurrence in majority version (%s)\n",
    color_word_maj, vtag_maj; 
  printf "  Labelword occurrence in minority versions\n", color_word_ord; 
  printf "  Context of label in occurrence\n", color_ctx; 
  printf "  Comments on the text unit\n", color_cmt; 
  printf "
\n"; printf "\n"; printf "

The concordance

\n"; printf "\n"; printf "
\n";
}

function print_word_header(word,   llen,rlen)
{
  llen = maxlen_left - 1;
  rlen = 110 - maxlen_left - length(word) - 1;
  printf "\n%.*s ", word, color_dsh, llen, dashes;
  printf "%s", color_hdr, word;
  printf " %.*s\n\n", rlen, dashes;
}
  
function print_html_tailer()
{
  printf "
\n"; printf "\n"; printf "\n"; } function print_entry(stag,loc,vtag,lctx,word,rctx,ucmt,def, n,clab,cloc,xl,xw,xr,xx,lc,st,uc) { # Truncate context strings: n = length(lctx); if (n > maxlen_left) { lctx = substr(lctx, 1+(n-maxlen_left)); } n = length(rctx); if (n > maxlen_rite) { rctx = substr(rctx, 1, maxlen_rite); } # Select color {clab} to use for word occurrence: clab = ( (vtag_maj=="") || (index(vtag, vtag_maj) > 0) ? color_word_maj : color_word_ord ); # Select color {cloc} to use for locator+version: cloc = ( def=="+" ? color_loc_def : color_loc_use ); # Format fields with their colors and styles: xl = sprintf("%*s%s", maxlen_left - length(lctx), "", color_ctx, lctx); xw = sprintf("%s", clab, word); xr = sprintf("%s%*s", color_ctx, rctx, maxlen_rite - length(rctx), ""); xx = sprintf("%s%*s", (xl xw xr), maxlen_word - length(word), ""); lc = sprintf("%-12s %-6s", cloc, loc, vtag); st = sprintf("%-3s", color_sec, stag); uc = sprintf("%s", color_cmt, ucmt); # Print line: printf "%s %s %s %s\n", xx, lc, st, uc; } function data_error(msg) { printf "%s:%d: ** %s\n", FILENAME, FNR, msg > "/dev/stderr"; abort = 1; exit 1; } function arg_error(msg) { printf "%s\n", msg > "/dev/stderr"; abort = 1; exit 1; }