|
@@ -12,6 +12,7 @@ import com.tzld.piaoquan.recommend.feature.domain.ad.base.AdRankItem;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.MapUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.xm.Similarity;
|
|
|
|
|
@@ -37,6 +38,9 @@ public class RankStrategyXGBAutoUpdateModel688 extends RankStrategyXGBBasic {
|
|
|
|
|
|
private Map<String, Double> bucketsLen = new HashMap<>();
|
|
|
|
|
|
+ @Value("${word2vec.exp:694}")
|
|
|
+ private String word2vecExp;
|
|
|
+
|
|
|
@Override
|
|
|
public List<AdRankItem> adItemRank(RankRecommendRequestParam request, ScoreParam scoreParam) {
|
|
|
|
|
@@ -140,14 +144,14 @@ public class RankStrategyXGBAutoUpdateModel688 extends RankStrategyXGBBasic {
|
|
|
String title = b1Feature.getOrDefault("cidtitle", "");
|
|
|
ThreadPoolFactory.defaultPool().submit(() -> {
|
|
|
try {
|
|
|
- this.handleE1AndE2Feature(e1Feature, e2Feature, title, item.getFeatureMap());
|
|
|
+ this.handleE1AndE2Feature(e1Feature, e2Feature, title, item.getFeatureMap(), scoreParam);
|
|
|
} finally {
|
|
|
cdl2.countDown();
|
|
|
}
|
|
|
});
|
|
|
ThreadPoolFactory.defaultPool().submit(() -> {
|
|
|
try {
|
|
|
- this.handleD3AndB1Feature(d3Feature, title, item.getFeatureMap());
|
|
|
+ this.handleD3AndB1Feature(d3Feature, title, item.getFeatureMap(), scoreParam);
|
|
|
} finally {
|
|
|
cdl2.countDown();
|
|
|
}
|
|
@@ -434,16 +438,23 @@ public class RankStrategyXGBAutoUpdateModel688 extends RankStrategyXGBBasic {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void handleD3AndB1Feature(Map<String, String> d3Feature, String cTitle, Map<String, String> featureMap) {
|
|
|
+ private void handleD3AndB1Feature(Map<String, String> d3Feature, String cTitle, Map<String, String> featureMap,
|
|
|
+ ScoreParam scoreParam) {
|
|
|
if (MapUtils.isEmpty(d3Feature) || !d3Feature.containsKey("title") || StringUtils.isEmpty(cTitle)) {
|
|
|
return;
|
|
|
}
|
|
|
String vTitle = d3Feature.get("title");
|
|
|
- double score = Similarity.conceptSimilarity(cTitle, vTitle);
|
|
|
+ double score;
|
|
|
+ if (scoreParam.getExpCodeSet().contains(word2vecExp)) {
|
|
|
+ score = SimilarityUtils.word2VecSimilarity(cTitle, vTitle);
|
|
|
+ } else {
|
|
|
+ score = Similarity.conceptSimilarity(cTitle, vTitle);
|
|
|
+ }
|
|
|
featureMap.put("ctitle_vtitle_similarity", String.valueOf(score));
|
|
|
}
|
|
|
|
|
|
- private void handleE1AndE2Feature(Map<String, String> e1Feature, Map<String, String> e2Feature, String title, Map<String, String> featureMap) {
|
|
|
+ private void handleE1AndE2Feature(Map<String, String> e1Feature, Map<String, String> e2Feature, String title,
|
|
|
+ Map<String, String> featureMap, ScoreParam scoreParam) {
|
|
|
if (StringUtils.isEmpty(title)) {
|
|
|
return;
|
|
|
}
|
|
@@ -461,7 +472,13 @@ public class RankStrategyXGBAutoUpdateModel688 extends RankStrategyXGBBasic {
|
|
|
for (String tagsField : tagsFieldList) {
|
|
|
if (StringUtils.isNotEmpty(feature.get(tagsField))) {
|
|
|
String tags = feature.get(tagsField);
|
|
|
- Double[] doubles = ExtractorUtils.funcC34567ForTags(tags, title);
|
|
|
+ //Double[] doubles = ExtractorUtils.funcC34567ForTags(tags, title);
|
|
|
+ Double[] doubles;
|
|
|
+ if (scoreParam.getExpCodeSet().contains(word2vecExp)) {
|
|
|
+ doubles = ExtractorUtils.funcC34567ForTagsNew(tags, title);
|
|
|
+ } else {
|
|
|
+ doubles = ExtractorUtils.funcC34567ForTags(tags, title);
|
|
|
+ }
|
|
|
featureMap.put(prefix + "_" + tagsField + "_matchnum", String.valueOf(doubles[0]));
|
|
|
featureMap.put(prefix + "_" + tagsField + "_maxscore", String.valueOf(doubles[1]));
|
|
|
featureMap.put(prefix + "_" + tagsField + "_avgscore", String.valueOf(doubles[2]));
|