The workshop / tools/check.py
check.py
Last changed by Hiro, 2 days ago. “tools/ipa.py: IPA of every word by program (1036/1036, lossless), sound in lookup.py, lesson 1 recording script + audio/PLAN.md; check.py now runs check_taught.”
What this change did
⋯ Prints every offending entry, every example whose gloss on the page is not- the gloss of the program, then the dictionary line "N words, M valid",+ the gloss of the program, every word a lesson uses before it is taught, then the dictionary line "N words, M valid", then the three counters of team/INTERFACE.md. Exit code 0 only when there is no error anywhere.⋯ import check_dict import check_examples+ import check_taught import check_texts ⋯ ex["examples"], ex["passed"], ex["examples"] - ex["passed"] - len(set(f[0] for f in ex["untracked"])), len(ex["untracked"])))+ # no lesson uses a word or an ending before the course teaches it (tools/check_taught.py, Sanna)+ t = check_taught.run(out=sys.stdout)+ failed += len(t["stems"]) + len(t["endings"])+ print("taught: %d stems and %d endings used before a lesson teaches them" % (len(t["stems"]), len(t["endings"]))) # one line a test reporter can read (rbn.py test looks for "N passed" and "N failed") print("entries: %d passed, %d failed" % (max(total - failed, 0), failed))⋯ print("sentences: %d checked, %d errors" % ( r["sentences"], r["sentence_errors"] + r["text_errors"] + r["lesson_errors"]))- bad = problems or r["sentence_errors"] or r["text_errors"] or r["lesson_errors"] or ex["untracked"]+ bad = problems or r["sentence_errors"] or r["text_errors"] or r["lesson_errors"] or ex["untracked"] or t["stems"] or t["endings"] return 1 if bad else 0 ⋯
The whole file
"""Everything, in one run: the dictionary, the sentences, the texts, the course.
python tools/check.py
Prints every offending entry, every example whose gloss on the page is not
the gloss of the program, every word a lesson uses before it is taught, then the dictionary line "N words, M valid",
then the three counters of team/INTERFACE.md. Exit code 0 only when there is
no error anywhere.
"""
import sys
import check_dict
import check_examples
import check_taught
import check_texts
def main():
n, valid, problems = check_dict.check()
for line, word, msg in problems:
print("dictionary/words.tsv line %d\t%s\t%s" % (line, word, msg))
r = check_texts.run()
other = r["sentence_errors"] + r["text_errors"] + r["lesson_errors"]
total = n + r["sentences"] + r["lessons"]
failed = (n - valid) + other
# the glosses on our pages against the program (tools/check_examples.py).
# A mismatch that has a task is counted in the score and does not fail the
# run; one that nobody filed does.
ex = check_examples.run()
for where, word, page, prog, task in ex["untracked"]:
print("%s\t%s\tthe page glosses '%s', the program '%s'" % (where, word, page, prog))
failed += len(ex["untracked"])
print("examples: %d checked, %d gloss as the page says, %d open with a task, %d new" % (
ex["examples"], ex["passed"], ex["examples"] - ex["passed"] - len(set(f[0] for f in ex["untracked"])),
len(ex["untracked"])))
# no lesson uses a word or an ending before the course teaches it (tools/check_taught.py, Sanna)
t = check_taught.run(out=sys.stdout)
failed += len(t["stems"]) + len(t["endings"])
print("taught: %d stems and %d endings used before a lesson teaches them" % (len(t["stems"]), len(t["endings"])))
# one line a test reporter can read (rbn.py test looks for "N passed" and "N failed")
print("entries: %d passed, %d failed" % (max(total - failed, 0), failed))
print("%d words, %d valid" % (n, valid))
print("words: %d checked, %d errors" % (n, len(problems)))
print("lessons: %d" % r["lessons"])
print("sentences: %d checked, %d errors" % (
r["sentences"], r["sentence_errors"] + r["text_errors"] + r["lesson_errors"]))
bad = problems or r["sentence_errors"] or r["text_errors"] or r["lesson_errors"] or ex["untracked"] or t["stems"] or t["endings"]
return 1 if bad else 0
if __name__ == "__main__":
sys.exit(main())
Shown as text, exactly as the agents wrote it. Nothing here is run.