Skip to content

feat: add OCR regex to detect Nutri-Score v2 through Nouveau calcul text#1878

Open
adiprathapa wants to merge 1 commit intoopenfoodfacts:mainfrom
adiprathapa:feat/nutri-score-v2-ocr-regex
Open

feat: add OCR regex to detect Nutri-Score v2 through Nouveau calcul text#1878
adiprathapa wants to merge 1 commit intoopenfoodfacts:mainfrom
adiprathapa:feat/nutri-score-v2-ocr-regex

Conversation

@adiprathapa
Copy link
Copy Markdown

Summary

This PR adds a new OCR based regex predictor to differentiate between the old and new Nutri-Score (v2) logos. Right now the visual similarity causes some false positives, so I implemented a text matching layer that looks for Nouveau calcul and its translations.

Main Changes

  • More language support: Added regex patterns for 11 languages (FR, EN, DE, ES, IT, NL, PT, DA, FI, HR, BG), pulling from the Open Food Facts labels taxonomy.
  • Tagging: I used en:nutriscore-v2 for now. I noticed the taxonomy has specific tags like en:nutriscore-grade-a-new-calculation, but because this is a general detection for the version of the algorithm, a generic v2 tag is what I went with. Please lmk any suggestions on the naming convention.

Should Fix #1346

Test Plan

I expanded the suite with 15 new test cases to verify correct detection across all 11 languages, case insensitivity, compatibility with existing en:nutriscore detection to make sure it isn't breaking current logic. All 24 label tests are passing locally.

@adiprathapa adiprathapa requested a review from a team as a code owner March 20, 2026 19:07
@adiprathapa adiprathapa changed the title add OCR regex to detect Nutri-Score v2 through Nouveau calcul text feat: add OCR regex to detect Nutri-Score v2 through Nouveau calcul text Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

Add a special regex to detect the new Nutri-Score

1 participant