image repairment in own products
This commit is contained in:
@@ -262,7 +262,7 @@
|
||||
"wikipedia_title": "Chrysanthemum"
|
||||
},
|
||||
"Clam": {
|
||||
"image_credit": "File:Am\u00eaijoas de Set\u00fabal.jpg",
|
||||
"image_credit": "File:Amêijoas de Setúbal.jpg",
|
||||
"image_note": "hand-picked: the article's lead image is a botanical plate",
|
||||
"image_source": "wikimedia_commons",
|
||||
"image_url": "https://thumb.wikimedia.org/wikipedia/commons/thumb/1/13/Am%C3%AAijoas_de_Set%C3%BAbal.jpg/960px-Am%C3%AAijoas_de_Set%C3%BAbal.jpg?utm_source=commons.wikimedia.org&utm_campaign=imageinfo&utm_content=thumbnail",
|
||||
@@ -553,9 +553,10 @@
|
||||
"wikipedia_title": "Ghee"
|
||||
},
|
||||
"Ginger": {
|
||||
"image_credit": "Ginger",
|
||||
"image_source": "wikipedia_lead",
|
||||
"image_url": "https://upload.wikimedia.org/wikipedia/commons/1/18/Koeh-146-no_text.jpg",
|
||||
"image_credit": "Fresh ginger rhizome",
|
||||
"image_note": "Wikipedia's lead image for Ginger is Koehler's Medizinal-Pflanzen plate 146 - a 19th-century botanical illustration of the whole plant, not the rhizome a shop sells. Hand-picked from Commons.",
|
||||
"image_source": "wikimedia_commons",
|
||||
"image_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/f/fb/Fresh_ginger_rhizome_01.jpg/960px-Fresh_ginger_rhizome_01.jpg",
|
||||
"usda_description": "Ginger root, raw",
|
||||
"usda_fdc_id": 169231,
|
||||
"wikipedia_title": "Ginger"
|
||||
|
||||
1590
data/brand_image_repair_backup_20260904_151415.json
Normal file
1590
data/brand_image_repair_backup_20260904_151415.json
Normal file
File diff suppressed because it is too large
Load Diff
1435
data/brand_image_repair_backup_20260904_152006.json
Normal file
1435
data/brand_image_repair_backup_20260904_152006.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -576,14 +576,36 @@ def repair(cur, conn, brands: List[str], apply: bool, timeout: int, workers: int
|
||||
# three providers were caught serving a confidently wrong image.
|
||||
# --recheck re-opens rows whose stored URL names neither the brand
|
||||
# nor any distinctive word of the product, so they are re-searched
|
||||
# under the corroboration rule rather than grandfathered in.
|
||||
# under the corroboration rule rather than grandfathered in - and,
|
||||
# for the produce bucket, any row that simply is not the reviewed
|
||||
# image (see below).
|
||||
have = {r["image_id"] for r in needs}
|
||||
for row in rows:
|
||||
if row["image_id"] in have:
|
||||
continue
|
||||
name = row.get("product_name") or ""
|
||||
|
||||
# A REVIEWED IMAGE OUTRANKS THE HEURISTIC.
|
||||
#
|
||||
# The corroboration test below asks whether the URL contains a
|
||||
# distinctive word of the product, and it cannot tell an image OF
|
||||
# the thing from an image merely NAMED after it. It passed, and so
|
||||
# grandfathered in, `Bitter_Gourd_Curry.jpg` for Bitter Gourd,
|
||||
# `Zunaid_Ahmed_Palak.jpg` - a photograph of a person - for Palak,
|
||||
# and `BANANA_CREPE_CON_BASIL_LEAVES.jpg` for Basil Leaves. That
|
||||
# left 57 rows untouched on the first full run.
|
||||
#
|
||||
# Where a person has already chosen the image, no heuristic gets a
|
||||
# vote: if the stored URL is not the curated one, it is wrong.
|
||||
if _is_own_products(suffix):
|
||||
curated = produce_reference.image_url(name)
|
||||
if curated and (row.get("image_url") or "") != curated:
|
||||
needs.append(row)
|
||||
continue
|
||||
|
||||
stored = _row_urls(row)
|
||||
if stored and not any(
|
||||
_names_product(u, row.get("product_name") or "", suffix) for u in stored
|
||||
_names_product(u, name, suffix) for u in stored
|
||||
):
|
||||
needs.append(row)
|
||||
totals["scanned"] += len(rows)
|
||||
|
||||
Reference in New Issue
Block a user