![JAR search and dependency download from the Maven repository](/logo.png)
com.github.TKnudsen.ComplexDataObject.data.uncertainty.string.LabelUncertainty Maven / Gradle / Ivy
package com.github.TKnudsen.ComplexDataObject.data.uncertainty.string;
import java.util.Map;
import java.util.Set;
import com.github.TKnudsen.ComplexDataObject.data.uncertainty.IUncertaintyQualitative;
/**
*
* Title: LabelUncertainty
*
*
*
* Description: data model for uncertainties of string data.
*
*
*
* Copyright: Copyright (c) 2015-2017
*
*
* @author Juergen Bernard
* @version 1.0
*/
public class LabelUncertainty implements IUncertaintyQualitative {
private Map valueDistribution;
private String representant;
/**
* constructor for reflection-based and jackson-based access.
*/
@SuppressWarnings("unused")
private LabelUncertainty() {
this(null, null);
}
public LabelUncertainty(Map valueDistribution) {
this(valueDistribution, null);
}
public LabelUncertainty(Map valueDistribution, String representant) {
this.valueDistribution = valueDistribution;
this.representant = representant;
if (representant == null)
this.representant = calculateRepresentant();
}
private String calculateRepresentant() {
String rep = null;
Double repRatio = 0.0;
if (valueDistribution == null)
return null;
for (String value : valueDistribution.keySet())
if (valueDistribution.get(value) > repRatio) {
rep = value;
repRatio = valueDistribution.get(value);
}
return rep;
}
@Override
public String getRepresentant() {
return representant;
}
@Override
public Map getValueDistribution() {
return valueDistribution;
}
public Set getValueSet() {
return valueDistribution.keySet();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy