# Ontology-Based Nutritional Recommender System
## 3 Recommender System Architecture
### Ontology of Dietary Recommendations
The \(foodRecSys-V1\) dataset ([[https://www.kaggle.com/elisaxxygao/foodrecsysv1](https://www.kaggle.com/elisaxxygao/foodrecsysv1)]([https://www.kaggle.com/elisaxxygao/foodrecsysv1](https://www.kaggle.com/elisaxxygao/foodrecsysv1)) (accessed on 17 December 2021)), where thousands of recipes have been collected from the Allrecipes.com website, was used to create such a hierarchy. The dataset includes data such as ingredients, nutritional components, and even users' ratings. We randomly selected 105 recipes from the whole dataset and scrutinized details about the ingredients and nutritional components to integrate each recipe in our knowledge base. To do so, we developed a procedure (see Algorithm 1) that analyzes each recipe, extracts its ingredients and nutritional values, and expresses the extracted information in the form of OWL axioms. The process takes such details and utilizes data properties and object properties to link the retrieved data to entities already defined in the knowledge base. For instance, the recipe \"Abuelas_Picadillo\" is made of red wine, butter, bell pepper, garlic, and olive oil, among other ingredients, and contains 74 mg of cholesterol, 378 calories, and 24 g of proteins. Then, the procedure utilizes this information to define the axioms that represent the new recipe with the mentioned ingredients and nutritional values. Figure 3: Axiom to link a diet with the user’s health status. Figure 2: Diets’ hierarchy defined in the ODR. In addition, in order to associate recipes with the type of diets, we defined a specific subclass of _Recipe_ for each diet type (see Figure 4). The aim of this hierarchy is to clearly state the unique constraints, in terms of both ingredients and nutritional values, that a recipe should satisfy to be valid for a given diet. Essentially, each class defines in OWL language the set of nutritional restrictions that users must follow to implement the diet. Therefore, the number of proteins, calories, or allowed types of the ingredient constitute some of the rules defined in those classes. In this way, when a diet is selected, the recipes will be filtered according to these nutritional restrictions in an automatic way using a reasoning engine. For example, the class \(Recipe\_For\_Alkaline\_Diet\) is defined as shown in Figure 5. Since the \(Alkaline\_Diet\) is characterized by high fruit and vegetable content, avoiding chicken, red meat, and eggs, among others, recipes for such a diet should comply with those restrictions. The ontology was developed in OWL 2 [53] and is available at [[https://agrisemantics.inf.um.es/ontologies/ODR](https://agrisemantics.inf.um.es/ontologies/ODR)]([https://agrisemantics.inf.um.es/ontologies/ODR](https://agrisemantics.inf.um.es/ontologies/ODR)) (accessed on 16 December 2021). Table 2 shows some of the most relevant metrics of the ontology. The correctness of the resulting ontology was checked using the following tools: (i) the RDFS Validator ([[https://www.w3.org/RDF/Validator/](https://www.w3.org/RDF/Validator/)]([https://www.w3.org/RDF/Validator/](https://www.w3.org/RDF/Validator/)), accessed on 16 December 2021) to repair the definitions of concepts, relations, and instances;  
Figure 4: Hierarchy of recipes created for each specific diet. Figure 5: Semantic definition of the class \(Recipe\_For\_Alkaline\_Diet\). (ii) OOPS! ([[http://oops.linkeddata.es/catalogue.jsp](http://oops.linkeddata.es/catalogue.jsp)]([http://oops.linkeddata.es/catalogue.jsp](http://oops.linkeddata.es/catalogue.jsp)), accessed on 16 December 2021) (the OntOlogy Pitfall Scanner!) to identify deficiencies in metadata information such as license and version information, among others; (iii) OQuare ([[https://semantics.inf.um.es/ontolo/gy-metrics/](https://semantics.inf.um.es/ontolo/gy-metrics/)]([https://semantics.inf.um.es/ontolo/gy-metrics/](https://semantics.inf.um.es/ontolo/gy-metrics/)), accessed on 16 December 2021) to test the model's features. Figure 6 depicts the core concepts of the resulting ontology.