Package org.incenp.obofoundry.sssom
Class Cardinalizer
java.lang.Object
org.incenp.obofoundry.sssom.Cardinalizer
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
ConstructorsConstructorDescriptionCreates a new instance with an empty scope.Cardinalizer
(Collection<String> slots) Creates a new instance with the specified slots as the scope. -
Method Summary
Modifier and TypeMethodDescriptionvoid
fillCardinality
(List<Mapping> mappings) Computes the cardinality of all mappings in the given set, according to the current scope, and fills themapping_cardinality
slot and thecardinality_scope
slot accordingly.Gets a string representing the object of a mapping, that can be used for cardinality computation.getSubject
(Mapping mapping) Gets a string representing the subject of a mapping, that can be used for cardinality computation.
-
Constructor Details
-
Cardinalizer
public Cardinalizer()Creates a new instance with an empty scope. -
Cardinalizer
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 Details
-
fillCardinality
Computes the cardinality of all mappings in the given set, according to the current scope, and fills themapping_cardinality
slot and thecardinality_scope
slot 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
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.
-
getObject
Gets a string representing the object of a mapping, that can be used for cardinality computation.- Parameters:
mapping
- The mapping for which to derive an object string.- Returns:
- A string that can be used to compare objects across mappings.
-