Skip to content

Fix whitespace check and all whitespace violations - #51

Merged
jclerman merged 7 commits into
mainfrom
fix-whitespace-check2
Nov 24, 2026
Merged

jclerman merged 7 commits into
mainfrom
fix-whitespace-check2

Conversation

@jclerman

@jclerman jclerman commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #33

Summary

Fixes the stray-whitespace check (leading_trailing_multi_whitespace.rq), which had never matched anything, and cleans up the 459 annotation values it turned up, so the check now passes with no violations.

Details

The check. It selected properties with ?property rdfs:subPropertyOf owl:AnnotationProperty, which no property in RadLex satisfies, so it never tested any value. It now selects ?property a owl:AnnotationProperty. It also now:

  • flags nonbreaking spaces anywhere in a value (U+00A0, U+2007, U+202F and U+FEFF, none of which \s matches);
  • allows a double space directly after a period;
  • in prose properties (obo:IAO_0000115 definition, rid:Comment and rdfs:comment), allows line breaks between non-whitespace characters: one newline, or two for a paragraph break, optionally followed by spaces that indent the next line (e.g. nested bullets). The rest of such a value is still checked, so e.g. a space before a newline is a violation.

rdfs:comment is included ahead of a possible move to that property.

The ontology. 459 values on 454 classes changed:

  • 433 whitespace-only fixes: almost all doubled spaces collapsed, plus stray line breaks and tabs, one trailing space, and two nonbreaking spaces in German synonyms (RID2513, RID10010).
  • 5 Source values split into one reference per value, where the references had been run together (separated by ;, , or just spaces). This matches the plan to hold one reference per Source value.
  • 21 values with small content fixes made while fixing their whitespace: typos, mismatched brackets ([PI-RADS}), missing sentence punctuation, straightened quotes, trailing commas on Source, and some definitions split onto lines by modality.

Motivation

Stray whitespace makes values that should be equal compare as different (e.g. when matching labels or synonyms), and inconsistent whitespace shows up in every downstream use of the text. The check was meant to catch it but had been silently passing.

Affected classes and properties

Changed

  • leading_trailing_multi_whitespace.rq: fixed and extended, as described above.
  • 433 values on 431 classes: whitespace-only fixes in Comment (270), definition (156), Source (5) and hasExactSynonym (2, both German).

Source split into one reference per value:

  • RID34992 absent collecting duct system (the Eisenberg reference also gained its publication details)
  • RID34997 acorn deformity
  • RID35095 coin lesion
  • RID35391 musculoskeletal crescent sign
  • RID35666 tumbling bullet sign

Content fixes alongside the whitespace fixes:

  • RID343 prostate: Comment quotes straightened and wording tidied
  • RID348 central zone of prostate: definition line breaks and punctuation tidied
  • RID3544 prostatitis: definition punctuation
  • RID3875 nodule: definition bracket and wording fixes
  • RID5701 diffuse: definition split onto one line per source
  • RID5811 linear: definition punctuation
  • RID5812 wedge-shaped: definition bracket fix
  • RID6434 brain: definition punctuation and wording
  • RID14063 subdivision of middle frontal gyrus: Comment line break replaced with ;
  • RID28957 right cingulum bundle: Comment line break replaced with ;
  • RID29173 round mass: definition punctuation and wording
  • RID29215 irregular mass: trailing comma removed from Source
  • RID29927 quadrant of breast: trailing comma removed from Source
  • RID32078 hepatoportal lymph node (obsolete): Comment line break replaced with ;
  • RID34263 Intramammary lymph node: definition typo ("ahve")
  • RID34270 skin thickening: definition spacing ("> 2mm")
  • RID34282 obscured: definition punctuation and wording
  • RID34301 focus: definition spacing
  • RID35978 Chilaiditi syndrome: definition spacing inside parentheses
  • RID49515 tumor invasion of neurovascular bundle of prostate: Comment reformatted as a list
  • RID49820 transitional phase: definition bracket fix

ROBOT diff

The full diff (454 classes) is in docs/changes/fix-whitespace-check2.md.

Markdown would collapse the whitespace being fixed, so values in that file are shown as code: single-line values in code spans, multi-line values in fenced blocks. The two nonbreaking spaces (RID2513 and RID10010) still look like ordinary spaces there.

tests/scripts/robot-report-tests.sh reports no violations on this branch.

🤖 Generated with Claude Code

jclerman and others added 6 commits November 20, 2026 10:28
 - defines the covered properties via rdf:type, not rdfs:subPropertyOf
 - makes an exception for double-space after a period (for now)
 - adds coverage for nonbreaking spaces

Finds 460 violations, to be fixed in later commits
"Was used as an instance-level  slot for a procedure; not needed"
…ment properties only). Fix one more actual ontology value.
Generated as described in docs/CONTRIBUTING.md step 5 (main vs. this
branch, markdown format) and relabeled with scripts/relabel_robot_diff.py.
The "Loaded from" lines show branch names in place of local file paths,
and the Version IRI lines and the empty Ontology imports and Ontology
annotations headings are removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Markdown collapses runs of spaces and line breaks, which hid most of the
fixes in this diff. Single-line values are now in code spans and
multi-line values in fenced code blocks, with ROBOT's HTML entities
unescaped inside them. Nonbreaking spaces still look like spaces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jclerman
jclerman requested a review from hoodcm November 20, 2026 22:18
@jclerman jclerman self-assigned this Nov 20, 2026
@jclerman
jclerman marked this pull request as ready for review November 20, 2026 22:23

@hoodcm hoodcm left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Jeff, good find on the old check. Claude found one gap while I was reviewing: rdfs:label and rdfs:comment aren't declared as annotation properties in RadLex.owl, so ?property a owl:AnnotationProperty skips them. Running this branch's query on labels alone finds 23, all German labels with nonbreaking spaces, such as RID44634. This change picks them up and nothing else:

    { ?property a owl:AnnotationProperty }
    UNION
    { VALUES ?property { rdfs:label rdfs:comment } }

The rest looks good to me.

@jclerman

Copy link
Copy Markdown
Collaborator Author

Thanks Jeff, good find on the old check. Claude found one gap while I was reviewing: rdfs:label and rdfs:comment aren't declared as annotation properties in RadLex.owl, so ?property a owl:AnnotationProperty skips them. Running this branch's query on labels alone finds 23, all German labels with nonbreaking spaces, such as RID44634. This change picks them up and nothing else:

    { ?property a owl:AnnotationProperty }
    UNION
    { VALUES ?property { rdfs:label rdfs:comment } }

The rest looks good to me.

Hi @hoodcm thanks, good catch. Ouch. What do you think of accepting this PR as-is and opening a new ticket for the extension to annotation-properties that are not internally declared? There's a larger question of the right way to gather those, and meantime it'll be good to merge the fixes in this branch so far. Basically seems like adding new properties would be an additive change, not a rollback of what's in this PR so far.

The whitespace check only looked at values of declared annotation
properties. ROBOT adds declarations for undeclared custom properties
when it loads the ontology, but never for OWL's built-in ones, so
rdfs:label, rdfs:comment and owl:versionInfo were skipped. The check now
looks at every literal (except owl:annotatedTarget, which repeats a
reified axiom's value).

That finds 23 German rdfs:label values with nonbreaking spaces
(U+00A0) between words; they are now ordinary spaces. The ROBOT diff
doc is regenerated to include them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jclerman

Copy link
Copy Markdown
Collaborator Author

Thanks, @hoodcm — fixed in place rather than deferred. Rather than adding rdfs:label/rdfs:comment to a list, the check now tests every literal, whatever its property. The underlying cause: ROBOT adds declarations for undeclared custom properties when it loads the ontology, but never for OWL's built-ins (rdfs:label, rdfs:comment, owl:versionInfo, …), so any declaration-based filter misses exactly those. Run time is unchanged (~6 s either way).

That finds the same 23 German labels you found. Each had nonbreaking spaces (U+00A0) between words, which are now ordinary spaces. They're in the regenerated ROBOT diff, though the removed and added values look identical there, since a nonbreaking space renders like a normal one.

Catching custom properties that are used but never declared needs a different kind of check, which is now in #52 / #53 (OWL 2 DL profile check).

@jclerman
jclerman merged commit 677eba9 into main Nov 24, 2026
2 checks passed
@jclerman
jclerman deleted the fix-whitespace-check2 branch November 24, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

annotation-whitespace check is not working - SPARQL issue

3 participants