glam/.opencode/rules/ontology-detection-rule.md

1.3 KiB

Rule: Ontology Detection vs Heuristics

Summary

When detecting classes and predicates in data/ontology/ or external ontology files, you must read the actual ontology definitions (e.g., RDF, OWL, TTL files) to determine if a term is a Class or a Property. Do not rely on naming heuristics (like "Capitalized means Class").

Detail

  • Verification: Always read the source ontology file or use a semantic lookup tool to verify the rdf:type of an entity.
    • If rdf:type is owl:Class or rdfs:Class, it is a Class.
    • If rdf:type is rdf:Property, owl:ObjectProperty, or owl:DatatypeProperty, it is a Property.
  • Avoid Heuristics: Do not assume that skos:Concept is a class just because it looks like one (it is), or that schema:name is a property just because it's lowercase. Many ontologies have inconsistent naming conventions (e.g., schema:Person vs foaf:Person).
  • Strictness: If the ontology file is not available locally, attempt to fetch it or consult authoritative documentation before guessing.

Violation Examples

  • Assuming ex:MyTerm is a class because it starts with an uppercase letter without checking the .ttl file.
  • Mapping a LinkML slot to schema:Thing (a Class) instead of a Property because you guessed based on the name.