ProductOpener::TaxonomiesEnhancer - analyze ingredients and other fields to enrich the taxonomies
ProductOpener::TaxonomiesEnhancer
analyze analyze ingredients and other fields to enrich the taxonomies
use ProductOpener::TaxonomiesEnhancer qw/:all/; [..] check_ingredients_between_languages($product_ref);
[..]
This function recursively flattens a nested list of ingredients. If an ingredient contains sub-ingredients, they are flattened into a single-level array.
An array reference of ingredients that may contain nested sub-ingredients.
An array of flattened ingredients, each represented as a hash reference.
This function parses and flattens the ingredient list for a specific language based on the provided key.
A hash reference to the product data containing the ingredient text for various languages.
A string representing the language-specific ingredient text key (e.g., "ingredients_text_cs").
This function does not return a value but modifies the product reference to store the flattened ingredient list under a new key (e.g., "ingredients_cs").
This function checks if all or a certain percentage of ingredients in the first language (reference) overlap with ingredients in second language (to analyze).
An array reference of ingredients in the first language (reference).
An array reference of ingredients in the second language (to analyze).
Returns 1 if the overlap of ingredients between the two lists is below a certain threshold, otherwise returns 0.
This function detects missing stop words before the first known ingredient in a list of ingredients.
An array reference of ingredients in the first language (reference).
An array reference of ingredients in the second language (to analyze).
A string representing the language code for the first language.
A string representing the language code for the second language.
A hash reference to store the missing stop words before the first known ingredient.
This function does not return a value but modifies the `missing_stop_words_before` hash reference to store the missing stop words.
This function finds the index of a specific ingredient in a list of ingredients based on its ID.
An array reference of ingredients, where each ingredient is represented as a hash reference.
A string representing the ID of the ingredient to find.
Returns the index of the ingredient if found, otherwise returns -1.
This function detects missing stop words after the last known ingredient in a list of ingredients.
An array reference of ingredients in the first language (reference).
An array reference of ingredients in the second language (to analyze).
A string representing the language code for the first language.
A string representing the language code for the second language.
A hash reference to store the missing stop words after the last known ingredient.
This function does not return a value but modifies the `missing_stop_words_after` hash reference to store the missing stop words.
This function removes duplicate elements from an array.
An array of elements from which duplicates need to be removed.
Returns an array with duplicate elements removed.
This function finds the key with the smallest value in a hashmap. If multiple keys have the same smallest value, it returns the first key in alphabetical order.
A hash reference where the keys are strings and the values are numeric.
Returns the key with the smallest value. If multiple keys have the same smallest value, returns the first key in alphabetical order.
This function returns two strings in alphabetical order.
A string to be compared.
A string to be compared.
Returns a list of two strings sorted in lexicographical order.
This function detects missing ingredients and potential typos between two lists of ingredients in different languages.
An array reference of ingredients in the first language (reference).
An array reference of ingredients in the second language (to analyze).
A string representing the language code for the first language.
A string representing the language code for the second language.
A hash reference to store missing ingredients.
A hash reference to store potential typos in ingredients.
A hash reference to store mismatches in the taxonomy between the two languages.
This function does not return a value but modifies the `missing_ingredients`, `ingredients_typo`, and `mismatch_in_taxonomy` hash references to store the detected issues.
This function extracts data for each language from the provided product reference. It then detects failed extractions (missing stop words) and identifies missing translations.
A reference to the product data, which is expected to be a hash reference containing the necessary information.
This function does not return any value. It performs the extraction and detection internally.