Food Ontology and Semantic Web
Table of Contents
Overview
Food ontologies provide formal, machine-readable representations of food-related knowledge, enabling semantic interoperability between nutrition databases, recipe systems, dietary applications, and scientific research platforms. This research explores the landscape of food ontologies, their design patterns using OWL and RDF, integration with linked data ecosystems, and practical applications in nutrition informatics and food traceability systems.
Background
The food domain presents unique ontological challenges due to its inherent complexity: foods exist as biological entities, cultural artifacts, commercial products, and nutritional compositions simultaneously. Early efforts to standardize food data focused on hierarchical classification systems like USDA food codes, but these lacked the expressivity needed for modern applications requiring inference, cross-database mapping, and multilingual support.
The semantic web movement provided the technological foundation for food ontologies through RDF (Resource Description Framework), OWL (Web Ontology Language), and SPARQL query capabilities. Projects like FoodOn emerged from the need to unify disparate food vocabularies across agriculture, nutrition science, food safety, and consumer applications.
Key Concepts
Core Food Ontologies
FoodOn
The Food Ontology (FoodOn) provides a comprehensive vocabulary for food description:
@prefix foodon: <http://purl.obolibrary.org/obo/FOODON_> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
foodon:00001002 a owl:Class ;
rdfs:label "apple (whole, raw)" ;
rdfs:subClassOf foodon:00001714 ; # pome fruit
foodon:has_food_substance_analog foodon:03301710 .
Open Food Facts
Community-driven product database with structured nutritional data:
- Barcode-indexed products
- Nutritional composition
- Ingredients parsing
- Nutri-Score calculations
USDA FoodData Central
Authoritative nutritional composition database:
- Foundation Foods
- SR Legacy
- Branded Foods
- Survey Foods (FNDDS)
Ontology Design Patterns
Food Product Hierarchy
@prefix : <http://example.org/food#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
:Food a owl:Class .
:PlantFood a owl:Class ;
rdfs:subClassOf :Food .
:Fruit a owl:Class ;
rdfs:subClassOf :PlantFood .
:Apple a owl:Class ;
rdfs:subClassOf :Fruit ;
:hasNutrient :Fiber, :VitaminC ;
:typicalServingSize "182"^^xsd:decimal ;
:servingUnit "gram" .
Nutritional Composition
:NutrientContent a owl:Class .
:AppleNutrition a :NutrientContent ;
:food :Apple ;
:nutrient :Calories ;
:amount "95"^^xsd:decimal ;
:unit "kcal" ;
:per "182g serving" .
:Macronutrient a owl:Class .
:Micronutrient a owl:Class .
:Fiber a :Macronutrient ;
rdfs:label "Dietary Fiber" ;
:dailyValue "28"^^xsd:decimal ;
:unit "gram" .
Recipe Modeling
:Recipe a owl:Class .
:ApplePie a :Recipe ;
:hasIngredient [
:food :Apple ;
:quantity "6"^^xsd:integer ;
:preparation "sliced"
] ;
:hasIngredient [
:food :Sugar ;
:quantity "150"^^xsd:decimal ;
:unit "gram"
] ;
:cookingMethod :Baking ;
:cookingTime "PT45M"^^xsd:duration .
Linked Data Integration
Food ontologies connect to broader knowledge graphs:
- DBpedia: General encyclopedic knowledge
- Wikidata: Structured Wikipedia data
- schema.org: Web-scale structured data (Recipe, NutritionInformation)
- AGROVOC: FAO agricultural vocabulary
Implementation
SPARQL Queries
# Find foods high in vitamin C
PREFIX food: <http://example.org/food#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?food ?vitaminC
WHERE {
?food a food:Food ;
food:hasNutrientContent ?content .
?content food:nutrient food:VitaminC ;
food:amount ?vitaminC .
FILTER (?vitaminC > 50)
}
ORDER BY DESC(?vitaminC)
Schema.org Integration
{
"@context": "https://schema.org",
"@type": "Recipe",
"name": "Apple Pie",
"nutrition": {
"@type": "NutritionInformation",
"calories": "320 calories",
"carbohydrateContent": "45 g",
"fiberContent": "3 g"
},
"recipeIngredient": [
"6 medium apples",
"3/4 cup sugar"
]
}
Python Implementation with RDFLib
from rdflib import Graph, Namespace, Literal, URIRef from rdflib.namespace import RDF, RDFS, XSD FOOD = Namespace("http://example.org/food#") g = Graph() g.bind("food", FOOD) # Add food item apple = URIRef(FOOD.Apple) g.add((apple, RDF.type, FOOD.Fruit)) g.add((apple, RDFS.label, Literal("Apple"))) g.add((apple, FOOD.calories, Literal(95, datatype=XSD.integer))) # Query for s, p, o in g.triples((None, FOOD.calories, None)): print(f"{s} has {o} calories")
References
- FoodOn - Food Ontology
- Open Food Facts
- USDA FoodData Central
- OWL 2 Web Ontology Language
- Schema.org Recipe
- OBO Foundry - Biomedical ontology standards
Notes
- Food identity is context-dependent (biological vs. culinary vs. commercial)
- Multilingual support is essential for global food vocabularies
- Provenance and traceability require supply chain ontology integration
- Allergen and dietary restriction modeling needs careful attention
- Consider cultural and regional food naming variations
- Integration with agricultural ontologies enables farm-to-fork tracking