Skip to content

Commit

Permalink
chore: Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Raphaël Bournhonesque <[email protected]>
  • Loading branch information
alexgarel and raphael0202 authored Oct 18, 2024
1 parent dead58b commit 792d848
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions app/_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ def perform_taxonomy_import(config: IndexConfig) -> None:


def perform_cleanup_indexes(config: IndexConfig) -> int:
"""Delete old indexes (that have no active alias on them)"""
"""Delete old indexes (that have no active alias on them)."""
removed = 0
# some timeout for it can be long
es_client = connection.get_es_client(request_timeout=600)
Expand All @@ -579,7 +579,7 @@ def perform_cleanup_indexes(config: IndexConfig) -> int:


def perform_refresh_synonyms(index_id: str, config: IndexConfig) -> None:
"""Refresh synonyms files generated by taxonomies"""
"""Refresh synonyms files generated by taxonomies."""
refresh_synonyms(index_id, config, settings.synonyms_path)


Expand Down
3 changes: 2 additions & 1 deletion app/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def generate_dsl_field(
:param field: the field to use as input
:param supported_langs: an iterable of languages (2-letter codes),
used to know which sub-fields to create for `text_lang` field types
used to know which sub-fields to create for `text_lang`
and `taxonomy` field types
:return: the elasticsearch_dsl field
"""
if field.type is FieldType.taxonomy:
Expand Down
2 changes: 1 addition & 1 deletion app/openfoodfacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def process_after(self, result: JSONType) -> JSONType:

@staticmethod
def build_image_fields(product: JSONType):
"""Images are stored in a weird way in OpenFoodFacts,
"""Images are stored in a weird way in Open Food Facts,
We want to make it far more simple to use in results.
"""
# Python copy of the code from
Expand Down
2 changes: 1 addition & 1 deletion app/postprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def process(self, response: Response, projection: set[str] | None) -> JSONType:
# Flatten the language dict
lang_values = result.pop(fname)
for lang, text in lang_values.items():
# FIXME: this reproduce OFF behaviour, but is this a good thing ?
# FIXME: this reproduces OFF behaviour, but is this a good thing?
suffix = "" if lang == "main" else f"_{lang}"
result[f"{fname}{suffix}"] = text

Expand Down
10 changes: 5 additions & 5 deletions docs/users/explain-taxonomies.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

Taxonomies are a way to organize categorization of items.

Normally a taxonomy is about a specific field.
For each possible values, it defines translations in different languages, and also possible synonyms (in each languages).
Normally, a taxonomy is about a specific field.
For each possible values, it defines translations in different languages, and also possible synonyms (in each language).
For each entry we have a canonical identifier.

A taxonomy also organize the entries within a direct acyclic graph (a hierarchy but with possibility of multiple parents, though always avoiding cycles).
A taxonomy also organizes the entries within a direct acyclic graph (a hierarchy but with possibility of multiple parents, though always avoiding cycles).
For example it may help describe that a salmon is a marine fish as well as a freshwater fish, and a oily fish.

It can be used to help users find items using a specific field, in their language, even if they use a synonym for it.
Expand All @@ -17,7 +17,7 @@ If you plan to use taxonomies, you should first list them, in the [taxonomy sect

Taxonomies must come in a JSON format, that can be downloaded at a particular URL.

The data in the JSON must contains an object, where:
The data in the JSON must contain an object, where:
* each key correspond to the id of the taxonomy entries
* the value is an Object, with the following fields (none are mandatory):
* `name`: an Object associating language code,
Expand All @@ -30,7 +30,7 @@ The data in the JSON must contains an object, where:
As you define your [fields in the configuration](./explain-configuration.md#fields),
you can specify that a field is a taxonomy field (`type: taxonomy`).

In this case, you also have to provide following fields:
In this case, you also have to provide the following fields:
* taxonomy_name: the name of the taxonomy (as defined in the configuration)

* synonyms_search: if true,
Expand Down

0 comments on commit 792d848

Please sign in to comment.