Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

The information in this document refers to functions that are available in the latest version of the RML Mapper feature.
Lenses may require updating in order to take advantage of any newly created functions.

General Functionality

  • A triple will not be generated if the subject or object is provided will a NULL value.

  • Strings passed into functions may be sourced from

    • References (The entire value of a field in the source document)

    • Templates (A string that includes values of fields in the source document, as well as manually specified strings)

    • Outputs from other Functions (Functions may therefore be nested)

Prefixes

In order to make use of the below functions, you must include the following prefixes in your mapping files:

@prefix fnml: <http://semweb.mmlab.be/ns/fnml#> .
@prefix fno: <https://w3id.org/function/ontology#> .
@prefix grel: <http://users.ugent.be/~bjdmeest/function/grel.ttl#> .

Custom Data Lens Functions

removeEqualValues

  • Description: Returns NULL if Input is equal to any of the values in String1

  • Use Case: Don’t generate a triple if the value in the source data is ‘None’ or N/A

  • Required Parameters:

    • Input - Input text

    • String1 - Delimited list of values

  • Returns: Input or NULL

fnml:functionValue [                                      # The object is the result of the function
        rr:predicateObjectMap [
          rr:predicate fno:executes ;                           # Execute the function
          rr:objectMap [ rr:constant grel:removeEqualValues ]   # The name of the function
        ] ;
        rr:predicateObjectMap [
          rr:predicate grel:valueParameter ;                    # Expected input type
          rr:objectMap [ rml:reference "Name" ]                 # Input value param, referenced from the data source
        ] ;
        rr:predicateObjectMap [
          rr:predicate grel:valueParameter2 ;                   # Expected input type
          rr:objectMap [ rr:constant "null,\N" ]                # Input value param, string constant as defined in ""
        ]
      ]

findAndReplace

  • Description: Find part or all of the first input value from a list of regex, provided by the second input of comma separated values, and replace with its respective value from the third input of comma separated values

  • Use Case: Remove undesirable values from within field data.

  • Expects:

    • Input - Input text

    • String1 - Regex find values

    • String2 - Regex replace values

  • Returns: Input, where matched values from String1 are replaced with corresponding values from String2

fnml:functionValue [
        rr:predicateObjectMap [
          rr:predicate fno:executes ;
          rr:objectMap [ rr:constant grel:findAndReplace ]
        ] ;
        rr:predicateObjectMap [
          rr:predicate grel:valueParameter ;
          rr:objectMap [ rml:reference "Name" ]
        ] ;
        rr:predicateObjectMap [
          rr:predicate grel:valueParameter2 ;
          rr:objectMap [ rr:constant "Bert,\],Venus,%20" ]
        ] ;
        rr:predicateObjectMap [
          rr:predicate grel:valueParameter3 ;
          rr:objectMap [ rr:constant "Bret,,Pluto, " ]
        ]
      ]

removeAllDoubleQuotes

  • Description: Returns the input with all double quotes removed

  • Use Case: Remove unnecessary double quotation marks from within field data.

  • Expects:

    • Input- Input text

  • Returns: Input with all double quotation marks have been removed.

fnml:functionValue [
        rr:predicateObjectMap [
          rr:predicate fno:executes ;
          rr:objectMap [ rr:constant grel:removeAllDoubleQuotes ]
        ] ;
        rr:predicateObjectMap [
          rr:predicate grel:valueParameter ;
          rr:objectMap [ rml:reference "Name" ]
        ]
      ]

translateToISODate

  • Description: Allows valid xsd:date values to be generated from non ISO standard date formats.

  • Use Case: The source data provides a date, but it’s not in xsd:date format.

  • Expects:

    • YearString - Delimited list containing

      • Input - Input text

      • StartPosition - Which position to start from, relative to the beginning on the Input text

      • CharacterCount - Number of characters after the StartPosition to extract

      • Prefix -2 digit prefix to add to extracted 2 character date, to make a 4 character date.

    • MonthString - Delimited list containing

      • Input - Input text

      • StartPosition - Which position to start from, relative to the beginning on the Input text

      • CharacterCount - Number of characters after the StartPosition to extract

    • DayString - Delimited list containing

      • Input - Input text

      • StartPosition - Which position to start from, relative to the beginning on the Input text

      • CharacterCount - Number of characters after the StartPosition to extract

  • Returns: Date in the format YYYY-MM-DD

 fnml:functionValue [
        rr:predicateObjectMap [
          rr:predicate fno:executes ;
          rr:objectMap [ rr:constant grel:translateToISODate ]
        ] ;
        rr:predicateObjectMap [
          rr:predicate grel:valueParameter ;
          rr:objectMap [
            rr:template "{Date},6,4,";
      	    rr:termType rr:Literal;
          ];
        ] ;
        rr:predicateObjectMap [
          rr:predicate grel:valueParameter2 ;
          rr:objectMap [
            rr:template "{Date},3,2";
            rr:termType rr:Literal;
          ]
        ] ;
        rr:predicateObjectMap [
          rr:predicate grel:valueParameter3 ;
          rr:objectMap [
            rr:template "{Date},0,2,";
            rr:termType rr:Literal;
          ]
        ]
      ];
      rr:datatype xsd:date;
      rr:termType rr:Literal;

extractCharactersFromEnd

  • Description: Extract a configurable number of characters from within a provided string, relative to the end of the string.

  • Use Case: You only want the last 5 characters from a provided string.

  • Expects:

    • Input - Input text

    • String1 - Which position to start from, relative to the end on the Input text (0 being the last character)

    • String2 - Number of characters prior to the position in String1 to extract

  • Returns: A slice of characters from the input text or NULL

fnml:functionValue [
        rr:predicateObjectMap [
          rr:predicate fno:executes ;
          rr:objectMap [ rr:constant grel:extractCharactersFromEnd ]
        ] ;
        rr:predicateObjectMap [
          rr:predicate grel:valueParameter ;
          rr:objectMap [ rml:reference "Name" ]
        ] ;
        rr:predicateObjectMap [
          rr:predicate grel:valueParameter2 ;
          rr:objectMap [ rr:constant "0" ]
        ] ;
        rr:predicateObjectMap [
          rr:predicate grel:valueParameter3 ;
          rr:objectMap [ rr:constant "5" ]
        ]
      ]

extractCharactersFromStart

  • Description: Extract a configurable number of characters from within a provided string, relative to the beginning of the string.

  • Use Case: You only want the first 5 characters from a provided string.

  • Expects:

    • Input - Input text

    • String1 - Which position to start from, relative to the beginning of the Input text (0 being the first character)

    • String2 - Number of characters after the position in String1 to extract

  • Returns: A slice of characters from the input text or NULL

fnml:functionValue [
        rr:predicateObjectMap [
          rr:predicate fno:executes ;
          rr:objectMap [ rr:constant grel:extractCharactersFromStart ]
        ] ;
        rr:predicateObjectMap [
          rr:predicate grel:valueParameter ;
          rr:objectMap [ rml:reference "Name" ]
        ] ;
        rr:predicateObjectMap [
          rr:predicate grel:valueParameter2 ;
          rr:objectMap [ rr:constant "0" ]
        ] ;
        rr:predicateObjectMap [
          rr:predicate grel:valueParameter3 ;
          rr:objectMap [ rr:constant "5" ]
        ]
      ]

retrieveValueFromDelimitedList

  • Description: Extracts a specified value from a provided delimited list.

  • Use Case:

  • Expects:

    • Input - Input delimited list

    • String1 - Value used as the delimiter

    • String2 - Which element from the delimited list to return

  • Returns: An element extract from the Input list, or NULL

 fnml:functionValue [
        rr:predicateObjectMap [
          rr:predicate fno:executes ;
          rr:objectMap [ rr:constant grel:retrieveValueFromDelimitedList ]
        ] ;
        rr:predicateObjectMap [
          rr:predicate grel:valueParameter ;
          rr:objectMap [ rml:reference "Name" ]
        ] ;
        rr:predicateObjectMap [
          rr:predicate grel:valueParameter2 ;
          rr:objectMap [ rr:constant "," ]
        ] ;
        rr:predicateObjectMap [
          rr:predicate grel:valueParameter3 ;
          rr:objectMap [ rr:constant "1" ]
        ]
      ]

toUpperCase

  • Description: Converts a provided string to UPPERCASE

  • Use Case:

  • Expects:

    • Input

  • Returns: Input, in UPPERCASE

fnml:functionValue [
      rr:predicateObjectMap [
        rr:predicate fno:executes ;
        rr:objectMap [ rr:constant grel:toUpperCase ]
      ] ;
      rr:predicateObjectMap [
        rr:predicate grel:valueParameter ;
        rr:objectMap [ rr:template "{Name}" ]
      ]
    ]

toLowerCase

  • Description: Converts a provided string to lowercase

  • Use Case:

  • Expects:

    • Input

  • Returns: Input, in lowercase

fnml:functionValue [
      rr:predicateObjectMap [
        rr:predicate fno:executes ;
        rr:objectMap [ rr:constant grel:toLowerCase ]
      ] ;
      rr:predicateObjectMap [
        rr:predicate grel:valueParameter ;
        rr:objectMap [ rr:template "{Name}" ]
      ]
    ]

concat

  • Description: Combines 2 provided strings, into 1 string

  • Use Case:

  • Expects:

    • Input1

    • Input2

  • Returns: Input1Input2

//This is unverified

fnml:functionValue [
      rr:predicateObjectMap [
        rr:predicate fno:executes ;
        rr:objectMap [ rr:constant grel:concat ]
      ] ;
      rr:predicateObjectMap [
        rr:predicate grel:valueParameter ;
        rr:objectMap [ rml:reference "Part1" ]
      ] ;
      rr:predicateObjectMap [
        rr:predicate grel:valueParameter2 ;
        rr:objectMap [ rml:reference "Part2" ]
      ]
    ]

random

  • Description: Returns a randomly generated UUID

  • Use Case:

  • Expects: None

  • Returns: A randomly generated UUID

//This is unverified

fnml:functionValue [
      rr:predicateObjectMap [
        rr:predicate fno:executes ;
        rr:objectMap [ rr:constant grel:random ]
      ] 
    ]

toUpperCaseURL

  • Description: Ensures that a provided string is a URL, and converts it to one if it isn’t (Prepends HTTP:// where necessary),

  • Use Case:

  • Expects:

    • Input

  • Returns: Input1 in UPPERCASE converted to a URL

fnml:functionValue [
      rr:predicateObjectMap [
        rr:predicate fno:executes ;
        rr:objectMap [ rr:constant grel:toUpperCaseURL ]
      ] ;
      rr:predicateObjectMap [
        rr:predicate grel:valueParameter ;
        rr:objectMap [ rr:template "http://example.com/{Name}" ]
      ]
    ]


Default Mapper Functions

DBpedia Spotlight annotate

Returns the DBpedia URLs of the detected entities in the input text

Function IRI: http://example.com/idlab/function/dbpediaSpotlight

Read local file as string

Returns the content of a local file as string

Function IRI: http://example.com/idlab/function/readFile

True condition

Returns the value if the given boolean is true, else null

Function IRI: http://example.com/idlab/function/trueCondition

decide

Returns a given value if input is equal to another given value

Function IRI: http://example.com/idlab/function/decide

getMIMEType

Returns the MIME Type of a filename

Function IRI: http://example.com/idlab/function/getMIMEType

listContainsElement

Returns true if the string is found in the list

Function IRI: http://example.com/idlab/function/listContainsElement

random

Returns a random uuid.

Function IRI: http://example.com/idlab/function/random

This function does not take any arguments.

stringContainsOtherString

Returns true if a string is found in a delimited string.

Function IRI: http://example.com/idlab/function/stringContainsOtherString

toLowercase

Returns the input with all letters in lower case.

Function IRI: http://users.ugent.be/~bjdmeest/function/grel.ttl#toLowerCase

toUppercase

Returns the input with all letters in upper case.

Function IRI: http://users.ugent.be/~bjdmeest/function/grel.ttl#toUpperCase

toUpperCaseURL

Returns an uppercase, valid url.

Function IRI: http://example.com/idlab/function/toUpperCaseURL

  • No labels

0 Comments

You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In if you already have an account.