Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate and apply insights automatically based on constraints #163

Closed
raphael0202 opened this issue May 9, 2020 · 1 comment
Closed
Assignees

Comments

@raphael0202
Copy link
Collaborator

raphael0202 commented May 9, 2020

Being able to generate and add automatically information based on available product data would be very valuable.

This new information can be computed using a list of known rules, such as:

  • label MSC when MSC packager code (Add MSC or ASC as a parent when a MSC or ASC code is added #143)
  • wine category when AOC label is present (Extract AOC from images #78)
  • add carrefour store if carrefour brand is present
  • add carrefour store and en:organic label and fr:ab-agriculture-biologique label if carrefour-bio is present
  • add category frozen ships if has category en:shrimps and if label frozen is present
  • add category en:artificially-sweetened-yogurts if has ingredient:sweetener and if category en:yogurts is present
  • add category en:sugared-yogurts if has category en:yogurts and has ingredient en:sugar but doesn't have ingredient en:sweetener (yogurts with sugar in the ingredients but without sweeteners)

Each rule has a list of input conditions and an output (addition of one or more information to the product). As a first step, we can create these first input conditions:

  • hasCategory, target category value_tag as parameter
  • hasIngredient, target ingredient value_tag as parameter
  • hasNotIngredient, target ingredient value_tag as parameter
  • hasBrand, normalized brand name as parameter
  • hasLabel, target label value_tag as parameter
  • packagerCodeStartsWith, with string (pattern) as parameter

As output:

  • addCategory
  • addStore
  • addLabel

We can implement this rule engine in Robotoff. Each time a product is updated, Robotoff receives a webhook call. We can check all rules against the product, and generate insights that are automatically applied. We can store the rules in Postgres DB, to allow easy editing/collaboration.

For the rule engine, @alexgarel has suggested to use Lucene query language (see https://github.com/jurismarches/luqum), as we're going to index all data in an Elasticsearch instance. We would search for products that match each rule instead of searching for rules that match the product. Given how simple the rules are (binary AND operator only), I don't believe we need a tool as powerful as Elasticsearch for this.

Not supported yet by Robotoff but to be done:

  • add origins of ingredients en:France and labels fr:aoc if category fr:Sancerre is present
@raphael0202 raphael0202 self-assigned this May 9, 2020
@raphael0202 raphael0202 added the ✨ enhancement New feature or request label May 9, 2020
@teolemon
Copy link
Member

teolemon commented Aug 23, 2021

@github-actions github-actions bot added ⭐ top issue Top issue. ⭐ top feature Top feature request. labels Sep 20, 2022
@raphael0202 raphael0202 changed the title Generate secondary insights Generate and apply insights automatically based on constraints Sep 22, 2022
@openfoodfacts openfoodfacts locked and limited conversation to collaborators Aug 29, 2023
@raphael0202 raphael0202 converted this issue into discussion #1225 Aug 29, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Development

No branches or pull requests

2 participants