Skip to content

FnO output specification? #29

Closed
Closed
@bjdmeest

Description

@bjdmeest

Just to summarize the current discussions and make sure I understand: the problem is that if a function is defined to return multiple outputs, FNML is ambiguous in which output to use.
Right now, implicitly, we assume to always take the first output. At the very least, this should be explicitly stated in the specification.
HOWEVER, that still gives problems if at some point you want to use the second output of a function :).
So we need a way to specify the output of the function, and Sam suggested using the SubjectMap for this.
(If above doesn't reflect the correct reasoning, please correct me and ignore my suggestions below ;) )

I personally think that there are the following options for specifying the output of the function:

  • explicitly state that the subjectmap within a FunctionTripleMaps has a quite different definition than subjectmaps within regular TripleMaps, namely smth like "The subjectMap of a FunctionTriplesMap generates the reference to the needed output of the function". I'm not for this option, since it's basically a redefinition and also hinders the generation of provenance data in the long run
  • provide a separate OutputMap within a FunctionTripleMaps with the definition "The outputMap of a FunctionTriplesMap generates the reference to the needed output of the function". The subjectMap's definition is untouched and can be used for provenance generation, and you can specify the output of the function
  • Specify this outputMap on the level of FunctionTermMap instead of FunctionTriplesMap (so you, e.g., use multiple outputs of the same FunctionTriplesMap for different (regular) TermMaps)

I'm in favor of this last option, see example below for what this entails

# Function description #

<ex:parseName> a fno:Function
  fno:expects ( [ fno:predicate ex:inputString ] )
  fno:returns ( [ fno:predicate ex:firstName] [fno:predicate ex:lastName ] ) .

# Mapping #

<#Person_Mapping>
    rml:logicalSource <#LogicalSource> ;                  # Specify the data source
    rr:subjectMap <#SubjectMap> ;                         # Specify the subject
    rr:predicateObjectMap <#FirstNameMapping> ;                # Specify the predicate-object-map
    rr:predicateObjectMap <#LastNameMapping> ,                # Specify the predicate-object-map

<#FirstNameMapping>
    rr:predicate foaf:firstName ;                              # Specify the predicate
    rr:objectMap <#FunctionTermMapFirstName> .                         # Specify the object-map
    
<#LastNameMapping>
    rr:predicate foaf:lastName ;                              # Specify the predicate
    rr:objectMap <#FunctionTermMapLastName> .                         # Specify the object-map

<#FunctionTermMapFirstName>
    fnml:functionValue parseNameFunctionTriplesMap ;
    fnml:outputValue ex:firstName .

<#FunctionTermMapLastName>
    fnml:functionValue parseNameFunctionTriplesMap ;
    fnml:outputValue ex:lastname .

<#parseNameFunctionTriplesMap>
    a fnml:FunctionTriplesMap ;
    rr:predicateObjectMap [
        rr:predicate fno:executes ;                   # Execute the function
        rr:objectMap [ rr:constant ex:parseName ] # ex:parseName
    ] ;
    rr:predicateObjectMap [
        rr:predicate ex:inputString ;
        rr:objectMap [ rr:reference "name" ]          # Use as input the "name" reference
    ] .

# When given the reference "name", e.g. value "Ben De Meester", this functiontriplesMap will generate following triples:
_:a # Blank node, because no SubjectMap is given
  fno:executes ex:parseName ;
  ex:inputString "Ben De Meester" .

# After execution, following triples will be generated
_:a # Same blank node
  ex:firstName "Ben" ;
  ex:lastName "De Meester" .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions