Public APIs ‐ predict - openefsa/foodex2-sca-backend GitHub Wiki

European Food Safety Authority

This API allows to obtain FoodEx2 code suggestion(s).

Request type:

  • GET
  • Content-type: application/json

Parameters

  • desc: description of the food to be coded
  • thld: minimum accuracy (float value between [0.01,99.99]) required for each predicted term
  • smartAcc (optional): if enabled, increases/decreases the final accuracy according to the text similarity between the given description and the predicted term name. By default this function is disabled
  • model (optional): allows to specify a model to query. If no model is specified all them will be used. The available models are:
    • BT : base term model
    • CAT: facet categories model
    • Fxy: facets in category (x between [0,3] - y between [1,9])
  • lang: language used for describing a particular food (if non-English language is chosen the tool will automatically translate it to English).
Example Response
https://efsa-ai-prototypes.westeurope.cloudapp.azure.com/
foodexwebcomponentbackend/
predict?
desc=yogurt%20con%20fragole
&thld=50
&lang=it
&model=BT
{
    "desc": {
        "orig": "yogurt con fragole",
        "trsl": "yogurt with strawberries"
    },
    "BT": [{
            "termCode": "A02NH",
            "termExtendedName": "Yoghurt, cow milk, flavoured",
            "termScopeNote": "The group includes any...",
            "deprecated": 0,
            "allFacets": "A02NH#F02.A0BZ2$F27.A04HG$F28.A0CQZ",
            "detailLevel": "E",
            "termType": "d",
            "acc": 0.5931562781333923
        }
    ]
}
https://efsa-ai-prototypes.westeurope.cloudapp.azure.com/
foodexwebcomponentbackend/
predict?
desc=yogurt%20con%20fragole
&thld=20
&lang=it
&smartAcc=true
{
    "desc": {
        "orig": "yogurt con fragole", 
        "trsl": "yogurt with strawberries"
    }, 
    "bt": [
        {
            "termCode": "A02NE", 
            "termExtendedName": "Yoghurt", 
            "termScopeNote": "The group includes any ...", 
            "deprecated": 0, 
            "allFacets": "A02NE#F02.A0BZ2$F27.A02LT$F28.A0CQZ", 
            "detailLevel": "P", 
            "termType": "d", 
            "acc": 0.5751506465673446
        }, 
        {
            "termCode": "A02NH", 
            "termExtendedName": "Yoghurt, cow milk, flavoured", 
            "termScopeNote": "The group includes any ...", 
            "deprecated": 0, 
            "allFacets": "A02NH#F02.A0BZ2$F27.A04HG$F28.A0CQZ", 
            "detailLevel": "E", 
            "termType": "d", 
            "acc": 0.5465781390666962
        }
    ], 
    "cat": [
        {
            "code": "F04", 
            "name": "ingred", 
            "label": "Ingredient", 
            "scopeNote": "This facet collects ...", 
            "attributeReportable": "O", 
            "attributeSingleOrRepeatable": "repeatable", 
            "deprecated": 0, 
            "acc": 0.6509895920753479, 
            "facets": [
                {
                    "termCode": "A01EA", 
                    "termExtendedName": "Strawberries", 
                    "termScopeNote": "Berries or small ...", 
                    "deprecated": 0, 
                    "allFacets": "A01EA#F01.A05YV$F02.A0ELC$F27.A01EA", 
                    "detailLevel": "E", 
                    "termType": "r", 
                    "acc": 0.7061246931552887
                }
            ]
        }
    ]
}

Next

Previous

⚠️ **GitHub.com Fallback** ⚠️