#! /usr/bin/gawk -f # Last edited on 2012-05-05 22:14:47 by stolfilocal # Sampling functions for latn/ock # The Dialogus of William of Ockam, III.1.2, mapped to lowercase, with abbrevs. # To be included in wds-to-tlw function smp_define_patterns(smp,sec) { # No patterns needed if (sec != "tot.1") { data_error(("invalid section \"" sec "\"")); } } function smp_is_good_word(smp,sec,type,wd) { # Accept only lowercase alpha and "~" (abbrev marker). # The text uses neither hyphen nor apostrophe. return (wd ~ /^[~a-z]+$/); } function smp_reclassify_word(smp,sec,cursec,curlin,type,wd) { # Delete anything outside section {sec}: if (sec == "tot.1") { if (cursec !~ /^{3[.]1[.][0-9]+}{c[1-9][0-9]*}{tx/) { return "n"; } } else { arg_error(("bad subsection \"" subsec "\"")); } # Delete titles: if (cursec ~ /{(tt|cn)}$/) { return "n"; } # Reject any subsection that is not prose text: if (cursec !~ /{tx[1-9][0-9]*[md]}$/) { return "x"; }; # Discard punctuation other than parag breaks: if ((type == "p") && (wd != "=")) { return "n"; } return type; } function smp_fix_word(smp,sec,type,wd) { # Map upper case to lower case (just in case). wd = tolower(wd); return wd; }