Skip to content

Step 7: Instances

11 min · step 7 of 8

Introduction#

Add real examples to test the model you’ve built.

Until now you’ve described kinds of things. An instance is one real thing: this winery, this bottle. Adding a few is the quickest way to find out whether your classes and slots work. If a real wine doesn’t fit, the model needs fixing. You can read the full guide to this step in Method.

What you’ll make#

9 instances: two wineries, four grapes, a region and two wines. One of them is the example from Ontology 101, Chateau Morgon Beaujolais.

Run the commands#

A wine links to a winery, a grape and a region, so create those first:

okb instance add "Chateau Morgon" --of Winery location="Beaujolais, France"
okb instance add "Sterling Vineyards" --of Winery location="Napa Valley, California"
okb instance add Gamay --of WineGrape
okb instance add "Merlot grape" --of WineGrape
okb instance add "Chardonnay grape" --of WineGrape
okb instance add "Riesling grape" --of WineGrape
okb instance add "Beaujolais region" --of WineRegion
Added Chateau Morgon (a Winery).
Chateau Morgon.location = "Beaujolais, France"

Added Sterling Vineyards (a Winery).
Sterling Vineyards.location = "Napa Valley, California"

Added Gamay (a WineGrape).

Added Merlot grape (a WineGrape).

Added Chardonnay grape (a WineGrape).

Added Riesling grape (a WineGrape).

Added Beaujolais region (a WineRegion).

Give each grape-variety class its grape as a fixed value. Every Merlot wine uses the Merlot grape:

okb class fix Merlot "grape=Merlot grape"
okb class fix Chardonnay "grape=Chardonnay grape"
okb class fix Riesling "grape=Riesling grape"
Merlot.grape fixed to Merlot grape

Chardonnay.grape fixed to Chardonnay grape

Riesling.grape fixed to Riesling grape

Now add the wines. Give only the values that aren’t already fixed or defaulted:

okb instance add "Chateau Morgon Beaujolais" --of Beaujolais body=light flavor=delicate tanninLevel=low grape=Gamay "maker=Chateau Morgon" "region=Beaujolais region" sugar=dry
okb instance add "Sterling Vineyards Merlot" --of Merlot "maker=Sterling Vineyards" flavor=moderate tanninLevel=moderate sugar=dry
Added Chateau Morgon Beaujolais (a Beaujolais).
Chateau Morgon Beaujolais.body = "light"
Chateau Morgon Beaujolais.flavor = "delicate"
Chateau Morgon Beaujolais.tanninLevel = "low"
Chateau Morgon Beaujolais.grape = Gamay
Chateau Morgon Beaujolais.maker = Chateau Morgon
Chateau Morgon Beaujolais.region = Beaujolais region
Chateau Morgon Beaujolais.sugar = "dry"

Added Sterling Vineyards Merlot (a Merlot).
Sterling Vineyards Merlot.maker = Sterling Vineyards
Sterling Vineyards Merlot.flavor = "moderate"
Sterling Vineyards Merlot.tanninLevel = "moderate"
Sterling Vineyards Merlot.sugar = "dry"
Filled in default body = "medium".

Then look at both a wine and a winery:

okb show "Chateau Morgon Beaujolais"
okb show "Chateau Morgon"
Chateau Morgon Beaujolais  Instance · i.chateau-morgon-beaujolais
  instance of    Beaujolais

  Values
    tanninLevel        low
    color              red (fixed by RedWine)
    body               light
    flavor             delicate
    sugar              dry
    maker              Chateau Morgon
    grape              Gamay
    region             Beaujolais region
    goesWellWith       RedMeat (fixed by RedWine)

Chateau Morgon  Instance · i.chateau-morgon
  instance of    Winery

  Values
    produces           Chateau Morgon Beaujolais
    location           Beaujolais, France

Read the output#

  • Values you didn’t type. The wine has color red (fixed by RedWine) and goesWellWith RedMeat (fixed by RedWine). They come from its class.
  • A default in action. The Sterling Vineyards Merlot has no body in the command. okb filled in medium from the default you set in step 6. The Beaujolais said body=light, so it keeps that.
  • One edge, two views. Chateau Morgon produces the Beaujolais, yet you never wrote that. produces reads the maker edge backwards. That’s what the inverse in step 6 does.

Check your work#

okb validate
okb status
✗ 0 error(s)   ! 0 warning(s)   i 2 hint(s)   · checks for steps 1–7 (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
(6 warning(s)/hint(s) from later steps are hidden until you get there; okb validate --all shows them. Errors are never hidden.)

Wine and Food  · 21 classes · 11 slots · 9 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 2   okb validate for details

Step 7 looks done. When you're happy with it: okb step next

The Merlot warning from step 6 is gone, because Merlot now has a fixed grape. When step 7 has a tick, move on:

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. “Chateau Morgon Beaujolais” is one wine, so it’s an instance. “Beaujolais” is a kind of wine, so it’s a class. If you can have two of them, it’s a class.
  • Skipping a required link. A wine needs a maker and a grape. okb validate reports what’s missing.
  • Misspelling a value. Writing body=meduim fails, because the allowed values are light, medium and full.

Next step#

You added nine instances and saw fixed values, defaults and an inverse at work. Next, you’ll check the ontology against the six questions from step 1.

View page source