Skip to content

Commit

Permalink
fix: remove unused functions
Browse files Browse the repository at this point in the history
  • Loading branch information
raphael0202 committed Feb 28, 2023
1 parent 8632d21 commit 5b0f1ae
Showing 1 changed file with 1 addition and 35 deletions.
36 changes: 1 addition & 35 deletions robotoff/prediction/ocr/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@

import requests

from robotoff.off import generate_json_ocr_url, get_barcode_from_path, split_barcode
from robotoff.prediction.types import Prediction
from robotoff.settings import BaseURLProvider
from robotoff.types import JSONType, PredictionType
from robotoff.utils import get_logger, http_session, jsonl_iter, jsonl_iter_fp
from robotoff.utils import get_logger, jsonl_iter, jsonl_iter_fp

from .brand import find_brands
from .category import find_category
Expand Down Expand Up @@ -50,22 +48,6 @@
}


def fetch_images_for_ean(ean: str):
url = BaseURLProvider.world() + "/api/v0/product/{}.json?fields=images".format(ean)
images = http_session.get(url).json()
return images


def get_json_for_image(barcode: str, image_id: str) -> Optional[JSONType]:
url = generate_json_ocr_url(barcode, image_id)
r = http_session.get(url)

if r.status_code == 404:
return None

return r.json()


def get_ocr_result(
ocr_url: str, session: requests.Session, error_raise: bool = True
) -> Optional[OCRResult]:
Expand Down Expand Up @@ -123,22 +105,6 @@ def extract_predictions(
raise ValueError(f"unknown prediction type: {prediction_type}")


def is_barcode(text: str):
return text.isdigit()


def get_source(
image_name: str, json_path: Optional[str] = None, barcode: Optional[str] = None
) -> str:
if not barcode:
barcode = get_barcode_from_path(str(json_path))

if not barcode:
raise ValueError("invalid JSON path: {}".format(json_path))

return "/{}/{}.jpg" "".format("/".join(split_barcode(barcode)), image_name)


def ocr_content_iter(items: Iterable[JSONType]) -> Iterable[tuple[Optional[str], dict]]:
for item in items:
if "content" in item:
Expand Down

0 comments on commit 5b0f1ae

Please sign in to comment.