Automating Legacy Ontology Extraction with AI Agents: A Practical Workflow
The article explains ontology concepts using food delivery examples, contrasts ontology with knowledge graphs, database schemas, DDD, and OOP, then presents an AI-agent workflow using Palantir ontology skills and Qoder RepoWiki to automatically generate TTL ontology files and HTML visualizations from legacy code, followed by human review for accuracy.
Ontology Basics and Key Distinctions
The author opens with a colleague's complaint about manually constructing an ontology for a legacy system — a slow, error‑prone process. Using a food‑delivery scenario, the article defines ontology as a structured business model that captures objects (customer, order, merchant, rider), their attributes (order amount, status), relationships (place‑order, accept‑order, deliver), and constraints so that AI can process concrete orders with a unified business meaning.
Ontology vs. Knowledge Graph
Ontology focuses on defining what things mean and how they relate ; a knowledge graph focuses on linking specific instances . In the food‑delivery example, the ontology defines "Order", "Customer", "Merchant", "Rider" and their relationships; the knowledge graph records "Xiao Wang placed order O101, accepted by Happy Restaurant, delivered by Li" and connects those concrete entities.
Ontology vs. Database Schema
A well‑designed schema already embodies business modeling, but ontology emphasizes shared business meaning while schema emphasizes how a particular database organizes and constrains data . The same business meaning (amount and status belong to Order; Order links to Customer and Merchant; Order may lack a Rider before assignment) can be implemented with different table designs.
Ontology vs. Domain‑Driven Design (DDD)
Ontology is a model that expresses business meaning ; DDD is a method for designing software around that model . A comparison table highlights:
Core question : Ontology asks "What are the things in the business and how do they relate?" DDD asks "How do we organize software around these concepts?"
Food‑delivery example : Ontology defines Customer, Order, Merchant, Rider meanings and relationships; DDD designs how order trading, payment settlement, and delivery fulfillment divide responsibilities and maintain rules.
Typical artifacts : Ontology produces types, attributes, relationships, semantic constraints; DDD produces ubiquitous language, bounded contexts, domain objects, aggregates.
For a concurrency case where two riders grab the same delivery task, ontology can express the constraint "a delivery task can be assigned to at most one rider at a time"; DDD helps decide which domain object owns that rule, which states must update together, and how delivery collaborates with order and payment. Actual concurrency control remains a programmatic concern. Thus, DDD guides responsibility, behavior, and boundary design; ontology helps systems and agents share and interpret business meaning. They can be combined or used separately.
Ontology vs. Object‑Oriented Programming (OOP)
Ontology is a knowledge model describing what exists in the business world and how it relates; OOP is a programming paradigm organizing program objects' state and behavior. Ontology describes Order's relationships and the meaning of amount and status; OOP defines an Order class with status , amount fields and pay() , cancel() methods. A concrete order O101 (38 CNY, paid) is an instance of that class. The ontology concept "Order" and the code class Order can be mapped but need not be one‑to‑one; one business concept may be implemented by multiple collaborating objects.
Challenges of Manual Ontology Extraction for Legacy Systems
System too large, maintained by many — no single person knows all modules.
Code and documentation severely out of sync.
Team members unfamiliar with ontology modeling, prone to mistakes.
Manual effort is time‑consuming and labor‑intensive.
AI‑Agent‑Assisted Workflow
Building on the idea of encapsulating best practices as reusable skills for agents, the author proposes the following pipeline:
Prepare ontology skill : Package Palantir's official ontology documentation into a skill (open‑sourced at chujianyun/wuming-ontology on GitHub) so the agent can reference authoritative ontology guidelines.
Generate system documentation from code : Use Qoder's RepoWiki to analyze the existing codebase and produce up‑to‑date system documentation.
Agent generates ontology artifacts : Feed the ontology skill and the RepoWiki docs to the agent with a prompt such as:
使用 /wuming-ontology,根据 .qoder/repowiki 中的文档,生成本系统的 .ttl 本体文件和 HTML 可视化页面。
The agent outputs .ttl ontology files and an HTML visualization page.
Review and refine : Open the .ttl in Protégé for editing, or view the generated HTML page for a visual check. Then have one or more domain experts verify the ontology, correcting omissions and misjudgments. The "agent first, human review" loop improves both speed and accuracy.
Storage : For simple cases, store the .ttl directly for agent consumption; for larger scales, use a triple store like Jena TDB2 .
The author invites others to try the workflow and contribute improvements via pull requests to the wuming-ontology skill repository.
References
Taxonomy vs. ontology vs. knowledge graph: What's the difference?
Qdrant: Payload
Neo4j: Patterns
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
