Skip to content

Commit

Permalink
Attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
goulven authored and goulven committed Dec 10, 2024
1 parent a1ddc9a commit 8fa9722
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public void updateVerticalWithMappings(
public void updateVerticalWithAttributes(
@RequestParam (defaultValue = "tv") String vertical,
@RequestParam (defaultValue = "10") Integer minCoverage,
@RequestParam String containing
@RequestParam (defaultValue = "") String containing
) throws ResourceNotFoundException, IOException {

//TODO(p2,conf) : from conf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,35 +94,40 @@ public void onProduct(Product data, VerticalConfig vConf) throws AggregationSkip
// A hard filtering on datasource categories, that must at least contains one of the
// vertical natural names
////////////////////////////////////

// Building offer name bags
StringBuilder productNameBag = new StringBuilder();
data.getOfferNames().forEach(name -> {
productNameBag.append(StringUtils.stripAccents(name).toLowerCase());
});
String pNames = productNameBag.toString();
if (null != data.getVertical()) {

// Building offer name bags
StringBuilder productNameBag = new StringBuilder();
data.getOfferNames().forEach(name -> {
productNameBag.append(StringUtils.stripAccents(name).toLowerCase());
});
String pNames = productNameBag.toString();

try {
try {

if (null != vConf.getId() && null != data.getVertical()) {
if (null != vConf.getId()) {

Set<String> verticalNames = vConf.getTokenNames(taxonomyService.byId(vConf.getGoogleTaxonomyId()).getGoogleNames().values().stream().map(e -> StringUtils.stripAccents(e.toLowerCase())).toList());
Set<String> verticalNames = vConf.getTokenNames(taxonomyService.byId(vConf.getGoogleTaxonomyId()).getGoogleNames().values().stream().map(e -> StringUtils.stripAccents(e.toLowerCase())).toList());

for (String term : verticalNames) {
for (String term : verticalNames) {

if (pNames.contains(term)) {
dedicatedLogger.info("Vertical {} confirmed by product names match for {}", vConf, data);
data.setVertical(vConf.getId());
break;
} else {
if (pNames.contains(term)) {
dedicatedLogger.info("Vertical {} confirmed by product names match for {}", vConf, data);
data.setVertical(vConf.getId());
break;
} else {
data.setVertical(null);
}

}

if (null == data.getVertical()) {
dedicatedLogger.info("Vertical {} failed on product names match, unsetting vertical for {}", vConf, data);
data.setVertical(null);
}

}
} catch (Exception e) {
dedicatedLogger.error("Error while handling names vertical filtering", e);
}
} catch (Exception e) {
dedicatedLogger.error("Error while handling names vertical filtering", e);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public class VerticalConfig{
/**
* A list a words that will exclude the item from the category if encountered
*/
@JsonMerge
private Set<String> excludingTokensFromCategoriesMatching = new HashSet<String>();

/**
Expand Down
4 changes: 4 additions & 0 deletions verticals/src/main/resources/verticals/tv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ attributesConfig:
##############################################################################
# Will associate to this vertical if one of the following categorie is present for the product

# If product categories contains one of this token, this will be unmatched
excludingTokensFromCategoriesMatching:
- MEUBLE

matchingCategories:
all: []
Darty Pro - Cashback:
Expand Down

0 comments on commit 8fa9722

Please sign in to comment.