Package org.incenp.obofoundry.sssom
Class Cardinalizer
- java.lang.Object
-
- org.incenp.obofoundry.sssom.Cardinalizer
-
public class Cardinalizer extends Object
A helper object to compute cardinality values.This class implements the idea, proposed to the SSSOM specification, that there is not a single “absolute” cardinality, but that cardinality is instead defined relatively to a ”scope”.
A “scope” is a list of mapping slot names (S1, S2, ..., Sn). Cardinality is computed in the subset of mappings that have the same value for all slots in the scope. If the scope is empty, cardinality is computed on the entire set.
-
-
Constructor Summary
Constructors Constructor Description Cardinalizer()Creates a new instance with an empty scope.Cardinalizer(Collection<String> slots)Creates a new instance with the specified slots as the scope.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidfillCardinality(List<Mapping> mappings)Computes the cardinality of all mappings in the given set, according to the current scope, and fills themapping_cardinalityslot and thecardinality_scopeslot accordingly.StringgetObject(Mapping mapping)Gets a string representing the object of a mapping, that can be used for cardinality computation.StringgetSubject(Mapping mapping)Gets a string representing the subject of a mapping, that can be used for cardinality computation.
-
-
-
Constructor Detail
-
Cardinalizer
public Cardinalizer()
Creates a new instance with an empty scope.
-
Cardinalizer
public Cardinalizer(Collection<String> slots)
Creates a new instance with the specified slots as the scope.- Parameters:
slots- The list of slots to take into account when computing cardinality. Names that do not correspond to valid SSSOM slots are silently ignored.
-
-
Method Detail
-
fillCardinality
public void fillCardinality(List<Mapping> mappings)
Computes the cardinality of all mappings in the given set, according to the current scope, and fills themapping_cardinalityslot and thecardinality_scopeslot accordingly.This overrides any cardinality information that may already be stored in each mapping.
- Parameters:
mappings- The set of mappings on which to compute cardinality.
-
getSubject
public String getSubject(Mapping mapping)
Gets a string representing the subject of a mapping, that can be used for cardinality computation.- Parameters:
mapping- The mapping for which to derive a subject string.- Returns:
- A string that can be used to compare subjects across mappings.
-
-