-
-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: improve ingredients extraction (#8942)
- Loading branch information
1 parent
bacf2a7
commit ddd8177
Showing
6 changed files
with
67 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/perl -w | ||
|
||
# Tests of Ingredients::preparse_ingredients_text() | ||
|
||
use Modern::Perl '2017'; | ||
use utf8; | ||
|
||
use Test::More; | ||
use Log::Any::Adapter 'TAP'; | ||
|
||
use ProductOpener::Products qw/:all/; | ||
use ProductOpener::Tags qw/:all/; | ||
use ProductOpener::TagsEntries qw/:all/; | ||
use ProductOpener::Ingredients qw/:all/; | ||
|
||
my @lists = ( | ||
# en phrases_after_ingredients_list | ||
[ | ||
"en", | ||
"carrots, green peas, corn, scallion. *adds a trivial amount of added sugars per serving.", | ||
"carrots, green peas, corn, scallion.", | ||
], | ||
# en ignore_phrases, | ||
[ | ||
"en", | ||
"Egg White, Xanthan Gum (not applicable), Salt, Glucono-delta-lactone.", | ||
"Egg White, Xanthan Gum, Salt, Glucono-delta-lactone.", | ||
], | ||
); | ||
|
||
foreach my $test_ref (@lists) { | ||
my $lc = $test_ref->[0]; # Language | ||
my $ingredients_text_from_image = $test_ref->[1]; | ||
my $cut_ingredients_text_from_image = cut_ingredients_text_for_lang($ingredients_text_from_image, $lc); | ||
print STDERR "input from the picture extraction (ingredients list ($lc)): $ingredients_text_from_image\n"; | ||
print STDERR "cut_ingredients_text_from_image (result from sub routine): $cut_ingredients_text_from_image\n"; | ||
my $expected = $test_ref->[2]; | ||
is(lc($cut_ingredients_text_from_image), lc($expected)) | ||
or print STDERR "Original ingredients: $ingredients_text_from_image ($lc)\n"; | ||
} | ||
|
||
done_testing(); |