Module 1 of 3Free to explore

A contract for inert specimens and editorial notes

2 hoursTheory and practiceHard

What the editor actually needs

A security training team received a specimen for a workshop on phishing reports. They plan to discuss it as a group and record their observations in an exercise booklet. An older script accepts any file containing a heading and the word training. Last week a different exercise passed that check as well. Two reviewers referred to the second annotation and meant different paragraphs. The first programming task is to state precisely what the checker should accept. This lets the editor separate a misplaced file from a badly numbered paragraph.

The exercise specimen is deliberately simple. A title identifies the activity, geometric shapes distinguish neutral blocks of text and numbered notes let an editor describe what appears at each position. A student works on the source as text. Nobody receives a message or has to interact with a service. Two people can review the same source in different editors and still identify the same annotation, even when their line wrapping and font sizes differ. The identifier also survives a change to the wording of that paragraph.

Give each identifier a scope

The collection has three kinds of identifiers. MAIL-06 names a particular exercise. A revision number identifies a version of its source. A value such as N18 identifies an individual note inside that source. Consecutive revisions can share an exercise label and note identifiers. This is what allows a reviewer to compare changes across revisions. Within one revision a given note identifier must refer to a single paragraph. Your future linter should therefore allocate a fresh set of seen identifiers when it starts checking a document.

Write the contract in terms of properties that can be observed. One article element carries the data-lab attribute. It contains one h2 and at least one p. Each paragraph has a data-note consisting of an uppercase N and two ASCII digits. Other elements and attributes are outside the collection’s format. The heading names the exercise and the paragraph contains the editor’s comment. The short identifier remains the machine-readable reference to that comment. Decide what finding should be returned for an empty list before implementing any parsing.

<article data-lab="MAIL-06">
  <h2>Training specimen with editorial annotations</h2>
  <p data-note="N18">Circle. The editor marked the title position.</p>
  <p data-note="N19">Square. The editor marked the caption position.</p>
</article>

Turn the agreement into a function

For a first pass assume that someone has already extracted the attributes. Pass the exercise label, heading count and ordered list of paragraph identifiers into a small function. It returns the rules that failed. Returning immediately on the first issue forces an editor to submit the document repeatedly for unrelated mistakes. On the other hand an error near the root can cause a cascade of diagnostics. Keep all findings in this exercise and preserve their association with the source so a reviewer can later group related issues.

import re

def review(label, headings, notes):
    findings = []
    if label != "MAIL-06":
        findings.append("CARD_LABEL")
    if headings != 1:
        findings.append("CARD_HEADING")
    if not notes:
        findings.append("CARD_NO_NOTES")
    seen = set()
    for note in notes:
        if not re.fullmatch(r"N[0-9]{2}", note):
            findings.append("NOTE_ID")
        elif note in seen:
            findings.append("NOTE_REPEAT")
        else:
            seen.add(note)
    return findings

Test a valid pair of different identifiers first. Change just the second one to match the first and predict a single finding. Next change only the exercise label while keeping the notes distinct. The expected outcome is again a single finding, this time for a different rule. Finally pass an empty list. You now have independent examples for missing material, a wrong exercise and two paragraphs claiming the same place in the booklet.

Exercise. Specify a change before implementing it

The editor asks to add a short paragraph on a second topic. References in the existing booklet must continue to work. Create two revisions. In the first, add an annotation with an unused number. In the second, keep all identifiers and edit only the prose. Record your predictions and run the function. This reveals a precise limit of the structural contract. The checker can notice two notes sharing an identifier within a version. Deciding whether a changed sentence still supports last week’s conclusion requires comparing revisions and discussing that evidence with the editor.

Hand the other group a source specimen, a table of expected diagnostics and one outstanding question for the owner. Ask them to change only the parameter that causes the reported finding. Compare the rule codes they obtain and their explanations of why a correctly structured file carrying another exercise label should be routed elsewhere. Synthetic identifiers and editorial roles are sufficient to run this assessment.

Sources

Python HTMLParser · W3C WAI page structure tutorial

Test your conclusion

Which correction does the exercise card need?

Text export
line 3  p data-note=N18  «Круг»
line 6  p data-note=N18  «Квадрат»
Build contract
unique key = data-note per card
display text may repeat

Independent exercise

Учебные материалы по разработке инструмента
Сверьте исходные наблюдения, решение модели и ожидаемый результат.

An editor must choose a revision for training. The contract requires MAIL-06, a single heading and distinct paragraph IDs.

Evidence

revision | article.data-lab | heading_count | ordered paragraph notes
REV-8    | MAIL-06          | 1             | N02 N03 N04
REV-9    | MAIL-06          | 1             | N02 N03 N03
REV-10   | MAIL-07          | 1             | N02 N03 N04

Assignment

Name the eligible revision and the exact defects in the other two.

Compare your reasoning

REV-8 meets all three conditions. REV-9 reuses N03. REV-10 has distinct notes but belongs to a different exercise.

Personal practice environment

Check an excerpt, find matching lines and compute the SHA-256 of the original text. Temporary data expires after 30 minutes or when you close the environment.