# Check that all words, pairs, and triples in output ARGV[2] are in original ARGV[1] BEGIN { while (getline 0) { for (i = 1; i <= NF; i++) { wd[++nw] = $i # input words single[$i]++ } } for (i = 1; i < nw; i++) pair[wd[i],wd[i+1]]++ for (i = 1; i < nw-1; i++) triple[wd[i],wd[i+1],wd[i+2]]++ while (getline 0) { outwd[++ow] = $0 # output words if (!($0 in single)) print "unexpected word:", $0 } for (i = 1; i < ow; i++) if (!((outwd[i],outwd[i+1]) in pair)) print "unexpected pair:", outwd[i], outwd[i+1] for (i = 1; i < ow-1; i++) if (!((outwd[i],outwd[i+1],outwd[i+2]) in triple)) print "unexpected triple:", outwd[i], outwd[i+1], outwd[i+2] }