Introduction#
Add the real things your ontology describes.
An instance is one specific thing, like the cortado on your café’s menu. Classes say what kinds of things exist. Instances are the things. You can read the full guide to this step in Method.
What you’ll make#
16 instances: eight ingredients, such as “Steamed whole milk”, and eight menu items, each linked to what goes in it.
Add ingredients#
Run okb instance add with --of for the class. Add the ingredients first, so the drinks can point at them:
okb instance add "Double shot" --of Coffee
okb instance add "Hot water" --of Water
okb instance add "Steamed whole milk" --of WholeMilk
okb instance add "Steamed half-and-half" --of HalfAndHalf
okb instance add "Milk foam" --of Foam
okb instance add "Chocolate syrup" --of Chocolate
okb instance add "Whipped cream" --of WhippedCream
okb instance add "Vanilla gelato" --of Gelato
Added Double shot (a Coffee).
Added Hot water (a Water).
Added Steamed whole milk (a WholeMilk).
Added Steamed half-and-half (a HalfAndHalf).
Added Milk foam (a Foam).
Added Chocolate syrup (a Chocolate).
Added Whipped cream (a WhippedCream).
Added Vanilla gelato (a Gelato).
Add the menu#
Now add the menu items. Give only the values that aren’t already fixed or defaulted. A cortado needs no ratio, because the class already fixes it:
okb instance add "House espresso" --of Espresso "contains=Double shot" "pourOrder=Shot into a warm cup"
okb instance add "Vertex cortado" --of Cortado "contains=Double shot,Steamed whole milk" "pourOrder=Shot first, then equal warm milk"
okb instance add "Vertex flat white" --of FlatWhite "contains=Double shot,Steamed whole milk" "pourOrder=Shot first, then thin milk"
okb instance add "Vertex cappuccino" --of Cappuccino "contains=Double shot,Steamed whole milk,Milk foam" "pourOrder=Shot, milk, then a cap of foam"
okb instance add "Vertex breve" --of Breve "contains=Double shot,Steamed half-and-half,Milk foam" "pourOrder=Shot, half-and-half, then foam"
okb instance add "Vertex mocha" --of Mocha "contains=Double shot,Chocolate syrup,Steamed whole milk" "pourOrder=Chocolate, shot, then milk"
okb instance add "Vertex affogato" --of Affogato "contains=Double shot,Vanilla gelato" "pourOrder=Gelato first, shot poured over"
Added House espresso (an Espresso).
House espresso.contains = Double shot
House espresso.pourOrder = "Shot into a warm cup"
Added Vertex cortado (a Cortado).
Vertex cortado.contains = Double shot, Steamed whole milk
Vertex cortado.pourOrder = "Shot first, then equal warm milk"
Filled in default texture = "silky".
Added Vertex flat white (a FlatWhite).
Vertex flat white.contains = Double shot, Steamed whole milk
Vertex flat white.pourOrder = "Shot first, then thin milk"
Added Vertex cappuccino (a Cappuccino).
Tip: Cappuccino has subclasses (Breve). Use the most specific class that fits.
Vertex cappuccino.contains = Double shot, Steamed whole milk, Milk foam
Vertex cappuccino.pourOrder = "Shot, milk, then a cap of foam"
Filled in default espressoToMilkRatio = 0.33.
Filled in default texture = "foamy".
Filled in default origin = "Italy".
Added Vertex breve (a Breve).
Vertex breve.contains = Double shot, Steamed half-and-half, Milk foam
Vertex breve.pourOrder = "Shot, half-and-half, then foam"
Filled in default espressoToMilkRatio = 0.33.
Filled in default texture = "foamy".
Filled in default origin = "USA".
Added Vertex mocha (a Mocha).
Vertex mocha.contains = Double shot, Chocolate syrup, Steamed whole milk
Vertex mocha.pourOrder = "Chocolate, shot, then milk"
Added Vertex affogato (an Affogato).
Vertex affogato.contains = Double shot, Vanilla gelato
Vertex affogato.pourOrder = "Gelato first, shot poured over"
Add a link value#
Some facts belong to the link itself. A macchiato has only a splash of foam, so say that on the link:
okb instance add "Vertex macchiato" --of Macchiato "contains=Double shot" "pourOrder=Shot, then a spoonful of foam"
okb link "Vertex macchiato" contains "Milk foam" amount=splash
Added Vertex macchiato (a Macchiato).
Vertex macchiato.contains = Double shot
Vertex macchiato.pourOrder = "Shot, then a spoonful of foam"
Filled in default texture = "silky".
Linked (Vertex macchiato)-[:CONTAINS {amount: "splash"}]->(Milk foam)
Read the output#
Look at a drink and at an ingredient:
okb show "Vertex breve"
okb show "Milk foam"
Vertex breve Instance · i.vertex-breve
instance of Breve
Values
espressoToMilkRatio 0.33
texture foamy
pullVolumeMl —
pourOrder Shot, half-and-half, then foam
origin USA
contains Double shot, Steamed half-and-half, Milk foam
variationOf Latte, Cappuccino (fixed by Breve)
Milk foam Instance · i.milk-foam
instance of Foam
Values
usedIn Vertex cappuccino, Vertex breve, Vertex macchiato {amount: "splash"}
- Values you didn’t type. The breve has
espressoToMilkRatioandtexturefrom the defaults on Cappuccino, andoriginfrom its own default, USA.variationOflists both Latte and Cappuccino, from the class. - One edge, two views. “Milk foam” lists the drinks it goes into, though you only wrote
contains. That’s the inverse from step 6.
Check your work#
okb validate
okb status
✗ 0 error(s) ! 0 warning(s) i 4 hint(s) · checks for steps 1–7 (use --all for the rest)
HINTS: worth a look
i 'Drink' has only one direct subclass ('EspressoDrink'). Is a sibling missing, or is the subclass really the same as its parent? [hier-single-child]
Fix: Add the missing sibling(s), or remove the child and fold it into the parent. If
neither applies, record a design decision.
i 'Cappuccino' has only one direct subclass ('Breve'). Is a sibling missing, or is the subclass really the same as its parent? [hier-single-child]
Fix: Add the missing sibling(s), or remove the child and fold it into the parent. If
neither applies, record a design decision.
i 'Latte' has only one direct subclass ('Breve'). Is a sibling missing, or is the subclass really the same as its parent? [hier-single-child]
Fix: Add the missing sibling(s), or remove the child and fold it into the parent. If
neither applies, record a design decision.
i The subclasses of 'MilkDrink' ('Macchiato', 'Cortado', 'FlatWhite', 'Cappuccino', 'Latte') have no disjointness declared. Can anything be more than one of them? [disjoint-consider-siblings]
Fix: `okb class disjoint A B C`, or ignore it if the siblings can overlap (Dessert Wine
and White Wine can).
EXPLAINED by design decisions (3)
· Subclasses of 'EspressoDrink' are named inconsistently: 'MilkDrink', 'SweetenedDrink' include 'drink' but 'PureEspresso' doesn't. [naming-subclass-names-consistent] → d.2
· Subclasses of 'PureEspresso' are named inconsistently: 'Espresso' includes 'espresso' but 'Ristretto', 'Lungo', 'Americano', 'LongBlack' don't. [naming-subclass-names-consistent] → d.2
· Subclasses of 'Milk' are named inconsistently: 'WholeMilk', 'CondensedMilk' include 'milk' but 'HalfAndHalf' doesn't. [naming-subclass-names-consistent] → d.4
Learn about any rule: okb explain <rule-id> · add --why for reasons and sources
(6 warning(s)/hint(s) from later steps are hidden until you get there; okb validate --all shows them. Errors are never hidden.)
Espresso drinks · 31 classes · 9 slots · 16 instances · 6 questions
✓ 1. Determine the domain and scope
✓ 2. Consider reusing existing ontologies
✓ 3. Enumerate important terms
✓ 4. Define the classes and the class hierarchy
✓ 5. Define the properties of classes (slots)
✓ 6. Define the facets of the slots
✓ 7. Create instances ◀ you are here
✓ At least a few instances (enough to answer one competency question end to end)
✓ The instances have no known mistakes
○ 8. Review against your questions, and iterate
Validator (steps 1–7): ✗ 0 ! 0 i 4 okb validate for details
Step 7 looks done. When you're happy with it: okb step next
okb step next
Now on step 8. (To read a step's guide without moving: okb explain 8)
Step 8 of 8: Review against your questions, and iterate
Goal: Stand back: check each competency question can be answered, run the full validator,
review the judgment-only rules, record decisions, and go around again.
Why it matters: The only real test of an ontology is whether it does the job it was built for.
Expect to loop back to earlier steps.
Questions to answer
• For each competency question: which classes, slots and instances answer it? Is anything
missing?
• For each answered question: would the ontology also answer the rest of its family, the same
question about similar things and the questions next to it? Which of those are out of scope?
• Is there anything in the ontology no question needs?
• Would a domain expert agree with the hierarchy? Show it to one.
• Which choices would surprise someone reusing this ontology? Are they recorded as design
decisions?
You're done when
○ Every competency question is linked to what answers it
? Each question's family has been considered: wanted questions added, the rest recorded as out of scope
○ The whole ontology has no known mistakes
○ Every remaining issue is fixed or explained in a design decision
? Someone who knows the domain has looked at it
Tips
• Iteration is part of the method, not a sign you went wrong.
• Use the ontology-review skill for the judgment rules a script can't check.
In Ontology 101's wine example
Ontology 101's own evolution example: Zinfandel starts under Red Wine, then 'white zinfandel'
appears and the class has to be split into White Zinfandel and Red Zinfandel.
Commands
okb cq link okb validate --all okb decision add okb diagram
Common mistakes
- Making an instance a class. “Vertex cortado” is one cup on one menu. “Cortado” is a kind.
- Skipping a required link. A drink needs at least one ingredient, so
okb validatereports a drink withoutcontains.
Next step#
You added eight ingredients and eight menu items. Next, you’ll check the ontology against your questions and add two rules.