Skip to content
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

feat: Added origin extraction #890

Closed
wants to merge 21 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c65438d
Added origin extraction
ValentinRegnault Sep 8, 2022
e07cac9
Modifications to follow Semantic PRs
ValentinRegnault Sep 8, 2022
bf7dc9f
Removed unused import, and one useless statement
ValentinRegnault Sep 10, 2022
b77360d
Update robotoff/prediction/ocr/origin.py
ValentinRegnault Sep 13, 2022
eeb2c64
Update robotoff/prediction/ocr/origin.py
ValentinRegnault Sep 13, 2022
bb64958
Update robotoff/prediction/ocr/origin.py
ValentinRegnault Sep 13, 2022
6bb5767
Origin parser put in a class, with lazy initialization + small changes
ValentinRegnault Sep 14, 2022
668d2fc
Origin parser put in a class, with lazy initialization + small changes
ValentinRegnault Sep 14, 2022
31f07e5
repair last commit :/
ValentinRegnault Sep 14, 2022
ccba94c
small tweaks
ValentinRegnault Sep 14, 2022
c142504
Delete temp.txt
ValentinRegnault Sep 24, 2022
6d0af13
Delete temp2.txt
ValentinRegnault Sep 24, 2022
cc72baf
Small tweaks suggested by raphael0202
ValentinRegnault Sep 24, 2022
335e563
Revert .env
ValentinRegnault Sep 26, 2022
ee351bb
Added origin extraction
ValentinRegnault Oct 11, 2022
9806baa
remove useless comment
ValentinRegnault Oct 11, 2022
6228811
Merge branch 'master' of https://github.com/Pykorm/robotoff
ValentinRegnault Oct 11, 2022
64bf201
Revert "Merge branch 'master' of https://github.com/Pykorm/robotoff"
ValentinRegnault Oct 11, 2022
69c685d
Revert "remove useless comment"
ValentinRegnault Oct 11, 2022
8c48f12
Revert "Added origin extraction"
ValentinRegnault Oct 11, 2022
433ae15
Merge branch 'master' into master
ValentinRegnault Oct 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Small tweaks suggested by raphael0202
ValentinRegnault committed Sep 24, 2022
commit cc72bafb8561d3e9776bd338176beaa8cfa1d6a2
6 changes: 3 additions & 3 deletions .env
Original file line number Diff line number Diff line change
@@ -8,8 +8,8 @@ PO_LOCAL_NET=po_default

# User uid - in dev align this with your own user uid / gid
# see https://gist.github.com/alexgarel/6e6158ee869d6db2192e0441fd58576e
OFF_UID=1000
OFF_GID=1000
# OFF_UID=1000
# OFF_GID=1000

# Robotoff
TAG=latest
@@ -56,4 +56,4 @@ SENTRY_DSN=
IPC_AUTHKEY=ipc
IPC_HOST=0.0.0.0
IPC_PORT=6650
WORKER_COUNT=8
WORKER_COUNT=8
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you revert to the original version for this file too?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep !

File renamed without changes.
11 changes: 4 additions & 7 deletions robotoff/prediction/ocr/origin.py
Original file line number Diff line number Diff line change
@@ -27,13 +27,13 @@ def initialize(self):
INGREDIENTS = json.load(open(settings.TAXONOMY_CATEGORY_PATH, "r"))

# French ----------------
INGREDIENTS_SYNONIMS_FR = [
INGREDIENTS_SYNONYMS_FR = [
ingredient["synonyms"]["fr"]
for ingredient in INGREDIENTS.values()
if "synonyms" in ingredient and "fr" in ingredient["synonyms"]
]
INGREDIENTS_FR = [
synonym for synonyms in INGREDIENTS_SYNONIMS_FR for synonym in synonyms
synonym for synonyms in INGREDIENTS_SYNONYMS_FR for synonym in synonyms
]
GENERAL_WORDS_FR = [
"ingredients?",
@@ -147,13 +147,13 @@ def initialize(self):

# English -----------------------

INGREDIENTS_SYNONIMS_EN = [
INGREDIENTS_SYNONYMS_EN = [
ingredient["synonyms"]["en"]
for ingredient in INGREDIENTS.values()
if "synonyms" in ingredient and "en" in ingredient["synonyms"]
]
INGREDIENTS_EN = [
synonym for synonyms in INGREDIENTS_SYNONIMS_EN for synonym in synonyms
synonym for synonyms in INGREDIENTS_SYNONYMS_EN for synonym in synonyms
] # flatten the array
GENERAL_WORDS_EN = ["ingredients?", "elements?", "composition", "production"]
INGREDIENTS_EN.extend(GENERAL_WORDS_EN)
@@ -284,9 +284,6 @@ def find_origin(self, content: Union[OCRResult, str]) -> List[Prediction]:
ingredient
)

if len(ingredients_origins) == 0:
return []

return [
Prediction(
type=PredictionType.nutrient,