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

fix: fix flashtext #1108

Merged
merged 3 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
350 changes: 194 additions & 156 deletions poetry.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ elasticsearch = "~8.5.3"
pymongo = "~3.12.0"
spacy = "~3.4.1"
dacite = "~1.6.0"
flashtext = "~2.7"
langid = "~1.1.6"
influxdb-client = "~1.34.0"
jsonschema = "~4.4.0"
Expand Down
3 changes: 1 addition & 2 deletions robotoff/prediction/category/matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
import re
from typing import Iterable, Optional

from flashtext import KeywordProcessor

from robotoff import settings
from robotoff.products import ProductDataset
from robotoff.taxonomy import TaxonomyType, get_taxonomy
from robotoff.types import Prediction, PredictionType, ServerType
from robotoff.utils import dump_json, get_logger, load_json
from robotoff.utils.text import (
KeywordProcessor,
get_lemmatizing_nlp,
strip_accents_v1,
strip_consecutive_spaces,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
from typing import Optional

import numpy as np
from flashtext import KeywordProcessor

from robotoff import settings
from robotoff.taxonomy import Taxonomy, fetch_taxonomy
from robotoff.types import JSONType
from robotoff.utils.text import KeywordProcessor

from .text_utils import fold, get_tag

Expand Down
4 changes: 1 addition & 3 deletions robotoff/prediction/ocr/brand.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import functools
from typing import Iterable, Optional, Union

from flashtext import KeywordProcessor

from robotoff import settings
from robotoff.brands import get_brand_blacklist, keep_brand_from_taxonomy
from robotoff.types import Prediction, PredictionType
from robotoff.utils import get_logger, text_file_iter
from robotoff.utils.text import get_tag
from robotoff.utils.text import KeywordProcessor, get_tag

from .dataclass import OCRResult, get_match_bounding_box, get_text
from .utils import generate_keyword_processor
Expand Down
3 changes: 1 addition & 2 deletions robotoff/prediction/ocr/image_flag.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import functools
from typing import Optional, Union

from flashtext import KeywordProcessor

from robotoff import settings
from robotoff.types import Prediction, PredictionType
from robotoff.utils import text_file_iter
from robotoff.utils.text import KeywordProcessor

from .dataclass import OCRResult, SafeSearchAnnotationLikelihood, get_text

Expand Down
3 changes: 1 addition & 2 deletions robotoff/prediction/ocr/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
import re
from typing import Iterable, Optional, Union

from flashtext import KeywordProcessor

from robotoff import settings
from robotoff.types import Prediction, PredictionType
from robotoff.utils import get_logger, text_file_iter
from robotoff.utils.text import KeywordProcessor

from .dataclass import OCRField, OCRRegex, OCRResult, get_match_bounding_box, get_text
from .utils import generate_keyword_processor
Expand Down
4 changes: 1 addition & 3 deletions robotoff/prediction/ocr/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
from pathlib import Path
from typing import BinaryIO, Iterable, Optional, Union

from flashtext import KeywordProcessor

from robotoff import settings
from robotoff.types import Prediction, PredictionType
from robotoff.utils import get_logger
from robotoff.utils.cache import CachedStore
from robotoff.utils.text import strip_accents_v1
from robotoff.utils.text import KeywordProcessor, strip_accents_v1

from .dataclass import OCRResult

Expand Down
3 changes: 1 addition & 2 deletions robotoff/prediction/ocr/packager_code.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import re
from typing import Optional, Union

from flashtext import KeywordProcessor

from robotoff import settings
from robotoff.types import Prediction, PredictionType
from robotoff.utils import text_file_iter
from robotoff.utils.cache import CachedStore
from robotoff.utils.text import KeywordProcessor

from .dataclass import OCRField, OCRRegex, OCRResult, get_match_bounding_box, get_text
from .utils import generate_keyword_processor
Expand Down
2 changes: 1 addition & 1 deletion robotoff/prediction/ocr/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Callable, Iterable, Optional

from flashtext import KeywordProcessor
from robotoff.utils.text import KeywordProcessor


def generate_keyword_processor(
Expand Down
1 change: 1 addition & 0 deletions robotoff/utils/text.py → robotoff/utils/text/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from robotoff.utils import get_logger

from .flashtext import KeywordProcessor # noqa: F401
from .fold_to_ascii import fold, fold_without_insertion_deletion

logger = get_logger(__name__)
Expand Down
Loading