# Functions: the TripleTrail vocabulary at http://w3id.org/tripletrail/fn#
# Written by ns/generate.py in the tripletrail-website repository; see https://tripletrail.eu/ns/fn/
@prefix tt: <http://w3id.org/tripletrail/fn#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix sd: <http://www.w3.org/ns/sparql-service-description#> .

<http://w3id.org/tripletrail/fn> a owl:Ontology ;
    rdfs:label "TripleTrail functions"@en ;
    rdfs:comment "TripleTrail's own SPARQL functions and aggregates: building IRIs and keys, strings, dates, lists, statistics, full-text search and vectors."@en ;
    rdfs:seeAlso <https://tripletrail.eu/ns/fn/> .

tt:camelCase a sd:Function ;
    rdfs:label "camelCase" ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:colognePhonetic a sd:Function ;
    rdfs:label "colognePhonetic" ;
    rdfs:comment "Kölner Phonetik, as Apache Commons Codec."@en ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:cosine a sd:Function ;
    rdfs:label "cosine" ;
    rdfs:comment "Cosine similarity, from -1 to 1; no value when a vector is all zeros. As Stardog's metric:cosineSimilarity."@en ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:daysBetween a sd:Function ;
    rdfs:label "daysBetween" ;
    rdfs:comment "Whole days, months, years from the first date to the second (negative when earlier)."@en ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:dot a sd:Function ;
    rdfs:label "dot" ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:encodeForIri a sd:Function ;
    rdfs:label "encodeForIri" ;
    rdfs:comment "R2RML's IRI-safe form of a value: every character but the iunreserved ones (ASCII letters, digits, -._~ and letters outside ASCII) percent-encoded; ENCODE_FOR_URI encodes letters outside ASCII too. Used by tripletrail lift --as-sparql."@en ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:first a sd:Aggregate ;
    rdfs:label "first" ;
    rdfs:comment "The first and last value in the order the rows reach the aggregate."@en ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:format a sd:Function ;
    rdfs:label "format" ;
    rdfs:comment "The same templates, not encoded; SPIF's {?1} placeholders work too. afn:sprintf is in D.1."@en ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:formatDate a sd:Function ;
    rdfs:label "formatDate" ;
    rdfs:comment "Java patterns on xsd:date, xsd:dateTime and xsd:time."@en ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:iri a sd:Function ;
    rdfs:label "iri" ;
    rdfs:comment "{0}, {1} (or {} in turn) filled with the arguments, percent-encoded; {{ / }} are braces."@en ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:jaroWinkler a sd:Function ;
    rdfs:label "jaroWinkler" ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:l2 a sd:Function ;
    rdfs:label "l2" ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:last a sd:Aggregate ;
    rdfs:label "last" ;
    rdfs:comment "The first and last value in the order the rows reach the aggregate."@en ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:leftPad a sd:Function ;
    rdfs:label "leftPad" ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:levenshtein a sd:Function ;
    rdfs:label "levenshtein" ;
    rdfs:comment "Code points; n-gram similarity is the Jaccard index of the n-gram sets (n = 2 by default)."@en ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:median a sd:Aggregate ;
    rdfs:label "median" ;
    rdfs:comment "The continuous median: the mean of the two middle values of an even count."@en ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:mode a sd:Aggregate ;
    rdfs:label "mode" ;
    rdfs:comment "The most frequent value, of any kind; of equally frequent values the first one met."@en ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:monthsBetween a sd:Function ;
    rdfs:label "monthsBetween" ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:ngramSimilarity a sd:Function ;
    rdfs:label "ngramSimilarity" ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:normalizeWhitespace a sd:Function ;
    rdfs:label "normalizeWhitespace" ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:parseDate a sd:Function ;
    rdfs:label "parseDate" ;
    rdfs:comment "Java patterns (dd.MM.yyyy, yyyy-MM-dd HH:mm, d MMM yyyy h:mm a, yyyyMMdd'T'HHmmssX). xsd:date without time fields, xsd:dateTime with them. English month and day names; the timezone is an offset (+01:00, Z, UTC)."@en ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:percentile a sd:Aggregate ;
    rdfs:label "percentile" ;
    rdfs:comment "p from 0 to 1, a constant; linear interpolation between the closest ranks, as SQL's PERCENTILE_CONT. Unbound outside 0..1."@en ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:rightPad a sd:Function ;
    rdfs:label "rightPad" ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:skolem a sd:Function ;
    rdfs:label "skolem" ;
    rdfs:comment "As RDFox SKOLEM: the prefix followed by 32 hex digits of the SHA-256 of the arguments' terms (kind, lexical form, datatype or language), so the same values always give the same IRI and 3 differs from \"3\". A relative prefix is resolved against the query's base."@en ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:snakeCase a sd:Function ;
    rdfs:label "snakeCase" ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:stddev a sd:Aggregate ;
    rdfs:label "stddev" ;
    rdfs:comment "Sample standard deviation, an xsd:double."@en ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:stddevPop a sd:Aggregate ;
    rdfs:label "stddevPop" ;
    rdfs:comment "Population standard deviation, an xsd:double."@en ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:titleCase a sd:Function ;
    rdfs:label "titleCase" ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:topK a sd:Aggregate ;
    rdfs:label "topK" ;
    rdfs:comment "The k largest numbers, largest first, as one string separated by spaces (as GROUP_CONCAT)."@en ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:trim a sd:Function ;
    rdfs:label "trim" ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:variance a sd:Aggregate ;
    rdfs:label "variance" ;
    rdfs:comment "Sample variance (divided by n - 1); unbound for one value."@en ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:varPop a sd:Aggregate ;
    rdfs:label "varPop" ;
    rdfs:comment "Population variance (divided by n)."@en ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:yearsBetween a sd:Function ;
    rdfs:label "yearsBetween" ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
tt:vector a rdfs:Datatype ;
    rdfs:label "vector" ;
    rdfs:isDefinedBy <http://w3id.org/tripletrail/fn> .
