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
    Creates a new instance with an empty scope.
    Creates a new instance with the specified slots as the scope.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Computes the cardinality of all mappings in the given set, according to the current scope, and fills the mapping_cardinality slot and the cardinality_scope slot accordingly.
    getObject(Mapping mapping)
    Gets a string representing the object of a mapping, that can be used for cardinality computation.
    Gets a string representing the subject of a mapping, that can be used for cardinality computation.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • 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 Details

    • fillCardinality

      public void fillCardinality(List<Mapping> mappings)
      Computes the cardinality of all mappings in the given set, according to the current scope, and fills the mapping_cardinality slot and the cardinality_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

      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.
    • getObject

      public String getObject(Mapping mapping)
      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.