Introduction#
Turn the things on your term list into classes, and arrange them from general to specific.
A class is a kind of thing, like Wine or Winery. A class below another one is its subclass: RedWine is a subclass of Wine. The arrangement matters because everything you say about Wine later also applies to every subclass. Most modeling mistakes are mistakes in this arrangement. You can read the full guide to this step in Method.
What you’ll make#
21 classes in a tree, with Wine at the top and specific wines such as Pauillac at the bottom. You’ll also have a naming convention, a few declared “can’t be both” groups, and two recorded design decisions.
Set the convention#
Pick how classes are named before you create any. This is your naming convention. The defaults are fine: PascalCase and singular, but you can customize them. See the okb convention reference for the options.
okb convention
Naming convention: classes PascalCase (singular) · slots camelCase · instances free text
Add Wine#
Say each link out loud before you add it: “Every red wine is a wine.” If it sounds wrong, it is. Start with Wine:
okb class add Wine --desc "A specific wine produced by a specific winery (not an individual bottle)."
Added class Wine at the top level.
Now make a mistake on purpose. Plural names are a classic error: a single Wine isn’t a kind of Wines. Run this command. It fails, even with --force:
okb class add Wines --parent Wine --force
(node:2511) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
(Use `node --trace-warnings ...` to show where the warning was created)
✗ 'Wines' can't be a subclass of 'Wine': they're the singular and plural of the same concept, so neither is a kind of the other (Ontology 101 §4.1: "a single Wine is not a kind of Wines"). Use one class.
okb refused Wines as a subclass of Wine even with --force. Some mistakes are never right, so okb doesn’t let you override them.
Add colors#
Add the middle level next, then say which groups can’t overlap. A wine can’t be both red and white, so declare those classes disjoint:
okb class add RedWine --parent Wine --desc "Wine made from dark-skinned grapes with skin contact; described by tannin level."
okb class add WhiteWine --parent Wine --desc "Wine fermented without grape skins."
okb class add RoseWine --parent Wine --desc "Wine with brief skin contact giving a pink color." --synonym Rosé
okb class add DessertWine --parent Wine --desc "Sweet wine served with or as dessert."
okb class disjoint RedWine WhiteWine RoseWine
Added class RedWine (a kind of Wine).
Added class WhiteWine (a kind of Wine).
Can anything be both a WhiteWine and a RedWine? If not, say so: okb class disjoint "WhiteWine" "RedWine"
Added class RoseWine (a kind of Wine).
Added class DessertWine (a kind of Wine).
Declared disjoint: RedWine, WhiteWine, RoseWine. Nothing can be more than one of these now.
Add specific wines#
Bordeaux and its regions are classes even though they add no slots of their own. A slot is a fact you can state about a class, such as color, and you’ll add them in step 5. Experts always tell them apart, so they earn a place. Port has two parents because it’s both a red wine and a dessert wine:
okb class add Bordeaux --parent RedWine --terminological --desc "Red wine from the Bordeaux region of France."
okb class add Medoc --parent Bordeaux --terminological --desc "Bordeaux from the Médoc sub-region."
okb class add Pauillac --parent Medoc --terminological --desc "Médoc wine from the Pauillac appellation."
okb class add Margaux --parent Medoc --terminological --desc "Médoc wine from the Margaux appellation."
okb class add Beaujolais --parent RedWine --terminological --desc "Light red wine from the Beaujolais region, made from Gamay."
okb class add Merlot --parent RedWine --desc "Red wine made from the Merlot grape."
okb class add Port --parent RedWine --parent DessertWine --desc "Fortified sweet red wine from Portugal. (Only red Ports are modeled, as in the paper.)"
okb class add Chardonnay --parent WhiteWine --desc "White wine made from the Chardonnay grape."
okb class add Riesling --parent WhiteWine --desc "White wine made from the Riesling grape."
okb class disjoint Chardonnay Riesling
okb class add Sauternes --parent WhiteWine --parent DessertWine --desc "Sweet white wine from the Sauternes area of Bordeaux."
Added class Bordeaux (a kind of RedWine).
Added class Medoc (a kind of Bordeaux).
Added class Pauillac (a kind of Medoc).
Added class Margaux (a kind of Medoc).
Can anything be both a Margaux and a Pauillac? If not, say so: okb class disjoint "Margaux" "Pauillac"
Added class Beaujolais (a kind of RedWine).
Can anything be both a Beaujolais and a Bordeaux? If not, say so: okb class disjoint "Beaujolais" "Bordeaux"
Added class Merlot (a kind of RedWine).
Added class Port (a kind of RedWine and DessertWine).
Multiple parents are fine when it's truly a kind of each. Consider recording why with `okb decision add`.
Added class Chardonnay (a kind of WhiteWine).
Added class Riesling (a kind of WhiteWine).
Can anything be both a Riesling and a Chardonnay? If not, say so: okb class disjoint "Riesling" "Chardonnay"
Declared disjoint: Chardonnay, Riesling. Nothing can be more than one of these now.
Added class Sauternes (a kind of WhiteWine and DessertWine).
Note: 'Sauternes' looks plural, but class names here are singular. If it's a proper name that just ends in 's' (like Sauternes), that's fine: record it with okb decision add ... --waives naming-singular-plural-consistent.
Multiple parents are fine when it's truly a kind of each. Consider recording why with `okb decision add`.
Sauternes ends in “s”, so okb suspects a plural. It isn’t one: it’s the name of a place. Record that as a design decision, a note that explains a choice, so the warning is explained instead of ignored:
okb decision add --title "Sauternes keeps its final s" --decision "The class is named Sauternes, not Sauterne." --why "It's the proper name of the appellation, not a plural." --about Sauternes --waives naming-singular-plural-consistent
Recorded design decision d.2: Sauternes keeps its final s.
It explains 1 current finding(s) from naming-singular-plural-consistent (they'll show as 'explained' in okb validate).
Add the rest#
Add classes for wineries, grapes and regions, and for the food that wines pair with. Food is an abstract class: it only groups Seafood and RedMeat, and nothing is directly “a Food”:
okb class add Winery --desc "A business that makes wine."
okb class add WineGrape --desc "A grape variety used to make wine." --synonym Varietal
okb class add WineRegion --desc "A geographic area wines are named after or come from."
okb class add Food --abstract --desc "A kind of dish or ingredient a wine can be paired with."
okb class add Seafood --parent Food --desc "Fish and shellfish dishes."
okb class add RedMeat --parent Food --desc "Beef, lamb and similar dishes, including grilled meat."
okb class disjoint Seafood RedMeat
Added class Winery at the top level.
Added class WineGrape at the top level.
Added class WineRegion at the top level.
Added class Food at the top level.
Added class Seafood (a kind of Food).
Added class RedMeat (a kind of Food).
Can anything be both a RedMeat and a Seafood? If not, say so: okb class disjoint "RedMeat" "Seafood"
Declared disjoint: Seafood, RedMeat. Nothing can be more than one of these now.
Settle the terms#
Go back to the term list from step 3. Mark each term as a class or as out of scope, so nothing stays “undecided” by accident:
okb term set "vintage year" --as out-of-scope --note "Vintage questions deferred to v2"
okb term set "label paper" --as out-of-scope
okb term set port --as class --node Port
okb term set "rosé wine" --as class --node RoseWine
'vintage year' → out-of-scope.
'label paper' → out-of-scope.
'port' → class.
Linked to Class 'Port'.
'rosé wine' → class.
Linked to Class 'RoseWine'.
One more decision to record. Bordeaux has only one direct subclass, which okb finds suspicious. Here it’s deliberate:
okb decision add --title "Regional wines are terminological classes" --decision "Bordeaux, Medoc, Pauillac, Margaux and Beaujolais are classes even though they add no slots of their own." --why "Sommeliers and diners always distinguish these appellations (Ontology 101 §4.4: distinctions experts commonly make)." --about Bordeaux --about Medoc --about Beaujolais --waives hier-single-child
Recorded design decision d.3: Regional wines are terminological classes.
It explains 1 current finding(s) from hier-single-child (they'll show as 'explained' in okb validate).
Read the output#
- The follow-up questions. After some
class addcommands, okb asked “Can anything be both…?”. It nudges you to declare disjoint groups while the idea is fresh. Disjoint classes and multiple parents explains why. - Two parents. Port and Sauternes each sit under two classes, which is multiple inheritance. The tree shows them twice, with “also under” and “see above”. For how the tree works, see Is a kind of.
- Hints versus warnings. The two hints at the end are suggestions. A warning you’ve explained with a decision moves to its own list instead of staying open.
Check your work#
Look at the tree, then run the checks that apply to steps 1 to 4:
okb tree
okb validate
Food (abstract)
└ RedMeat
└ Seafood
Wine
└ DessertWine
└ Port (also under RedWine)
└ Sauternes (also under WhiteWine)
└ RedWine
└ Beaujolais
└ Bordeaux
└ Medoc
└ Margaux
└ Pauillac
└ Merlot
└ Port (see above)
└ RoseWine
└ WhiteWine
└ Chardonnay
└ Riesling
└ Sauternes (see above)
WineGrape
WineRegion
Winery
✗ 0 error(s) ! 0 warning(s) i 2 hint(s) · checks for steps 1–4 (use --all for the rest)
HINTS: worth a look
i The subclasses of 'RedWine' ('Bordeaux', 'Beaujolais', 'Merlot', 'Port') 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).
i The subclasses of 'Medoc' ('Pauillac', 'Margaux') 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 (2)
· Class 'Sauternes' looks plural, but the convention is singular. Try 'Sauterne'. [naming-singular-plural-consistent] → d.2
· 'Bordeaux' has only one direct subclass ('Medoc'). Is a sibling missing, or is the subclass really the same as its parent? [hier-single-child] → d.3
Learn about any rule: okb explain <rule-id> · add --why for reasons and sources
(9 warning(s)/hint(s) from later steps are hidden until you get there; okb validate --all shows them. Errors are never hidden.)
You should see no errors and no warnings. The two hints say that some sibling classes might overlap. You can leave them for now. Check the step:
okb status
Wine and Food · 21 classes · 0 slots · 0 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 ◀ you are here
✓ A naming convention is set
✓ At least two classes, organized with at least one is-a link
✓ The class hierarchy has no known mistakes
? You've stood back and looked at the whole tree, checking each is-a link against the "Is this really a subclass?" guide
○ 5. Define the properties of classes (slots)
○ 6. Define the facets of the slots
○ 7. Create instances
○ 8. Review against your questions, and iterate
Validator (steps 1–4): ✗ 0 ! 0 i 2 okb validate for details
Step 4 looks done. When you're happy with it: okb step next
When step 4 has a tick, move on:
okb step next
Now on step 5. (To read a step's guide without moving: okb explain 5)
Step 5 of 8: Define the properties of classes (slots)
Goal: Turn the remaining terms into slots and attach each one to the most general class whose
members all have it.
Why it matters: Classes alone can't answer your questions. Slots hold the facts and
relationships the answers are made of.
Questions to answer
• Which remaining terms describe a class rather than being one?
• For each: is it intrinsic (flavor), extrinsic (name, region), a part, or a relationship to
another thing (maker)?
• What is the most general class whose members all have this property?
• Which competency question needs this slot?
You're done when
○ At least one slot
○ Every slot is attached to at least one class
Tips
• Two kinds of slot: properties hold a value (name, year, one of a list); relationships point
at another thing (maker → Winery).
• Name relationships as verbs or roles read from the domain class: a Wine has a maker; a
Winery produces wines.
• If you're attaching the same slot to every child, attach it to the parent instead.
In Ontology 101's wine example
• Wine gets: color, body, flavor, sugar, name, maker, grape
• Winery gets: location, produces
• Red Wine gets: tanninLevel, because white wines aren't described by tannin
Decision guides for this step (okb explain <id>)
decision.slot-placement Which class does this slot go on?
decision.class-or-value New class, or just a slot value?
Commands
okb property add okb relationship add okb show okb term set
Common mistakes
- Plural names.
Winesinstead ofWine. okb refuses these, as you saw.- A class for every adjective. “Expensive wine” isn’t a kind of wine. It’s a property of a wine, and step 5 handles it.
- A subclass that isn’t a kind. A winery isn’t a kind of wine. If the sentence “every X is a Y” sounds wrong, don’t link them.
- No disjoint groups. Without them, okb can’t catch a wine labeled both red and white.
Next step#
You built a tree of 21 classes, with Wine at the top, and recorded two design decisions. Next, you’ll describe those classes with slots, such as color and maker.