Authored by hugufei

拆包

... ... @@ -4,7 +4,7 @@ import com.yoho.search.base.utils.SearchCollectionUtils;
import com.yoho.search.base.utils.Transfer;
import com.yoho.search.core.personalized.models.PersonalizedSearch;
import com.yoho.search.core.personalized.models.SortPriceAreas;
import com.yoho.search.service.recall.beans.persional.ProductFeatureFactorComponent;
import com.yoho.search.service.recall.helper.W2vFeatureCalculator;
import com.yoho.search.service.recall.config.RecallConfigConstants;
import com.yoho.search.service.recall.config.RecallConfigService;
import com.yoho.search.service.recall.models.personal.UserFeatureFactor;
... ... @@ -34,8 +34,6 @@ public class UserRecallResponseBuilder {
@Autowired
private PersonalVectorFeatureSearch personalVectorFeatureSearch;
@Autowired
private ProductFeatureFactorComponent productFeatureFactorComponent;
@Autowired
private SknBaseInfoBaseService sknBaseInfoBaseService;
@Autowired
private RecallConfigService recallConfigService;
... ... @@ -200,7 +198,7 @@ public class UserRecallResponseBuilder {
continue;
}
//3)向量计算-如果为1,则使用百分之1的人气替代
score = productFeatureFactorComponent.calProductFeatureFactor(userFeatureFactor, sknResult.getFactor());
score = W2vFeatureCalculator.calProductFeatureFactor(userFeatureFactor, sknResult.getFactor());
if (score == 0) {
score = sknResult.getHeatValue() / 100;
}
... ...
package com.yoho.search.service.recall.beans.persional;
package com.yoho.search.service.recall.helper;
import com.yoho.search.base.helper.Word2VectorCalculator;
import com.yoho.search.base.utils.ConvertUtils;
... ... @@ -8,19 +8,17 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public class ProductFeatureFactorComponent {
public class W2vFeatureCalculator {
private static final Logger logger = LoggerFactory.getLogger(ProductFeatureFactorComponent.class);
private static final Logger logger = LoggerFactory.getLogger(W2vFeatureCalculator.class);
private static double baseConstant = 1;
private static double factorConstant = 1;
public double calProductFeatureFactor(UserFeatureFactor userFeatureFactor, String productFeatureFactor) {
public static double calProductFeatureFactor(UserFeatureFactor userFeatureFactor, String productFeatureFactor) {
try {
//商品向量不存在,则返回
if (StringUtils.isBlank(productFeatureFactor)) {
... ... @@ -57,7 +55,7 @@ public class ProductFeatureFactorComponent {
PersonalizedSearch personalizedSearch = new PersonalizedSearch("1", "20180408", array);
UserFeatureFactor userFeatureFactor = new UserFeatureFactor(personalizedSearch);
String productFeatureFactor = "20180408|1.342045,-0.547933,0.291732,-0.056515,-0.182701,0.31113,0.151578,0.087678,-0.045536,-0.525699,-0.394715,-0.103153,-0.05575,-0.540641,0.028046,-0.193109,-0.003591,0.180923,0.290261,0.532309,-0.202463,-0.047271,-0.246197,0.324561,0.188814,0.36475,0.079007,0.455753,-0.11848,-0.135874,-0.187155,-0.055342,-0.12525,0.210669,-0.388331,-0.197123,0.132309,-0.4231,0.217752,-0.203266,0.190836,0.373428,-0.0102,-0.038654,0.2379,0.044424,0.071826,-0.201054,0.257434,0.141901,-0.390064,0.437099,0.559701,-0.040162,-0.193089,0.442338,-0.141678,-0.049696,0.315545,-0.028972,0.278694,-0.064345,-0.327943,0.103025,-0.40344,-0.34269,-0.237931,0.287046,0.139693,-0.38454,0.019959,-0.156907,0.374996,-0.074558,-0.019391,0.050522,0.315171,0.211605,-0.15418,0.502362,0.10184,0.153274,0.592659,-0.010284,0.28029,0.319741,-0.164559,0.286884,0.420483,-0.628866,-0.172259,0.027954,-0.411674,0.376585,0.322832,0.352039,0.078705,0.045152,0.139083,-0.164182";
System.out.println(new ProductFeatureFactorComponent().calProductFeatureFactor(userFeatureFactor, productFeatureFactor));
System.out.println(calProductFeatureFactor(userFeatureFactor, productFeatureFactor));
}
}
... ...
... ... @@ -6,14 +6,14 @@ import com.yoho.search.cache.beans.AbstractCacheBean;
import com.yoho.search.core.personalized.models.PersonalizedSearch;
import com.yoho.search.core.personalized.models.SortBrand;
import com.yoho.search.core.personalized.models.UserPersonalFactorRsp;
import com.yoho.search.service.recall.beans.persional.ProductFeatureFactorComponent;
import com.yoho.search.service.recall.beans.persional.UserPersionalFactorComponent;
import com.yoho.search.service.recall.strategy.IStrategy;
import com.yoho.search.service.recall.beans.vector.BrandVectorCacheBean;
import com.yoho.search.service.recall.helper.W2vFeatureCalculator;
import com.yoho.search.service.recall.models.common.ParamQueryFilter;
import com.yoho.search.service.recall.models.personal.BrandVectorScore;
import com.yoho.search.service.recall.models.personal.UserFeatureFactor;
import com.yoho.search.service.recall.models.req.RecallRequest;
import com.yoho.search.service.recall.strategy.IStrategy;
import com.yoho.search.service.scorer.personal.PersonalVectorFeatureSearch;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -36,8 +36,6 @@ public class AggBrandProductCacheBean extends AbstractCacheBean<BrandProductRequ
private BatchBrandProductCacheBean batchBrandProductCacheBean;
@Autowired
private PersonalVectorFeatureSearch personalVectorFeatureSearch;
@Autowired
private ProductFeatureFactorComponent productFeatureFactorComponent;
/**
* 入口
... ... @@ -115,7 +113,7 @@ public class AggBrandProductCacheBean extends AbstractCacheBean<BrandProductRequ
private void doCalScoreAndSort(List<BrandProduct> productList, UserFeatureFactor userFeatureFactor) {
for (BrandProduct product : productList) {
double score = productFeatureFactorComponent.calProductFeatureFactor(userFeatureFactor, product.getProductFeatureFactor());
double score = W2vFeatureCalculator.calProductFeatureFactor(userFeatureFactor, product.getProductFeatureFactor());
if (score == 0) {
score = (double) product.getHeatValue() / 100;
}
... ...