|
|
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));
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|