dnet-hadoop/dhp-workflows/dhp-broker-events/src/main/java/eu/dnetlib/dhp/broker/oa/util/TrustUtils.java

24 lines
567 B
Java
Raw Normal View History

2020-06-10 12:11:16 +02:00
2020-06-09 16:01:31 +02:00
package eu.dnetlib.dhp.broker.oa.util;
public class TrustUtils {
public static float rescale(final double score, final double threshold) {
2020-06-10 12:11:16 +02:00
if (score >= BrokerConstants.MAX_TRUST) {
return BrokerConstants.MAX_TRUST;
}
2020-06-09 16:01:31 +02:00
2020-06-10 12:11:16 +02:00
final double val = (score - threshold) * (BrokerConstants.MAX_TRUST - BrokerConstants.MIN_TRUST)
/ (BrokerConstants.MAX_TRUST - threshold);
2020-06-09 16:01:31 +02:00
2020-06-10 12:11:16 +02:00
if (val < BrokerConstants.MIN_TRUST) {
return BrokerConstants.MIN_TRUST;
}
if (val > BrokerConstants.MAX_TRUST) {
return BrokerConstants.MAX_TRUST;
}
2020-06-09 16:01:31 +02:00
return (float) val;
}
}