Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FnO output specification? #29

Closed
bjdmeest opened this issue Aug 2, 2021 · 6 comments
Closed

FnO output specification? #29

bjdmeest opened this issue Aug 2, 2021 · 6 comments

Comments

@bjdmeest
Copy link
Member

bjdmeest commented Aug 2, 2021

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" .
@bjdmeest bjdmeest added the FnO label Aug 2, 2021
@samiscoding
Copy link

samiscoding commented Oct 4, 2021

I agree that the third option may require less effort in terms of declaration, but what about its expressiveness e.g. join between different sources? I suggest keeping the output at the FunctionTermMap but including the reference from FunctionTriplesMap to the FunctionTermMap and not the other way around? The advantage of this definition is that it provides a solution to both join and output as list. So following the same example it would be sth like:

# 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 [                                                   # Specify the object-map
          rr:parentTriplesMap <#parseFirstNameFunctionTriplesMap>;  ].           
    
<#LastNameMapping>
    rr:predicate foaf:lastName ;                              # Specify the predicate
     rr:objectMap [                                                   # Specify the object-map
          rr:parentTriplesMap <#parseLastNameFunctionTriplesMap>;  ​].  

<#FunctionTermMapFirstName>
 ​ fnml:outputValue ex:firstname .

<#FunctionTermMapLastName>
  fnml:outputValue ex:lastname .

<#parseFirstNameFunctionTriplesMap>
fnml:outputValue <#FunctionTermMapFirstName>;
   rr:predicateObjectMap <#functionExecution>;
   rr:predicateObjectMap <#functionInput>.

<#parseLastNameFunctionTriplesMap>
fnml:outputValue <#FunctionTermMapLastName>;
  ​rr:predicateObjectMap <#functionExecution>;
  rr:predicateObjectMap <#functionInput>.

<#functionExecution>
    ​rr:predicate fno:executes ;                              # Execute the function
    ​rr:objectMap [ rr:constant ex:parseName ]     # ex:parseName  

<#functionInput>
    ​rr:predicate ex:inputString ;                             # Execute the function
    ​rr:objectMap [ rr:reference "name" ]               # Use as input the "name" reference 

What do you think?

@bjdmeest
Copy link
Member Author

bjdmeest commented Oct 5, 2021

For the outputValue, I don't see the added value for the indirection to <#FunctionTermMapFirstName>, could you elaborate?

For the joins, I have the feeling kg-construct/rml-lv#16 or kg-construct/rml-fnml#3 or kg-construct/rml-fnml#4 are more relevant than this issue, but correct me if I'm wrong :)

@samiscoding
Copy link

There was a typo in "ex:firstname", I edited it. Is there anything else missing?
As I also mentioned at kg-construct/rml-lv#16 we can probably solve some of the issues all at once just by selecting the more comprehensive definitions of FunctionTriplesMap and FunctionTermMap, I think that should be our approach :) If you prefer probably we can move all the issues related to the definitions of FunctionTriplesMap and FunctionTermMap to one issue with an appropriate name, what do you think?

@bjdmeest
Copy link
Member Author

bjdmeest commented Oct 7, 2021

I updated #14 for the definitions of functiontriplesmap and functiontermmap, can we continue discussions there, and focus this issue on the output specification?

@dachafra
Copy link
Member

If it makes sense, this can be transferred to https://github.com/kg-construct/fnml-spec

@bjdmeest
Copy link
Member Author

I think this should be revisited based on https://kg-construct.github.io/fnml-spec/ , I vote to close bc it's handled in the current draft

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants