Search code examples
semantic-web

Pancake recipe expressed in Semantic Web triples


As far as I understand some basic principles of the Semantic Web (especially the Resource Description Framework RDF), the semantic is described in tripels with subject, predicate and object.

So for example I can express

Pancake consistsOf Egg
Pancake consistsOf Flour
Pancake consistsOf Milk
Pancake producibleBy PancakeRecipe1
Pancake producibleBy PancakeRecipe2

Main question: How to describe process steps and time dependent statements with Semantic Web triples?

Process steps, amounts

How can I express amounts in a process step with tripels? For example the instruction "use 2 eggs". Maybe this is an approach: PancakeRecipe1 useEggs 2. But this would imply that when I want to offer a universal process description (not only for pancakes), I have to add a predicate for every thing that could ever be part of everything else (even those things that are unknown at the moment).

Another approach: PancakeRecipe1 use2 Egg. This would imply that I have to add a predicate for every amount (even floats). Not practical.

A third approach:

PancakeRecipe1 use 2Eggs
2Eggs isAmountOf Egg
2Eggs value 2

This way at least the number of predicates is constant this way.

A fourth approach: maybe misuse the possibility to upt a literal into the object and combine an amount and the reference to the object into the literal: PancakeRecipe1 use 2,Egg.

A fifth approach: can there be predicates at a predicate? For example PancakeRecipe1 use[amount 2] Egg?

Process steps, order

How can I express the order a pancake recipe with tripels? This would be an additional information at the predicate, I guess (if there may be any additional information at the predicate):

PancakeRecipe1 use[amount 2, order 1] Egg
PancakeRecipe1 use[amount 200, unit g, order 2] Flour
PancakeRecipe1 use[amount 200, unit ml, order 3] Flour

Process steps, conditions

What is the triple expression for "Use either butter or margarine"?

Time dependent statements

How can a Semantic Web triple express chronological events or states? For example the amount of sold pancakes in a city (or maybe the more practical use case: the amount of citizens in a city in history)? There could be something like this:

Berlin soldPancakes2018 12345678
Berlin soldPancakes2019 14567890
Berlin soldPancakes2020 20123456

Or maybe Berlin soldObjects[object Pancake, periodFrom 2018-01-01, periodTo 2018-12-31] 12345678?

How is this expressable in RDF?


Solution

  • There are many subquestions not really related to the main question to fully answer each one of them. You also didn't specify whether you are looking for a particular vocabulary, or just for idea about transforming real-world entities into semantic triples. Let's say we are creating an ontology for the moment.

    Process steps, amounts

    A recipe is similar to a programming function: it has some ingredients (arguments) and steps (statements) to produce the result. You may want to describe them separately.

    <recipe> :uses [
      :product :egg ;
      :minAmount 2
    ] .
    

    Process steps, order

    The individual steps can work in a similar manner, just in a list:

    <recipe> :steps (
      [
        :action :break ;
        :object [
          :product :egg ;
          :amount 2
        ] ;
        :result _:x
      ]
      [
        :action :add ;
        :object _:x
      ]
      [
        :action :add ;
        :object [
          :product :flour ;
          :amount "200"^^:g
        ]
      ]
      [
        :action :mix
      ]
    ) .
    

    Process steps, conditions

    We can link from ingredients or steps to alternatives:

      [
        :action :add ;
        :object [
          :product :flour ;
          :amount "200"^^:g
        ]
        :alternative [
          :action :add ;
          :object [
            :product :magicFlour ;
            :amount "10"^^:g
          ]
        ]
      ]
    

    As you can see, it is not hard to conceive a method for transforming ideas to triples that are sensible. What's hard is to find a consistent way for transforming all such sensible ideas to triples. Luckily, we are already covered by existing ontologies.

    I find the RDFa Core Initial Context a useful place to check for recommended and common vocabularies. From there we can pick what is useful:

    • For describing complex time points or intervals, there is the Time Ontology.

    • Offers with a high degree of details can be described by GoodRelations.

    • For statistics and measurements, there are Data Cubes.

    • And lastly, Schema.org covers many real-world entities, including recipes.