Introduction

Food additives have been used for centuries to enhance the appearance and flavor of food and prolong shelf life. The food additives are used by current food industry mostly to add color, stabilize, texturize, preserve, sweeten, thicken, add flavor, soften, emulsify, and so forth. The FDA (Food and Drug Administration) depicts a massive increase in the number of “generally recognized as safe” (GRAS) food additives used in food. According to the Pew Charitable Trusts, there are currently more than 10,000 additives used in food, and that number continues to grow daily. Back in 1958, on the other hand, when Congress first gave the FDA authority over food additives, there were only about 800 additives in useFootnote 1.

A typical American household spends about 90 % of their food budget on processed foods, and are in doing so exposed to a plethora of artificial food additives, many of which can cause dire consequences to individual’s health. Some food additives are worse than others and needed to avoid such as Artificial Sweeteners Aspartame (E951), High Fructose Corn Syrup, Monosodium Glutamate (MSG / E621), Trans Fat, Common Food Dyes {Blue #1 and Blue #2 (E133), Red dye # 3 (also Red #40 – a more current dye) (E124), Yellow #6 (E110) and Yellow Tartrazine (E102)}, Sodium Sulfite (E221), Sodium Nitrate/Sodium Nitrite etc2. By controlling what and how much to eat as well as what not to eat, we can maximize patients’ life quality and decrease usage of unhealthy ingredients. To get safe food consumption under control by patients, we need smart e-health systems that have semantic base knowledge base systems and can be easily extended to provide information from additional e-health tools.

Such e-health knowledge base systems start to examine for side effects of food additives and energy details according to the consumer’s health condition (such as heart disease, hypertension, cholesterol, asthma, diabetes, allergies, alzheimer etc.) through sets of inference rules of the system’s knowledge base according to diseases types. Any side effect of food additives may able to effect one or more types of health risks or diseases. For instance, the “Aspartame (E951)” more popularly known as NutraSweet and Equal, is found in foods labeled “diet” or “sugar free”. The components of this sweetener may lead to a wide variety of ailments including brain tumor, diseases like lymphoma, diabetes, multiple sclerosis, parkinson, alzheimer, fibromyalgia, and chronic fatigue, emotional disorders like depression and anxiety attacks, dizziness, headaches, nausea, mental confusion, migraines and seizuresFootnote 2. Beside this, e-health knowledge base systems may return found intolerance or side effects information via some predefined inferencing rules according to the current disease of a customer.

The Semantic Web [1] is an extension of the current Web in which information has a well-defined meaning. This approach enables better cooperation between computers and people. An ontology [2] (expressed in Web Ontology Language (OWL) as the conceptual language of the Semantic Web) is a specification of a conceptualization of a knowledge domain. It is a controlled vocabulary that formally describes concepts and their relationships. According to W3C, OWL is a family of knowledge representation languages for reasoning through ontologies. Recently, many ontological languages have been proposed and standardized such as RDF(S)Footnote 3, OWL, and its new version OWL 2.0 [3]. OWL expresses concepts in ontological form with specific spatial terms and features. In this way, it is possible to adapt heterogeneous information from distributed information systems. Additionally, each concept described in the ontology encapsulates a subset of instance data from the domain of discourse. The ontology knowledge base provides appropriate results in terms of human communication with the information in a machine-understandable format (OWL) or, in contrast, standardized methods are used for data match from the database, with data written in free style, such as the ingredients of food products on the food package. Thus, the Semantic Web is used in order to share and integrate information not only in natural language but also by using the associated software so it can be understood, interpreted, and expressed in a way that makes it easier to find the required data using the software.

The knowledge base in the proposed system describes health risk groups, unhealthy ingredients or compounds in foods, ingredients unsuitable for those in the risk groups condition (such as heart disease, hypertension, cholesterol, asthma, diabetes, allergies, alzheimer etc.) ingredients with side effects depending on patient characteristics, and so on. Therefore, through the Semantic technology approach featuring ontology knowledge base usage, technical personal health systems are based on ontological knowledge management, which is easily extensible to allow adoption of additional e-health tools. The knowledge base is shared between personal health services and e-health devices that provide interoperation specified by using OWL technology.

This article discusses a funded research project based on a mobile safe food consumption system (FoodWiki) that examines the side effects causing various types of diseases, available through SW technology, that provides easily informatics to a member consumer who is searching for an packaged food product from market shelves, according to his or her present disease. The packaged food products on the market shelves need to be described to the food consumers via inferencing e-health systems according to the food sensitivity rules on disease types.

Mobile application of the proposed FoodWiki system enables its users to use an interface as a web service that performs FoodWiki transactions both online or offline modes. The system uses its own semantic knowledge base that involves four subsections: Person, Diseases, Product, and Food Ingredients. We assumed the entire ingredients list of products would be kept in a database of the country’s agriculture ministry or food companies on Web. Because, entire food firms in the industry have to report information about their products such as ingredients, additives, and other details to the country’s agriculture ministry according to law. Therefore, the database of the country’s agriculture ministry keeps a unique International Article Number (EAN)Footnote 4 of each product via QR codes or barcodes that are printed on the packaging of food products during production.

Thus, the proposed system investigates some aspect of the packaged product details via unique code numbers on food packages and then parses semantics from the system knowledge base to perform its functionalities. The system presents to it users the available side effects of nutrients or food additives according to the user’s health conditions, and then it examines those with the nutrients or food additives of a selected product through a series of concept matching operations using smart mobile devices during shopping. In the future, the proposed system examines and provides smart food menus for individuals by accessing annotations of appropriate foods for them according to their personal health and profile information, via the semantic based food knowledge bases [48].

The rest of this paper is planned as follows: Second section presents the problem definition and then mentions working mechanism of the proposed system. Third section presents some case studies via mobile app of the system. Fourth section discusses similar food knowledge bases in the literature and also a detailed description of the food knowledge base used in the system. Fifth section describes the inference mechanism that makes use of semantic rules, which is able to identify ingredients with side effects according to consumer health conditions before the food product is consumed. Sixth section presents the implementation of the Java Web services via some well-known Semantic Web tools that runs between the developed mobile app and the developed knowledge base of the system, while Seventh section is dedicated to conclusions.

Problem definition

People still continue to consume packaged food products without knowing what is in them when they are purchased from market shelves. Therefore, the FoodWiki system will enable customers to use its mobile app interface as a web service to examine side effected ingredients or food additives in packaged foods that are unsuitable for various the risk groups (such as heart disease, hypertension, cholesterol, asthma, diabetes, allergies, alzheimer etc.). Food Matters Co2 presented a list of the top food additives to avoid in their research which is titled as “Receive Free Tips on Nutrition & Natural RemediesFootnote 5” (depicted in Table 1).

Table 1 Food Matters Co mentioned a list of the top food additives to avoid

FoodWiki system is designed based on semantic search, match, and inference techniques to examine the side effects of food additives according to types of diseases. The consumers get a result information page on FoodWiki mobile app for a queried food product that contains a detailed information about nutrients list, fat details, food additive list, and side effects of the food additives for the product according to the consumer’s disease profile in keeping with a food wiki. User interfaces of the mobile app are designed for ease of use, and they provide to user needs, working in online or offline modes, for use anywhere, anytime.

  • First of all, the FoodWiki mobile application provides login of a member consumer who can query to get suitable food consumption recommendations about an examined packaged food product on the market shelves (Step 1, Fig. 1).

    Fig. 1
    figure 1

    System working mechanism

  • Then, the system requires to scan the QR code or barcode number of the product. In this step, the system gets the diseases data of the consumer and also entire nutritional /ingredients information of the selected product from the database according to its unique EAN/barcode number (Step 2, Fig. 1).

  • Then, the system transfers the extracted information from database to knowledge bases to run available appropriate rules of the his/her disease in the Rule knowledge base that are modeled and separated according to types of diseases (Step 3, Fig. 1).

  • In the Step 4, the system runs on its ontology knowledge bases to retrieve nutritional information of the selected product and available side effects of the product’s nutrients according to the consumer’s disease.

  • Then, the system starts to match the concepts of the nutrients in the selected product (in Food knowledge base) with the concepts of the side effected nutrients for the customer’s disease in system knowledge base (in Human knowledge base) via a Concept Matching Engine (CME) at Step 5 in Fig. 1. In order to perform this matching task, the system needs to use semantic-based matching through the concepts and relationships defined in the knowledge bases. The semantic matching task on the retrieved concepts from knowledge bases is performed through the CME algorithm (Step 5, Fig. 1). The algorithm of CME contains a set of mathematical formulas to calculate an unsuitability score by comparing the ingredient list concepts (in product) with sensivity list concepts of the consumer (according to his/her disease). The details of CME is not given here since it was already discussed in our earlier studies of the system’s design [9, 10]. Briefly, the system has two lists as inputs to the CME to perform concept matching at Step 5:

    • Consumer Intolerance List: the list of terms (concepts) for side effects of nutrients according to a consumer’s disease type (i.e. food additives, ingredients, food items, etc.) and,

    • Selected Product Ingredients List: the list of terms (concepts) for food additives, ingredients, or nutrients of the selected product.

At the end of Step 5, the CME generates another list as an output list that is called a Semantically Enhanced Consumer Intolerance List. The reason for using ontologies is that while food companies label their products, they do not use standard concepts for ingredients and namely may use e-codex, abbreviations, or synonyms of the ingredient concepts during the labeling process. In addition, there are many alternative concepts that are used for food ingredients or chemical concepts on food product labels. For example, l-ascorbic acid, Vitamin C, ascorbate, Ascoltin, L(+)-Ascorbic acid, Ascorbicap, Hybrin, Cevitamic acid, and L-Ascorbate are also known as ascorbic acid. Therefore, the CME step collects all related unsuitable ingredients/nutritions concepts with synonyms from knowledge bases to enhance the list of unsuitability ingredients/nutritions for the customer.

  • After generating the enhanced concepts list by CME at Step 5, the system then starts to run its inferencing step that takes the side effected nutrient concepts (unsuitable nutrients) of the enhanced list as an input. Thus, the inferencing engine is initiated to run available fitting rules in the Rule knowledge base according to the consumer’s disease by considering the unsuitable concepts in the enhanced list (Step 6, Fig. 1). After inferencing step is completed, the mobile app of the system displays a result page that contains: the side effect information about each nutrients / food additives, energy values, product category, shelf life/expiration date etc. The details and defined rules of the inference mechanism are discussed in Fifth section.

Case studies

The aim of this study was to identify and match food additives on food packaging in order to observe sensitivity of consumers. Therefore, this section discusses two case studies of two different consumers who are striving to select food safe for their own consumption while shopping for food products on the shelves of a big market.

For this purpose, a market shopping consumer uses the proposed system’s mobile application. The customer could also use the system via kiosks (in the big markets) or any smart device such as phones, iPad, etc. After the login task, the system will need to scan the QR code/barcode of a food product that is tagged on the product packaging.

The QR code contains an EAN number of the food product. Then, the system will get all the ingredient lists and energy details of the scanned product via its EAN number from database. Querying the database, the system connects to the food search Web services of the Republic of Turkey Ministry of Food Agriculture and LivestockFootnote 6. The system starts to search for side effects of food additives and energy details according to the consumer’s health condition (such as food allergy, heart disease, asthma, hypertension, cholesterol, diabetes, etc.) through the rule set of the knowledge base. After that, the system will return found intolerance reasons through the rules after CME matching according to the food nutrients sensitivity of the customer.

  • In first scenario, Ms. Celik, who has Asthma disease, logs into the application system while she is shopping in a supermarket.

  • She has a smart phone that is able to connect to the FoodWiki mobile application. She connects to the system via her username and password (Fig. 2a).

    Fig. 2
    figure 2

    The customer member who has asthma disease and chooses various products and gets the results on the android mobile application of the system though knowledge base

  • If the consumer has not registered before, then she can create a new user account for herself (Fig. 2b). She can see the profile details as is shown in Fig. 2c.

  • She wants to check a product on the market shelves in order to buy suitable ingredients for her health condition, that is, asthma disease (Fig. 2d).

  • She then chooses a packaged food product from a shelf (e.g., the product is CHREZZA STİCK in Fig. 2e). She wants to be sure that the chosen product will not cause any side effects for her condition since she has intolerances for the asthma risk type of: Sulfur Dioxide (E220) and Sodium Sulfite (E221). Sulfur Dioxide (E220) are commonly used as a preservative in beers, dried fruit, soft drinks, wine, juices, cordials, vinegar, and potato products. Sodium Sulfite (E221) is contained by wine and dried fruit etc.

  • She scans the QR code/barcode of the product on her mobile phone (or alternatively through a market kiosk) and then the system retrieves all the nutritional/ingredients information related to the product from the database of the Ministry through its search product web services (Fig. 2f).

  • Then, the system searches the ingredients list to get the indicated concepts in the knowledge base. In addition to retrieving the nutritional concepts of commercial products, the system is able to compare them with specific nutritional concepts affecting her health (i.e., see the warning messages on screen; Fig. 2f). At this point, the system parse the indicated concepts from food knowledge base for each ingredients item in the ingredients list of the chosen product. After all, the concept based matching task is performed on two list; unsuitable ingredients list of the consumer for the disease type and the nutritional/ingredients concepts of the chosen product from market shelves instantly.

  • Then, the system presents three different colors as a result to the consumer: red, green, and yellow. The system also shows a result message explaining reasons of each ingredients for the suitability of the product for the customer (i.e., the system explains why the result is Green, Yellow or Red). In addition, the system shows general information about each ingredient in the product list, such as amount of nutrients, additives/compounds information, energy information, and the recommended daily intake.

  • The green light indicates “the product is safe” for the consumer while the red light is an “objectionable food product”’ (the red is indicated if the system finds at least one common ingredient that is defined as having an exact relationship between the consumer intolerance list and product ingredient list; Fig. 2g).

  • In addition, the yellow light indicates a possible issue, so the consumer should seek professional medical advice before consuming that product (the yellow is considered if the system does not find any exact relationship between the consumer intolerance list and the product ingredient list that involves side effects from ingredients).

  • If the consumer want to update her profile, then she can do it via the update window (Fig. 2h).

  • Figure 2g shows that the customer has tried various different products and has gotten some suitable product lights (Result is Green) or some unsuitable product lights (Result is Red) in the history window of the application.

  • According to second scenario, Mr. Taymaz, has Diabetes disease, who also logs into the application system as Ms. Celik while he is shopping in a supermarket. He has a smart phone that is able to connect to the FoodWiki mobile application. Similarly, he connects to the system via his username and password (Fig. 3a).

    Fig. 3
    figure 3

    The customer member who has diabetes disease and chooses various products and gets the results on the android mobile application of the system though knowledge base

  • If the consumer has not registered before, then he can create a new user account for himself (Fig. 3b).

  • He also can see the profile details as is shown in Fig. 3c.

  • He wants to check a product on the market shelves in order to buy suitable ingredients for his health risks, that is, Diabetes disease (Fig. 3d).

  • He then chooses a packaged food product from a shelf (e.g., the product is COCO STAR in Fig. 3e).

  • He wants to be sure that the chosen product will not cause any side effects for his condition since he has intolerances for the Diabetes risk type of: Artificial Sweeteners (Aspartame, E951), High Fructose Corn Syrup (HFCS), and Trans Fat etc. Artificial Sweeteners (Aspartame, E951) are commonly used in “diet” or “sugar free” products such as diet coke, coke zero, jell, desserts, sugar free gum, drink mixes, table top sweeteners, cereal, breath-mints, puddings, Kool-Aid, ice tea, chewable vitamins, toothpaste, cough syrup etc. High Fructose Corn Syrup (HFCS) is contained by most processed foods, breads, candy, flavored yogurts, salad dressings, canned vegetables, cereals etc. Trans Fat is contained by partially hydrogenated vegetable oils.

  • To get available side effected information for each ingredients, he scans the QR code/barcode of the chosen product on his mobile phone (or alternatively through a market kiosk) and then the system retrieves all the nutritional/ingredients information related to the product from the database of the Ministry through its search web services (Fig. 3f).

  • Figure 3g shows that the customer has tried various different products and has gotten some suitable product lights (Result is Green) or some unsuitable product lights (Result is Red) in the history window of the application.

Finally, the system presents three different colors as a result to the consumer: red, green, and yellow for each ingredients item. The user may click on each and then retrieve the available side effected reasons of each ingredients according to his/her disease.

FoodWiki knowledge base

FoodWiki knowledge base involves four main classes: Person, Disease, Product, and Food Ingredients/Compounds. The person and disease sections have similar contents that describe the general properties of individuals and some nutrition-related human diseases. Initially, the disease section was contain only some well-known intolerances/allergies that are commonly seen in people; lactose, fish, gluten, and egg allergies.

However, the latest extended version of the diseases part of the FoodWiki knowledge base includes unsuitable nutritions/ingredients for other common diseases such as asthma, an initial portion of the heart disease and diabetes. The final knowledge base contains four main classes, 58 subclasses, 17 object type properties and 19 sub-object type properties, 13 data type properties, almost 1600 individuals with annotation type properties and almost 250 semantic rules (Fig. 4). Knowledge base starts with a “Thing” class that contains four main classes: “Diseases”, “Person”, “Ingredients”, and “Product”. The classes contain many subclasses, properties, and individuals that are presented in Table 2.

Fig. 4
figure 4

A small portion of the FoodWiki knowledge base on the Protégé ontology editor [11]

Table 2 Initial section of the FoodWiki knowledge base

The Food Ingredients/Compounds class contains many food domain-related concepts, such as Antioxidants, Acidity Regulators, Food Concepts, and Food Additives etc., where each part of the ontology contains food domain-based concepts, properties, and relationships.

Another class of the knowledge base is the Product class that contains an abstract model of different types of foods, containing nutritional information for foods including the types and amount of nutrients, additives/compounds information, energy information, and the recommended daily intake.

Some of the classes, subclasses, and the individual entries of the knowledge base are depicted in Ontograph (Fig. 5); they were created using the Protégé ontology editor [11]. In addition, the ontological structure of the knowledge base, or in another words its semantic rule set, was created with Protégé using SWRLFootnote 7 (Semantic Web Rule Language) [12].

Fig. 5
figure 5

Onto graph representation of the FoodWiki knowledge base on the Protégé ontology editor

Figure 5 depicts a portion of the knowledge base in an Ontograph that contains almost 1600 semantic declarations about compounds and food additives in the food domain, such as “Acidity_Regulator”, “Anticaking_Agent”, “Auxiliary_Components”, “Codex Numbers”, “Antioxidant”, “Calories”, or “Food_Additives”. The “Food_Additives” section contains also various subclasses, such as “Anticaking_Agent”, “Antifoaming_Agent”, or “Antioxidant”. The ontology also contains properties such as “hasAdditives”, “hasAminoAcid”, “hasCalorie”, “hasAbbreviation”, “hasSynonym”, and others in the food domain. The semantic food contexts are described in knowledge base by using OWL 2.0 semantic tags such as <owl:class>, <rdfs:subClassOf>, <owl:DatatypeProperty>, <owl:ObjectProperty>, and so forth. As a result, knowledge base contains related concepts, properties, and annotations of food knowledge, such as food products, diseases, person profiles, nutrients, food additives, and energy information, formatted in a semantic way. The implementation of the required data parsing from knowledge base and running rules on the knowledge base of the system in pseudo code format are discussed in the Sixth section. In addition, next section discusses the generated rule knowledge base of the system according to diseases.

Inferencing mechanism via Semantic Web rule Language (SWRL) of the FoodWiki for diseases

Beyond the above mentioned contributions of the knowledge base in previous section, such semantic assertions are also used to infer meaningful and related information from the pre-asserted data of food products. That is done through an inference engine which is able to make an appropriate suggestion of a food given a specific health risk of a consumer. In addition, Semantic Web Rule Language (SWRL) [12] is an expressive OWL-based rule language that provides more powerful deductive reasoning capabilities than OWL alone. SWRL includes a high-level abstract syntax for Horn-like rules in both the OWL DL and OWL Lite sublanguages of OWL. SWRL rules are expressed referring to OWL concepts such as classes, properties, and individuals. The developed SWRL rules are saved as part of the ontology and evaluated the scalability of the generated SWRL rules inference framework with off-the shelf OWL 2 reasoners: HermiT [14], Pellet [13, 15], and FaCT++ [16].

Rules expressed in SWRL contain an antecedent (body) with conjunctions and the implied consequent (head) after the arrow ⇒. They can be read as “if-then” statements. The rule “A (? x) ∧ B (? x) ⇒ C (? x)” can accordingly be read as “if x is A and x is B then x is also C ”. Both the body and head consist of positive conjunctions of atoms such as atom ^ atom .... → atom ^ atom. An atom is an expression of the form that contains a predicate symbol, such as P, and also some parameters such as par1, par2, …, parn. The predicate symbol P can represent OWL classes, object properties, or data type properties. P may contain some parameters that can be OWL individuals or data values, or variables referring to them in the expression: P(par1, par2, …, parn), such as hasCalories(? p, ? calor greaterThan(? cal250), where ‘?p’ is a variable parameter used instead of an product of the ‘Product’ class. The term ‘?cal’ is a variable parameter that is used to hold the calorie information of a product. The greaterThan predicate takes also two parameters: the first parameter ‘?cal’ holds a value that is ‘250’ as the second parameter in the example given above.

The rules in the FoodWiki system are semantically defined by using SWRL for both the English and Turkish languages. The SWRL rule declarations are applied to predefined criteria to find food sensivity of a person according to the food additives, food items, e-codex, etc. in the chosen product. Therefore, the rule declarations are modeled in the form of SWRL, and the system uses its own predefined rules to find unsuitable food additive items in the selected food product on the market shelves.

The current knowledge base contains four main classes, 58 subclasses, 17 object type properties and 19 sub-object type properties, 13 data type properties, almost 1600 individuals with annotation type properties and almost 250 semantic rules (Fig. 6). Some of the rules are presented in Fig. 6. The rules consider almost seven type of diseases through OWL object or data type properties: Asthma, Heart Disease (few rules, not completed), Diabetes (few rules, not completed), Lactose Intolerance, Gluten Allergy, Fish Allergy, and Egg Allergy. Known side effects of some ingredients for Asthma and Diabetes diseases are discussed as case studies in the Section 3.

Fig. 6
figure 6

SWRL rule set of the system

In Third section, Fig. 2 is discussed a consumer who has Asthma disease and chooses a product from a market shelve which involves an unsuitable food additive that is Monosodium_Glutamate. The SWRL rule presents the case study in below and inference engine of the system finds “Monosodium_Glutamate” and its related concepts (such as synonym, abbreviation) are an unsuitable item for the consumer TC03 (Fig. 7).

Fig. 7
figure 7

Pellet [13, 15] in Protégé [11] analyses a sample person (i.e. TC03) on knowledge base that retrieves a new fact that is “has_Product_Risky_Color_Red” object property (right corner) as a “Monosodium_Glutamate” for “TC03”

Consumer(?p), Has_Diseases(?p, Asthma), Has_Ean_No(?p, ?u), Has_Product_Additives_Name(?u, ?fa), Has_Synonym(?fa, E621), Has_Abbreviation(?fa, “MSG”), equal(?fa, “Monosodium_Glutamate”) -> Has_Product_Risky_Color_Red(?p, Monosodium_Glutamate)

  • The meaning of the above rule is:

  • If the consumer ‘p’ has disease and also,

  • If the disease is ‘Asthma’ and also,

  • If the consumer ‘p’ chooses the product ‘u’ and also,

  • If the ‘u’ has a food additive ‘fa’ and also,

  • If the ‘fa’ is equal to ‘Monosodium_Glutamate’ and also,

  • If the ‘fa’ has synonym that is E621 and also,

  • If the ‘fa’ has abbreviation ‘MSG’ then (→),

  • The consumer ‘p’ has ‘has_Product_Risky_Color_Red’ as a new property assigned because of the ‘Monosodium_Glutamate’ or E621 or ‘MSG’ food additive.

‘Monosodium_Glutamate’ concept in food knowledge base has a synonym (exact) relation, such as E621, and also has an abbreviation such as MSG. Moreover, the matching task of CME will be able to define if the product involves one of these concepts (Monosodium Glutamate, E621, or MSG that have a relation (such as Is_a, Synonym or Abbreviation etc.) with the food additive ‘Monosodium_Glutamate’ concept of the person when running the rule beforehand. The OWL form of the rule is given in Table 3.

Table 3 A sample SWRL syntax in the knowledge base to infer inappropriateness ‘Monosodium_Glutamate’ for an Asthma patient (ontology form of the rule in Fig. 6 or Fig. 7)

The java implementation of the inferring mechanism over Web services of the system that runs the SWRL rules through Java Pellet reasoner is discussed in the next section.

JAVA implementation of the running SWRL rules through Pellet API

Web services of the system return the informatics of unsuitable additives in a chosen product via the mobile app of the system. Thus, the mobile app presents to the consumer a detailed information page about found unsuitable additives as wiki for the chosen product before consuming of the food product.

Algorithm 1. Inferring has_Product_Risky_Color_Red object property (for the person TC03) according to the SWRL rule in Fig. 6.

1    import com.clarkparsia.pellet.owlapiv3.*; // pellet reasoner library

2  import org.semanticweb.owlapi.apibinding.*; // owl api library

3    import org.semanticweb.owlapi.io.*;

4   import org.semanticweb.owlapi.model.*;

5    public static final File localLocation_IRI = new File("../Food Knowledge base.owl"); //physcial add of

6    Ont

7    public static final IRI Ont_Base_IRI = IRI.create("http://…/Food Knowledge base"); //base add of Ont

8    OWLOntologyManager m = OWLManager.createOWLOntologyManager(); // create a manager

9    OWLDataFactory f = OWLManager.getOWLDataFactory();// create a factory to produce ontology

10    elements

11    OWLOntology o = null; // create an emptly ontology

12

     public List runSWRLRule (String id, String OTP) { //get inference result of an SWRL rule after running

13    List<String> list = new ArrayList<String>();

14    try {

15 o = m.loadOntologyFromOntologyDocument(localLocation_IRI); // the manager object

16    connects to the ontology object

17PelletReasoner r = PelletReasonerFactory.getInstance().createReasoner(o); //define a

18    pellet reasoner for the predefined ontology object o

19    OWLNamedIndividual individual = f.getOWLNamedIndividual (IRI.create

20(Ont_Base_IRI + "#" + id)); // an individual object is created through ontology fabric f

21    OWLObjectProperty op = f.getOWLObjectProperty(IRI.create(Ont_Base_IRI + "#" +

22    OTP)); // an object property object is created through ontology fabric f

23  NodeSet<OWLNamedIndividual> value = r.getObjectPropertyValues(individual, op);

24    // remove unneccecary parts from the returned url strings of the returned SWRL rules for a

25    specific indiviudual

26    for (OWLNamedIndividual nmindividuals : value.getFlattened()) {

27String str = nmindividuals.toString();

28    str = StringRemoval(str); //Remove str IRI prefix

29   if (str != null) {

30    list.add(str);

31    }

32   }

33    m.removeOntology(o);

34    } catch (Exception e) {

35    System.out.println("Could not create ontology: " + e.getMessage());

36    }

37    System.out.println(list);

         return list;

38    }

39    public static void main(String[] args) {

40    OntologyFunctions obj = new OntologyFunctions();

41    List<String> list= obj. runSWRLRule ("TC03", “has_Product_Risky_Color_Red”);

     System.out.println("list"); }

In developing the knowledge base, Protégé 4.3Footnote 8 with OWL 2 0 support is preferred. JavaFootnote 9 programming language is used in the functional architecture of the system; parsing over the knowledge base is through Java-based Ontology Parser OWL API [17]. The Pellet OWL reasoner supports reasoning with SWRL rules. Pellet interprets SWRL using the DL-Safe Rules notion, which means rules will be applied only to the named individuals in the ontology. The SWRL rules are applied to infer the colored results to identify appropriate food products for individuals (consumers). In addition, Java PELLET APIFootnote 10 is an open source OWL DL reasoner that is used in programming to develop the inference mechanism via predefined SWRL rules in the knowledge base via the Java environment. Used algorithms of the methodology base for the semantic matchmaking studies of the system were already discussed in [10]. Based on these methods, the concepts related to a consumer’s sensitive food nutrients information are matched with the concepts of the scanned or queried food product through knowledge base of the system, and then the returned result is provided as a suggested consuming decision to the consumer. It identifies potential side effects to the consumer as a report on the product’s appropriateness before a consuming decision is made.

While developing inference mechanism, the Pellet reasoner is used to obtain the associations among the class and property assertions of a consumer (i.e. TC03 in Fig. 7) from system knowledge base and the predefined SWRL rules for finding unsuitable food additives purpose to perform inferencing task. The Fig. 7 depicts two predefined facts that were already asserted properties before; Has_Diseases and Has_Ean_No. After executing the Pellet reasoner, then the system retrieves a new fact that is has_Product_Risky_Color_Red object property (highlighted in a red rectangle in Fig. 7) as a Monosodium_Glutamate for the person TC03. The defined rule for the Monosodium_Glutamate according to Asthma risk is depicted in both Figs. 6 and 7 (highlighted in a red rectangle).

Algorithm 1 is designed to bring the inferred result through this SWRL rule (in Fig. 7) according to the system knowledge base. Once algorithm is implemented it brings the individuals of the OWL class ‘Person’ to a list (OWLNamedIndividual individual, line 19). Also, the has_Product_Risky_Color_Red object property (OWLObjectProperty op, line 20) are assigned to each individual of the entire person class. As can be seen from the code for the algorithm, it starts with getting information of OWL class person and assigns it’s all members to a list (individual) in a loop between lines 23 to 29.

Conclusion

The article presents a research project on mobile safe food consumption system (FoodWiki) is discussed that performs its own inferencing rules in its own knowledge base. Currently, the developed rules examines the side effects that are causing some health risks: heart disease, diabetes, allergy, and asthma as initial. Briefly working mechanism, case studies, its knowledge bases, and the design steps of the FoodWiki are discussed here. The system is especially developed for examining available ingredients on the labels of the packaged food products on market shelves and then presents appropriateness of each ingredients of the chosen products to food consumers according to their health conditions or intolerances. The Ingredients/Compounds involve nutritional information about commercial products from the food field and chemical perspective. The system used its own ontology is used to share knowledge among mobile smart devices of food consumers and the product database of the Republic of Turkey Ministry of Food, Agriculture and LivestockFootnote 11 via ontology parser Web services. Currently, we address only the design of the food consumption suggestion system in terms of provision of nutritional advice to market consumers according to their food intolerances or health conditions. To present the final stage of the system, we presented two food consuming scenarios that discusses Asthma and Diabetes diseases and choice of food products on the market shelves and demonstrates use of the android mobile application of the system. The application is developed for various platforms such as mobile applications of IOS, Android, and Windows that are currently in the testing stage.