List of Available Lens Functions
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.
Â
- 1 General Functionality
- 1.1 Prefixes
- 2 Custom Data Lens Functions
- 2.1 ifEqual
- 2.2 toPascalCase
- 2.3 toCamelCase
- 2.4 toKebabCase
- 2.5 toScreamingSnakeCase
- 2.6 toSnakeCase
- 2.7 unixEpochConverter
- 2.8 existsThen
- 2.9 removeEqualValues
- 2.10 findAndReplace
- 2.11 removeAllDoubleQuotes
- 2.12 translateToISODate
- 2.13 extractCharactersFromEnd
- 2.14 extractCharactersFromStart
- 2.15 retrieveValueFromDelimitedList
- 2.16 toUpperCase
- 2.17 toLowerCase
- 2.18 concat
- 2.19 random
- 2.20 toUpperCaseURL
- 3 Default Mapper Functions
- 3.1 DBpedia Spotlight annotate
- 3.2 Read local file as string
- 3.3 True condition
- 3.4 and
- 3.5 chomp
- 3.6 contains
- 3.7 decide
- 3.8 endsWith
- 3.9 equal
- 3.10 escape
- 3.11 getMIMEType
- 3.12 if
- 3.13 inRange
- 3.14 indexOf
- 3.15 join
- 3.16 length
- 3.17 listContainsElement
- 3.18 mqlKeyUnquote
- 3.19 not
- 3.20 not equal
- 3.21 or
- 3.22 random
- 3.23 split
- 3.24 startsWith
- 3.25 stringContainsOtherString
- 3.26 substring
- 3.27 toLowercase
- 3.28 toUppercase
- 3.29 toTitlecase
- 3.30 toUpperCaseURL
- 3.31 trim
- 3.32 xor
Â
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
ifEqual
Description: If a value equals and expected value, return if else that
Required Parameters:
Input - Input text
String1 - Value to be equal to
String2 - If equal return this value
String3 - If not equal return this value
Returns: String3 if input equals String1, otherwise return String2
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 [ rr:template "{Name}" ] # Input value param, referenced from the data source
] ;
rr:predicateObjectMap [
rr:predicate grel:valueParameter2 ; # Expected input type
rr:objectMap [ rr:template "John" ] # Input value param, string constant as defined in ""
] ;
rr:predicateObjectMap [
rr:predicate grel:valueParameter3 ; # Expected input type
rr:objectMap [ rr:template "matches name" ] # Input value param, string constant as defined in ""
] ;
rr:predicateObjectMap [
rr:predicate grel:valueParameter4 ; # Expected input type
rr:objectMap [ rr:template "no match" ] # Input value param, string constant as defined in ""
] ;
]
toPascalCase
Description: Returns as value as PascalCase
Required Parameters:
Input - Input text
Returns: Input as PascalCase
fnml:functionValue [ # The object is the result of the function
rr:predicateObjectMap [
rr:predicate fno:executes ; # Execute the function
rr:objectMap [ rr:constant grel:toPascalCase ] # 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
]
]
toCamelCase
Description: Returns as value as camelCase
Required Parameters:
Input - Input text
Returns: Input as camelCase
toKebabCase
Description: Returns as value as kebab-case
Required Parameters:
Input - Input text
Returns: Input as kebab-case
toScreamingSnakeCase
Description: Returns as value as SCREAMING_SNAKE_CASE
Required Parameters:
Input - Input text
Returns: Input as SCREAMING_SNAKE_CASE
toSnakeCase
Description: Returns as value as snake_case
Required Parameters:
Input - Input text
Returns: Input as snake_case
unixEpochConverter
Description: Reads a long representing unix time to xsd:date
Required Parameters:
Input - Input text
String1 -
days
,seconds
,milliseconds
(default)
Returns: a unix time conversion
existsThen
Description:
Takes an input value and if it is not null, return the output value
Required Parameters:
Input - Input text
String1 - value to return when not null
Returns: String1 when not null, otherwise null
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
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
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.
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
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
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
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
toUpperCase
Description: Converts a provided string to UPPERCASE
Use Case:
Expects:
Input
Returns: Input, in UPPERCASE
toLowerCase
Description: Converts a provided string to lowercase
Use Case:
Expects:
Input
Returns: Input, in lowercase
concat
Description: Combines 2 provided strings, into 1 string
Use Case:
Expects:
Input1
Input2
Returns: Input1Input2
random
Description: Returns a randomly generated UUID
Use Case:
Expects: None
Returns: A randomly generated UUID
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
Â
Â
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
Label | IRI |
---|---|
input string | |
endpoint url string |
Read local file as string
Returns the content of a local file as string
Function IRI:Â http://example.com/idlab/function/readFile
Label | IRI |
---|---|
input path |
True condition
Returns the value if the given boolean is true, else null
Function IRI:Â http://example.com/idlab/function/trueCondition
Label | IRI |
---|---|
boolean encoded as string | |
input string |
decide
Returns a given value if input is equal to another given value
Function IRI:Â http://example.com/idlab/function/decide
Label | IRI |
---|---|
input string | |
expected input string | |
result string |
escape
Escapes a string, with a mode parameter.
Function IRI:Â http://users.ugent.be/~bjdmeest/function/grel.ttl#escape
getMIMEType
Returns the MIME Type of a filename
Function IRI:Â http://example.com/idlab/function/getMIMEType
Label | IRI |
---|---|
input string |
Label | IRI |
---|---|
input value | http://users.ugent.be/~bjdmeest/function/grel.ttl#valueParameter |
listContainsElement
Returns true if the string is found in the list
Function IRI:Â http://example.com/idlab/function/listContainsElement
Label | IRI |
---|---|
list | |
input string |
mqlKeyUnquote
mqlKeyUnquote
Function IRI:Â http://users.ugent.be/~bjdmeest/function/grel.ttl#string_mqlKeyUnquote
not equal
Returns true if strings are not equal.
Function IRI:Â http://example.com/idlab/function/notEqual
This function does not take any arguments.
startsWith
startsWith
Function IRI:Â http://users.ugent.be/~bjdmeest/function/grel.ttl#string_startsWith
stringContainsOtherString
Returns true if a string is found in a delimited string.
Function IRI:Â http://example.com/idlab/function/stringContainsOtherString
Label | IRI |
---|---|
input string | |
other input string | |
delimiter |
toLowercase
Returns the input with all letters in lower case.
Function IRI:Â http://users.ugent.be/~bjdmeest/function/grel.ttl#toLowerCase
Label | IRI |
---|---|
input value | http://users.ugent.be/~bjdmeest/function/grel.ttl#valueParameter |
toUppercase
Returns the input with all letters in upper case.
Function IRI:Â http://users.ugent.be/~bjdmeest/function/grel.ttl#toUpperCase
Label | IRI |
---|---|
input value | http://users.ugent.be/~bjdmeest/function/grel.ttl#valueParameter |
toTitlecase
toTitlecase
Function IRI:Â http://users.ugent.be/~bjdmeest/function/grel.ttl#string_toTitlecase
Label | IRI |
---|---|
input value | http://users.ugent.be/~bjdmeest/function/grel.ttl#valueParameter |
toUpperCaseURL
Returns an uppercase, valid url.
Function IRI:Â http://example.com/idlab/function/toUpperCaseURL
Label | IRI |
---|---|
input string |
Label | IRI |
---|---|
input value | http://users.ugent.be/~bjdmeest/function/grel.ttl#valueParameter |