<commit_before>--
-- RDF View on relational data in BreeDB using R2RML mapping language.
--
-- Author: <NAME>
--

-- clear graphs
SPARQL CLEAR GRAPH <http://temp/germplasm>;
SPARQL CLEAR GRAPH <http://example.com/germplasm/>;

-- insert R2RML into a temporary graph
DB.DBA.TTLP('
@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix exa: <http://example.com/ns#> .
@prefix germplasm: <http://example.com/germplasm#> .
@prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
@prefix gterm: <http://purl.org/germplasm/germplasmTerm#> .

<exa:#TriplesMap1>
    a rr:TriplesMap;

    rr:logicalTable
    [
      rr:tableSchema "R2RML";
      rr:tableOwner  "TEST";
      rr:tableName   "pp_accession";
    ];

    rr:subjectMap
    [
      rr:template "http://example.com/germplasm/{accessionID}";
      rr:class gterm:GermplasmAccession;
      rr:graph <http://example.com/germplasm/>;
    ];

    rr:predicateObjectMap
    [
      rr:predicate gterm:germplasmID;
      rr:objectMap [ rr:column "accessionID" ];
    ];

    rr:predicateObjectMap
    [
      rr:predicate germplasm:name;
      rr:objectMap [ rr:column "accessionName" ];
    ];

    rr:predicateObjectMap
    [
      rr:predicate geo:lat;
      rr:objectMap [ rr:column "gpsLat"; rr:datatype xsd:decimal ];
    ];

    rr:predicateObjectMap
    [
      rr:predicate geo:long;
      rr:objectMap [ rr:column "gpsLong"; rr:datatype xsd:decimal ];
    ];

    rr:predicateObjectMap
    [
      rr:predicate geo:alt;
      rr:objectMap [ rr:column "elevation"; rr:datatype xsd:decimal ];
    ];
.
', 'http://temp/germplasm', 'http://temp/germplasm')
;

-- sanity checks
SELECT DB.DBA.R2RML_TEST('http://temp/germplasm');
DB.DBA.OVL_VALIDATE ('http://temp/germplasm', 'http://www.w3.org/ns/r2rml#OVL');

-- convert R2RML into Virtuoso's own Linked Data Views script
EXEC('SPARQL ' || DB.DBA.R2RML_MAKE_QM_FROM_G('http://temp/germplasm'));

-- graph queries

-- SPARQL SELECT * FROM <http://example.com/germplasm/> WHERE { ?s ?p ?o } LIMIT 10;
-- SPARQL SELECT * FROM <http://example.com/germplasm/> WHERE { ?s ?p ?o . FILTER(datatype(?o) = xsd:decimal) } LIMIT 10;
<commit_msg>Added namespace prefix for Darwin Core Terms and new column mappings.<commit_after>--
-- RDF View on relational data in BreeDB using R2RML mapping language.
--
-- Author: <NAME>
--

-- clear graphs
SPARQL CLEAR GRAPH <http://temp/germplasm>;
SPARQL CLEAR GRAPH <http://example.com/germplasm/>;

-- insert R2RML into a temporary graph
DB.DBA.TTLP('
@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix exa: <http://example.com/ns#> .
@prefix germplasm: <http://example.com/germplasm#> .
@prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
@prefix gterm: <http://purl.org/germplasm/germplasmTerm#> .
@prefix dwc: <http://rs.tdwg.org/dwc/terms/> .

<exa:#TriplesMap1>
    a rr:TriplesMap;

    rr:logicalTable
    [
      rr:tableSchema "R2RML";
      rr:tableOwner  "TEST";
      rr:tableName   "pp_accession";
    ];

    rr:subjectMap
    [
      rr:template "http://example.com/germplasm/{accessionID}";
      rr:class gterm:GermplasmAccession;
      rr:graph <http://example.com/germplasm/>;
    ];

    rr:predicateObjectMap
    [
      rr:predicate gterm:germplasmID;
      rr:objectMap [ rr:column "accessionID" ];
    ];

    rr:predicateObjectMap
    [
      rr:predicate gterm:germplasmIdentifier;
      rr:objectMap [ rr:column "accessionName" ];
    ];

    rr:predicateObjectMap
    [
      rr:predicate geo:lat;
      rr:objectMap [ rr:column "gpsLat"; rr:datatype xsd:decimal ];
    ];

    rr:predicateObjectMap
    [
      rr:predicate geo:long;
      rr:objectMap [ rr:column "gpsLong"; rr:datatype xsd:decimal ];
    ];

    rr:predicateObjectMap
    [
      rr:predicate geo:alt;
      rr:objectMap [ rr:column "elevation"; rr:datatype xsd:decimal ];
    ];

    rr:predicateObjectMap
    [
      rr:predicate dwc:countryCode;
      rr:objectMap [ rr:column "collectionSiteCountry" ];
    ];

    rr:predicateObjectMap
    [
      rr:predicate dwc:scientificName;
      rr:objectMap [ rr:column "speciesName" ];
    ];

    rr:predicateObjectMap
    [
      rr:predicate gterm:acquisitionDate;
      rr:objectMap [ rr:column "collectionDate"; rr:datatype xsd:date ];
    ];

    rr:predicateObjectMap
    [
      rr:predicate gterm:biologicalStatus;
      rr:objectMap [ rr:column "germplasmStatus" ];
    ];
.
', 'http://temp/germplasm', 'http://temp/germplasm')
;

-- sanity checks
SELECT DB.DBA.R2RML_TEST('http://temp/germplasm');
DB.DBA.OVL_VALIDATE ('http://temp/germplasm', 'http://www.w3.org/ns/r2rml#OVL');

-- convert R2RML into Virtuoso's own Linked Data Views script
EXEC('SPARQL ' || DB.DBA.R2RML_MAKE_QM_FROM_G('http://temp/germplasm'));

-- graph queries

-- SPARQL SELECT * FROM <http://example.com/germplasm/> WHERE { ?s ?p ?o } LIMIT 10;
-- SPARQL SELECT * FROM <http://example.com/germplasm/> WHERE { ?s ?p ?o . FILTER(datatype(?o) = xsd:decimal) } LIMIT 10;

{'fraction_non_alphanumeric': 0.1565728175005064, 'fraction_numerical': 0.009722503544662751, 'mean_word_length': 3.1426174496644297, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1069685', 'n_tokens_mistral': 2036, 'n_tokens_neox': 1894, 'n_words': 325}