|
@@ -17,9 +17,11 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.collections4.MapUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.commons.math3.util.MathUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.xm.Similarity;
|
|
|
+import spire.math.Number;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
import java.io.BufferedReader;
|
|
@@ -869,24 +871,29 @@ public class RankStrategyBy683 extends RankStrategyBasic {
|
|
|
private Map<String, String> featureBucket(Map<String, String> featureMap) {
|
|
|
Map<String, String> newFeatureMap = new ConcurrentHashMap<>(featureMap.size());
|
|
|
for (Map.Entry<String, String> entry : featureMap.entrySet()) {
|
|
|
- String name = entry.getKey();
|
|
|
- if (this.sparseFeatureSet.contains(name)) {
|
|
|
- if (entry.getValue() != null) {
|
|
|
- newFeatureMap.put(name, entry.getValue());
|
|
|
+ try {
|
|
|
+ String name = entry.getKey();
|
|
|
+ if (this.sparseFeatureSet.contains(name)) {
|
|
|
+ if (entry.getValue() != null) {
|
|
|
+ newFeatureMap.put(name, entry.getValue());
|
|
|
+ }
|
|
|
+ continue;
|
|
|
}
|
|
|
- continue;
|
|
|
- }
|
|
|
- double score = Double.parseDouble(entry.getValue());
|
|
|
- // 注意:0值、不在分桶文件中的特征,会被过滤掉。
|
|
|
- if (score > 1E-8) {
|
|
|
- if (this.bucketsMap.containsKey(name) && this.bucketsLen.containsKey(name)) {
|
|
|
- double[] buckets = this.bucketsMap.get(name);
|
|
|
- double bucketNum = this.bucketsLen.get(name);
|
|
|
- Double scoreNew = 1.0 / bucketNum * (ExtractorUtils.findInsertPosition(buckets, score) + 1.0);
|
|
|
- newFeatureMap.put(name, String.valueOf(scoreNew));
|
|
|
- } else {
|
|
|
- newFeatureMap.put(name, String.valueOf(score));
|
|
|
+
|
|
|
+ double score = Double.parseDouble(entry.getValue());
|
|
|
+ // 注意:0值、不在分桶文件中的特征,会被过滤掉。
|
|
|
+ if (score > 1E-8) {
|
|
|
+ if (this.bucketsMap.containsKey(name) && this.bucketsLen.containsKey(name)) {
|
|
|
+ double[] buckets = this.bucketsMap.get(name);
|
|
|
+ double bucketNum = this.bucketsLen.get(name);
|
|
|
+ Double scoreNew = 1.0 / bucketNum * (ExtractorUtils.findInsertPosition(buckets, score) + 1.0);
|
|
|
+ newFeatureMap.put(name, String.valueOf(scoreNew));
|
|
|
+ } else {
|
|
|
+ newFeatureMap.put(name, String.valueOf(score));
|
|
|
+ }
|
|
|
}
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("featureBucket error: ", e);
|
|
|
}
|
|
|
}
|
|
|
return newFeatureMap;
|