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