Skip to content

Commit

Permalink
taxonomy-translation-enhancer first draft
Browse files Browse the repository at this point in the history
  • Loading branch information
benbenben2 committed Jan 18, 2025
1 parent 782434e commit 64e3a77
Show file tree
Hide file tree
Showing 5 changed files with 1,274 additions and 63 deletions.
3 changes: 3 additions & 0 deletions cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ requires 'Module::Load';
# To measure the time taken by requests
requires 'Time::Monotonic';

# To measure similarity between words and find possible typo
requires 'Text::Levenshtein';

on 'test' => sub {
requires 'Test2::V0';
requires 'Mock::Quick';
Expand Down
2 changes: 0 additions & 2 deletions lib/ProductOpener/FoodProducts.pm
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ use ProductOpener::FoodGroups qw/compute_food_groups/;
use ProductOpener::Nutriscore qw/:all/;
use ProductOpener::EnvironmentalScore qw/compute_environmental_score/;
use ProductOpener::ForestFootprint qw/compute_forest_footprint/;
use ProductOpener::TaxonomiesEnhancer qw/detect_taxonomy_translation_from_text/;

use Log::Any qw($log);

Expand All @@ -84,7 +83,6 @@ sub specific_processes_for_food_product ($product_ref) {
extract_ingredients_from_text($product_ref);
extract_additives_from_text($product_ref);
detect_allergens_from_text($product_ref);
detect_taxonomy_translation_from_text($product_ref);

# Category analysis
# Food category rules for sweetened/sugared beverages
Expand Down
5 changes: 5 additions & 0 deletions lib/ProductOpener/Products.pm
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ use ProductOpener::Units qw/normalize_product_quantity_and_serving_size/;
# may be moved to another module at some point
use ProductOpener::Packaging qw/analyze_and_combine_packaging_data/;
use ProductOpener::DataQuality qw/check_quality/;
use ProductOpener::TaxonomiesEnhancer qw/check_ingredients_between_languages/;

# Specific to the product type
use ProductOpener::FoodProducts qw/specific_processes_for_food_product/;
Expand Down Expand Up @@ -3692,6 +3693,10 @@ sub analyze_and_enrich_product_data ($product_ref, $response_ref) {

ProductOpener::DataQuality::check_quality($product_ref);

if (defined $taxonomy_fields{'ingredients'}) {
check_ingredients_between_languages($product_ref);
}

# Sort misc_tags in order to have a consistent order
if (defined $product_ref->{misc_tags}) {
$product_ref->{misc_tags} = [sort @{$product_ref->{misc_tags}}];
Expand Down
Loading

0 comments on commit 64e3a77

Please sign in to comment.