Class SSSOMTInferCardinalityFunction

java.lang.Object
org.incenp.obofoundry.sssom.transform.SSSOMTInferCardinalityFunction
All Implemented Interfaces:
IMappingProcessorCallback, ISSSOMTFunction<IMappingProcessorCallback>

public class SSSOMTInferCardinalityFunction extends Object implements ISSSOMTFunction<IMappingProcessorCallback>, IMappingProcessorCallback
Represents the SSSOM/T standard callback function “infer_cardinality”.

This function computes the cardinality for all the mappings it is applied to. By default, the cardinality is computed relatively to all the mappings the function is applied to; to compute cardinality relatively to smaller subsets, specify the slots to use as scope as arguments to the function.

For example, to compute cardinality relatively to the subset of mappings that have the same predicate and the same object source:

 ... -> infer_cardinality("predicate_id", "object_source");
 
  • Constructor Details

    • SSSOMTInferCardinalityFunction

      public SSSOMTInferCardinalityFunction()
  • Method Details

    • getName

      public String getName()
      Description copied from interface: ISSSOMTFunction
      Gets the name of the function, by which it can be called in a SSSOM/T ruleset.
      Specified by:
      getName in interface ISSSOMTFunction<IMappingProcessorCallback>
      Returns:
      The function name.
    • getSignature

      public String getSignature()
      Description copied from interface: ISSSOMTFunction
      Gets the expected signature of the function. It should be a string that represents how many arguments (excluding keyed arguments) the function is expecting, where a single S character represents an argument.

      Regular expression syntax may be used to represent arguments that are optional or represent other kinds of constraints about the arguments list.

      Examples:

      • SSS for a function that expects exactly 3 arguments;
      • S+ for a function that expects at least one argument, possibly more;
      • (SS)+ for a function that one or more pairs of arguments (e.g. 2, 4, 6, but not 3 or 5).
      Specified by:
      getSignature in interface ISSSOMTFunction<IMappingProcessorCallback>
      Returns:
      The function signature.
    • call

      public IMappingProcessorCallback call(List<String> arguments, Map<String,String> keyedArguments) throws SSSOMTransformError
      Description copied from interface: ISSSOMTFunction
      Executes the function.

      Before this method is called, the arguments list will have been checked against the signature and will be guaranteed to be correct (e.g. if the function declared to expects two arguments, it is guaranteed the arguments list will contains two items).

      Specified by:
      call in interface ISSSOMTFunction<IMappingProcessorCallback>
      Parameters:
      arguments - The arguments to the function. May be empty, but not null.
      keyedArguments - The keyed arguments to the function. May be empty, but null.
      Returns:
      The result of executing the function.
      Throws:
      SSSOMTransformError - If any error occurred when executing the function (which may include the case where the number of arguments was correct but their contents was not).
    • process

      public void process(IMappingFilter filter, List<Mapping> mappings)
      Description copied from interface: IMappingProcessorCallback
      Applies a custom process to a set of mappings. This method is called by MappingProcessor.process(List) before applying the preprocessor and/or the generator of the current rule.
      Specified by:
      process in interface IMappingProcessorCallback
      Parameters:
      filter - The filter of the rule currently being applied. May be null.
      mappings - The current set of mappings.