OntologyGenerator derives a formal OWL ontology directly from the entities and relationships already in your knowledge graph — no schema design upfront. Use it to produce a machine-readable contract for your graph’s classes and properties, then export to Turtle, OWL/XML, or JSON-LD for SHACL validation, reasoning engines, and STIX/TAXII toolchains.

What Is an Ontology?

An ontology is a formal specification of the concepts and relationships in a domain. It defines a shared vocabulary for your knowledge graph by declaring: Classes — Types of entities in your domain. For example, ThreatActor, Vulnerability, or Software in cybersecurity. Classes describe what kinds of things exist. Object Properties — Relationships between entities. Examples: exploits (Threat Actor exploits Vulnerability), targets (Malware targets Organization), or uses (Actor uses Tool). Datatype Properties — Attributes with literal values. Examples: name (text), severity_score (decimal), published_date (date), or ip_address (string). An ontology makes your knowledge graph machine-readable by specifying which relationships are valid, what types of values each property can hold, and how concepts relate to each other hierarchically.

Why Use Ontologies?

Consistency. Without an ontology, one team might use “Threat_Actor” while another uses “ThreatActor” for the same concept. Ontologies enforce a single naming convention. Validation. Ontologies enable automatic checking — does this relationship make sense? Should a Vulnerability have a CVSS score as text or number? Reasoning. Exporting to OWL/Turtle lets external reasoning engines (HermiT, Pellet, ELK) infer new facts. If Malware subclasses Software and HAMMERTOSS is Malware, an OWL reasoner concludes HAMMERTOSS is also Software. Semantica exports the ontology; reasoning itself runs in the external tool. Knowledge Graph Quality. Structured schemas catch errors early and ensure new data integrates cleanly with existing entities.

When To Use / When Not To Use

Use ontologies for:
  • Formal knowledge graphs with complex entity relationships
  • Data integration across multiple teams or organizations
  • Automated reasoning and rule-based systems
  • Long-term knowledge bases that need consistency over time
  • Integration with external tools that expect OWL/RDF schemas
Don’t use ontologies for:
  • Simple semantic search over text documents
  • Lightweight RAG where vector similarity is sufficient
  • Prototype development where the schema changes rapidly
  • Single-use data analysis that doesn’t need reusability
  • Cases where the overhead exceeds the complexity of your domain
Semantica’s ontology module derives formal OWL ontologies directly from entities and relationships already in your knowledge graph — no schema design upfront. A 6-stage pipeline infers classes, builds hierarchies, maps OWL types, and serialises to Turtle. The pipeline runs in memory; you do not need a running triple store.

A Simple Example

Start with a familiar business domain to understand the mechanics before diving into cybersecurity:
The base_uri (https://company.example.org/ontology/) becomes the namespace prefix for all classes and properties. Person becomes <https://company.example.org/ontology/Person> in the exported RDF. Object properties connect entities to other entities (works_for, reports_to). Datatype properties connect entities to literal values (name).

The graph that has no schema

Now with a schema understanding, populate a knowledge graph with CTI data to make the pipeline mechanics visible.

Generating the ontology

OntologyGenerator reads your graph dict and runs the 6-stage pipeline.
The hierarchy entry for Malware shows the pipeline detected that malware is a sub-type of software based on co-occurrence patterns in the relationship graph. You can override these inferences manually before exporting.

Validating the schema

Run structural validation before exporting.
A warning about missing datatype properties is common at this stage. It means the inference pipeline found the class in your graph but none of the nodes carried explicit attribute values. You can add properties manually using ClassInferrer and PropertyGenerator before the next export cycle.

Growing the ontology as new node types emerge

Use ClassInferrer to add new entity types incrementally without regenerating the full ontology.
The pattern here is incremental: you run infer_classes on each new batch, review the results, adjust parent assignments where the pipeline guessed wrong, and merge. The ontology grows with the graph rather than falling behind it.

Generating an ontology from unstructured text

LLMOntologyGenerator extracts classes and properties from prose using an LLM — useful for bootstrapping when no structured graph exists yet.
LLMOntologyGenerator is best for bootstrapping a new domain where no structured graph exists yet. Once you have a graph, prefer OntologyGenerator.generate_from_graph() — it is deterministic, reproducible, and does not consume LLM tokens on every run.

Exporting for downstream systems

Export in the format your downstream tools expect.
The exported Turtle file is the input to Semantica’s SHACL validation pipeline. See the SHACL Validation guide for how to generate constraint shapes from this ontology and run them against live graph data.

Common Pitfalls

Over-modeling. Don’t create 50 classes when 10 would suffice. Start simple and add complexity only when you need formal distinctions for reasoning or validation. Having separate classes for MaliciousEmail and PhishingEmail is only useful if they have different properties or relationships. Ontology drift. When new entity types appear in your graph, the ontology becomes stale unless you regenerate or incrementally update it. Set up monitoring to detect when new entity types appear that aren’t covered by your current ontology. Inconsistent class naming. Pick a convention (CamelCase, snake_case, or kebab-case) and stick to it. Mixing ThreatActor, threat_actor, and threat-actor in the same ontology creates confusion and breaks tooling that expects consistent naming patterns.

Domain Examples

A defense CTI team ingests raw OSINT reports each morning. The ontology must stay interoperable with STIX 2.1 and the NATO MISP taxonomy, so IRIs follow the DoD namespace and the ontology is exported to OWL/XML for the org’s SIEM reasoning plugin.

  • SHACL Validation — generate W3C SHACL constraint shapes from your ontology and validate live graph data against them
  • Reasoning & Rules — apply forward/backward-chaining rules over your ontology to derive new facts
  • Export & Serialization — export graphs to RDF, GraphML, CSV, and Neo4j Cypher
  • Semantic Extraction — extract entities and relationships that feed ontology generation
  • Context Graphs — the knowledge graph that ontology generation reads from