src/p4l/settings.py
changeset 118 d33a072d974b
parent 117 0a4e7d6ebe80
child 119 ece69ca3ac24
equal deleted inserted replaced
117:0a4e7d6ebe80 118:d33a072d974b
   437 
   437 
   438 if not "SPARQL_REF_QUERIES" in locals():
   438 if not "SPARQL_REF_QUERIES" in locals():
   439     SPARQL_REF_QUERIES = {
   439     SPARQL_REF_QUERIES = {
   440         'subjects': {
   440         'subjects': {
   441             'url' : SPARQL_QUERY_ENDPOINT,
   441             'url' : SPARQL_QUERY_ENDPOINT,
   442             'filter' : """
   442             'filter' : (
   443                 PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
   443                 "PREFIX skos:<http://www.w3.org/2004/02/skos/core#> "
   444                 PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
   444                 "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
   445                 PREFIX owl:<http://www.w3.org/2002/07/owl#>
   445                 "PREFIX owl:<http://www.w3.org/2002/07/owl#> "
   446                 PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
   446                 "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "
   447                 SELECT DISTINCT ?uri ?label
   447                 "SELECT DISTINCT ?uri ?label "
   448                 WHERE {{
   448                 "WHERE {{ "
   449                     ?uri a skos:Concept.
   449                     "?uri a skos:Concept. "
   450                     ?uri skos:inScheme <http://skos.um.es/unescothes/CS000> .
   450                     "?uri skos:inScheme <http://skos.um.es/unescothes/CS000> . "
   451                     ?uri skos:prefLabel ?label.
   451                     "?uri skos:prefLabel ?label. "
   452                     FILTER (lang(?label) = {lang}).
   452                     "FILTER (lang(?label) = {lang}). "
   453                     ?uri skos:prefLabel ?lab.
   453                     "?uri skos:prefLabel ?lab. "
   454                     FILTER regex (str(?lab), ?reg, 'i').
   454                     "FILTER regex (str(?lab), ?reg, 'i'). "
   455                     FILTER (lang (?lab) = {lang}).
   455                     "FILTER (lang (?lab) = {lang}). "
   456                     BIND (STRLEN(STRBEFORE (str(?lab), ?reg)) AS ?place).
   456                     "BIND (STRLEN(STRBEFORE (str(?lab), ?reg)) AS ?place). "
   457                     BIND (STRLEN(STR(?lab)) AS ?len)
   457                     "BIND (STRLEN(STR(?lab)) AS ?len) "
   458                 }}
   458                 "}} "
   459                 ORDER BY ?place ?len ?lab
   459                 "ORDER BY ?place ?len ?lab"
   460             """,
   460             ),
   461             "root" : """
   461             "root" : (
   462                 PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
   462                 "PREFIX skos:<http://www.w3.org/2004/02/skos/core#> "
   463                 PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
   463                 "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
   464                 PREFIX owl:<http://www.w3.org/2002/07/owl#>
   464                 "PREFIX owl:<http://www.w3.org/2002/07/owl#> "
   465                 PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
   465                 "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "
   466                 SELECT DISTINCT ?uri ?label ?type
   466                 "SELECT DISTINCT ?uri ?label ?type "
   467                 WHERE {{
   467                 "WHERE {{ "
   468                     ?uri a skos:Collection ;
   468                     "?uri a skos:Collection ; "
   469                          skos:inScheme <http://skos.um.es/unescothes/CS000> ;
   469                          "skos:inScheme <http://skos.um.es/unescothes/CS000> ; "
   470                          skos:prefLabel|rdfs:label ?label ;
   470                          "skos:prefLabel|rdfs:label ?label ; "
   471                          rdf:type ?type .
   471                          "rdf:type ?type . "
   472                     FILTER (lang(?label) = {lang}). 
   472                     "FILTER (lang(?label) = {lang}). " 
   473                     FILTER NOT EXISTS {{ [skos:member ?uri] }}.
   473                     "FILTER NOT EXISTS {{ [skos:member ?uri] }}. "
   474                 }}
   474                 "}} "
   475                 ORDER BY ?label
   475                 "ORDER BY ?label"
   476             """,
   476             ),
   477             "childs" : """
   477             "childs" : (
   478                 PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
   478                 "PREFIX skos:<http://www.w3.org/2004/02/skos/core#> "
   479                 PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
   479                 "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
   480                 PREFIX owl:<http://www.w3.org/2002/07/owl#>
   480                 "PREFIX owl:<http://www.w3.org/2002/07/owl#> "
   481                 PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
   481                 "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "
   482                 SELECT DISTINCT ?uri ?label ?type
   482                 "SELECT DISTINCT ?uri ?label ?type "
   483                 WHERE {{
   483                 "WHERE {{ "
   484                   ?uri skos:inScheme <http://skos.um.es/unescothes/CS000> .
   484                   "?uri skos:inScheme <http://skos.um.es/unescothes/CS000> . "
   485                   {{ ?uri a ?type
   485                   "{{ ?uri a ?type "
   486                     FILTER (?type = skos:Collection || ?type = skos:Concept) }}.
   486                     "FILTER (?type = skos:Collection || ?type = skos:Concept) }}. "
   487                   ?root skos:narrower|skos:member ?uri.
   487                   "?root skos:narrower|skos:member ?uri. "
   488                   ?uri skos:prefLabel|rdfs:label ?label.
   488                   "?uri skos:prefLabel|rdfs:label ?label. "
   489                   FILTER (lang(?label) = {lang}).
   489                   "FILTER (lang(?label) = {lang}). "
   490                 }}
   490                 "}} "
   491                 ORDER BY ?label
   491                 "ORDER BY ?label"
   492             """,
   492             ),
   493             "child-count" : """
   493             "child-count" : (
   494                 PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
   494                 "PREFIX skos:<http://www.w3.org/2004/02/skos/core#> "
   495                 PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
   495                 "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
   496                 PREFIX owl:<http://www.w3.org/2002/07/owl#>
   496                 "PREFIX owl:<http://www.w3.org/2002/07/owl#> "
   497                 PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
   497                 "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "
   498                 SELECT (COUNT(?uri) as ?nb)
   498                 "SELECT (COUNT(?uri) as ?nb) "
   499                 WHERE {{
   499                 "WHERE {{ "
   500                     ?uri skos:inScheme <http://skos.um.es/unescothes/CS000> .
   500                     "?uri skos:inScheme <http://skos.um.es/unescothes/CS000> . "
   501                     ?root skos:narrower|skos:member ?uri.
   501                     "?root skos:narrower|skos:member ?uri. "
   502                 }}
   502                 "}}"
   503             """
   503             )
   504         },
   504         },
   505         'themes': {
   505         'themes': {
   506             'url' : SPARQL_QUERY_ENDPOINT,
   506             'url' : SPARQL_QUERY_ENDPOINT,
   507             'filter' : """
   507             'filter' : (
   508                 PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
   508                 "PREFIX skos:<http://www.w3.org/2004/02/skos/core#> "
   509                 PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
   509                 "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
   510                 PREFIX owl:<http://www.w3.org/2002/07/owl#>
   510                 "PREFIX owl:<http://www.w3.org/2002/07/owl#> "
   511                 PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
   511                 "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "
   512                 SELECT DISTINCT ?uri ?label
   512                 "SELECT DISTINCT ?uri ?label "
   513                 WHERE {{
   513                 "WHERE {{ "
   514                     ?uri a skos:Concept.
   514                     "?uri a skos:Concept. "
   515                     ?uri skos:inScheme <http://www.iiep.unesco.org/plan4learning/scheme/Themes> .
   515                     "?uri skos:inScheme <http://www.iiep.unesco.org/plan4learning/scheme/Themes> . "
   516                     ?uri skos:prefLabel ?label.
   516                     "?uri skos:prefLabel ?label. "
   517                     FILTER (lang(?label) = {lang}).
   517                     "FILTER (lang(?label) = {lang}). "
   518                     ?uri skos:prefLabel ?lab.
   518                     "?uri skos:prefLabel ?lab. "
   519                     FILTER regex (str(?lab), ?reg, 'i').
   519                     "FILTER regex (str(?lab), ?reg, 'i'). "
   520                     FILTER (lang (?lab) = {lang}).
   520                     "FILTER (lang (?lab) = {lang}). "
   521                     BIND (STRLEN(STRBEFORE (str(?lab), ?reg)) AS ?place).
   521                     "BIND (STRLEN(STRBEFORE (str(?lab), ?reg)) AS ?place). "
   522                     BIND (STRLEN(STR(?lab)) AS ?len)
   522                     "BIND (STRLEN(STR(?lab)) AS ?len) "
   523                 }}
   523                 "}} "
   524                 ORDER BY ?place ?len ?lab
   524                 "ORDER BY ?place ?len ?lab"
   525             """,
   525             ),
   526             'root' : """
   526             'root' : (
   527                 PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
   527                 "PREFIX skos:<http://www.w3.org/2004/02/skos/core#> "
   528                 PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
   528                 "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
   529                 PREFIX owl:<http://www.w3.org/2002/07/owl#>
   529                 "PREFIX owl:<http://www.w3.org/2002/07/owl#> "
   530                 PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
   530                 "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "
   531                 SELECT DISTINCT ?uri ?label ?type
   531                 "SELECT DISTINCT ?uri ?label ?type "
   532                 WHERE {{
   532                 "WHERE {{ "
   533                     ?uri a skos:Collection ;
   533                     "?uri a skos:Collection ; "
   534                          skos:inScheme <http://www.iiep.unesco.org/plan4learning/scheme/Themes> ;    
   534                          "skos:inScheme <http://www.iiep.unesco.org/plan4learning/scheme/Themes> ; "    
   535                          skos:prefLabel|rdfs:label ?label ;
   535                          "skos:prefLabel|rdfs:label ?label ; "
   536                          rdf:type ?type .
   536                          "rdf:type ?type . "
   537                     FILTER (lang(?label) = {lang}). 
   537                     "FILTER (lang(?label) = {lang}). " 
   538                     FILTER NOT EXISTS {{ [skos:member ?uri] }}
   538                     "FILTER NOT EXISTS {{ [skos:member ?uri] }} "
   539                 }}
   539                 "}} "
   540                 ORDER BY ?label
   540                 "ORDER BY ?label"
   541             """,
   541             ),
   542             'childs' : """
   542             'childs' : (
   543                 PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
   543                 "PREFIX skos:<http://www.w3.org/2004/02/skos/core#> "
   544                 PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
   544                 "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
   545                 PREFIX owl:<http://www.w3.org/2002/07/owl#>
   545                 "PREFIX owl:<http://www.w3.org/2002/07/owl#> "
   546                 PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
   546                 "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "
   547                 SELECT DISTINCT ?uri ?label ?type
   547                 "SELECT DISTINCT ?uri ?label ?type "
   548                 WHERE {{
   548                 "WHERE {{ "
   549                   ?uri skos:inScheme <http://www.iiep.unesco.org/plan4learning/scheme/Themes> .
   549                   "?uri skos:inScheme <http://www.iiep.unesco.org/plan4learning/scheme/Themes> . "
   550                   {{ ?uri a ?type
   550                   "{{ ?uri a ?type "
   551                     FILTER (?type = skos:Collection || ?type = skos:Concept) }}.
   551                     "FILTER (?type = skos:Collection || ?type = skos:Concept) }}. "
   552                   ?root skos:narrower|skos:member ?uri.
   552                   "?root skos:narrower|skos:member ?uri. "
   553                   ?uri skos:prefLabel|rdfs:label ?label.
   553                   "?uri skos:prefLabel|rdfs:label ?label. "
   554                   FILTER (lang(?label) = {lang}).
   554                   "FILTER (lang(?label) = {lang}). "
   555                 }}
   555                 "}} "
   556                 ORDER BY ?label
   556                 "ORDER BY ?label "
   557             """,
   557             ),
   558             'child-count' : """
   558             'child-count' : (
   559                 PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
   559                 "PREFIX skos:<http://www.w3.org/2004/02/skos/core#> "
   560                 PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
   560                 "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
   561                 PREFIX owl:<http://www.w3.org/2002/07/owl#>
   561                 "PREFIX owl:<http://www.w3.org/2002/07/owl#> "
   562                 PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
   562                 "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "
   563                 SELECT (COUNT(?uri) as ?nb)
   563                 "SELECT (COUNT(?uri) as ?nb) "
   564                 WHERE {{
   564                 "WHERE {{ "
   565                     ?uri skos:inScheme <http://www.iiep.unesco.org/plan4learning/scheme/Themes> .
   565                     "?uri skos:inScheme <http://www.iiep.unesco.org/plan4learning/scheme/Themes> . "
   566                     ?root skos:narrower|skos:member ?uri.
   566                     "?root skos:narrower|skos:member ?uri. "
   567                 }}
   567                 "}} "
   568             """
   568             )
   569         },
   569         },
   570         'countries': {
   570         'countries': {
   571             'url' : SPARQL_QUERY_ENDPOINT,
   571             'url' : SPARQL_QUERY_ENDPOINT,
   572             'filter' : """
   572             'filter' : (
   573                 PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
   573                 "PREFIX skos:<http://www.w3.org/2004/02/skos/core#> "
   574                 PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
   574                 "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
   575                 PREFIX owl:<http://www.w3.org/2002/07/owl#>
   575                 "PREFIX owl:<http://www.w3.org/2002/07/owl#> "
   576                 PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
   576                 "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "
   577                 SELECT DISTINCT ?uri ?label
   577                 "SELECT DISTINCT ?uri ?label "
   578                 WHERE {{
   578                 "WHERE {{ "
   579                     ?uri a skos:Concept.
   579                     "?uri a skos:Concept. "
   580                     ?uri skos:inScheme <http://skos.um.es/unescothes/CS000/Countries> .
   580                     "?uri skos:inScheme <http://skos.um.es/unescothes/CS000/Countries> . "
   581                     ?uri skos:prefLabel ?label.
   581                     "?uri skos:prefLabel ?label. "
   582                     FILTER (lang(?label) = {lang}).
   582                     "FILTER (lang(?label) = {lang}). "
   583                     ?uri skos:prefLabel ?lab.
   583                     "?uri skos:prefLabel ?lab. "
   584                     FILTER regex (str(?lab), ?reg, 'i').
   584                     "FILTER regex (str(?lab), ?reg, 'i'). "
   585                     FILTER (lang (?lab) = {lang}).
   585                     "FILTER (lang (?lab) = {lang}). "
   586                     BIND (STRLEN(STRBEFORE (str(?lab), ?reg)) AS ?place).
   586                     "BIND (STRLEN(STRBEFORE (str(?lab), ?reg)) AS ?place). "
   587                     BIND (STRLEN(STR(?lab)) AS ?len)
   587                     "BIND (STRLEN(STR(?lab)) AS ?len) "
   588                 }}
   588                 "}} "
   589                 ORDER BY ?place ?len ?lab
   589                 "ORDER BY ?place ?len ?lab"
   590             """,
   590             ),
   591             'root' : """
   591             'root' : (
   592                 PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
   592                 "PREFIX skos:<http://www.w3.org/2004/02/skos/core#> "
   593                 PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
   593                 "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
   594                 PREFIX owl:<http://www.w3.org/2002/07/owl#>
   594                 "PREFIX owl:<http://www.w3.org/2002/07/owl#> "
   595                 PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
   595                 "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "
   596                 SELECT DISTINCT ?uri ?label
   596                 "SELECT DISTINCT ?uri ?label "
   597                 WHERE {{
   597                 "WHERE {{ "
   598                     ?uri a skos:Concept ;
   598                     "?uri a skos:Concept ; "
   599                          skos:inScheme <http://skos.um.es/unescothes/CS000/Countries> ;    
   599                          "skos:inScheme <http://skos.um.es/unescothes/CS000/Countries> ; "    
   600                          skos:prefLabel ?label .
   600                          "skos:prefLabel ?label . "
   601                     FILTER (lang(?label) = {lang}). 
   601                     "FILTER (lang(?label) = {lang}). " 
   602                     FILTER NOT EXISTS {{ [skos:narrower ?uri] }}
   602                     "FILTER NOT EXISTS {{ [skos:narrower ?uri] }} "
   603                 }}
   603                 "}} "
   604                 ORDER BY ?label
   604                 "ORDER BY ?label "
   605             """,
   605             ),
   606             'childs' : """
   606             'childs' : (
   607                 PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
   607                 "PREFIX skos:<http://www.w3.org/2004/02/skos/core#> "
   608                 PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
   608                 "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
   609                 PREFIX owl:<http://www.w3.org/2002/07/owl#>
   609                 "PREFIX owl:<http://www.w3.org/2002/07/owl#> "
   610                 PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
   610                 "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "
   611                 SELECT DISTINCT ?uri ?label
   611                 "SELECT DISTINCT ?uri ?label "
   612                 WHERE {{
   612                 "WHERE {{ "
   613                   ?uri skos:inScheme <http://skos.um.es/unescothes/CS000/Countries> .
   613                   "?uri skos:inScheme <http://skos.um.es/unescothes/CS000/Countries> . "
   614                   {{ ?uri a ?type
   614                   "{{ ?uri a ?type "
   615                     FILTER (?type = skos:Collection || ?type = skos:Concept) }}.
   615                     "FILTER (?type = skos:Collection || ?type = skos:Concept) }}. "
   616                   ?root skos:narrower|skos:member ?uri.
   616                   "?root skos:narrower|skos:member ?uri. "
   617                   ?uri skos:prefLabel|rdfs:label ?label.
   617                   "?uri skos:prefLabel|rdfs:label ?label. "
   618                   FILTER (lang(?label) = {lang}).
   618                   "FILTER (lang(?label) = {lang}). "
   619                 }}
   619                 "}} "
   620                 ORDER BY ?label
   620                 "ORDER BY ?label"
   621             """,
   621             ),
   622             'child-count' : """
   622             'child-count' : (
   623                 PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
   623                 "PREFIX skos:<http://www.w3.org/2004/02/skos/core#> "
   624                 PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
   624                 "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
   625                 PREFIX owl:<http://www.w3.org/2002/07/owl#>
   625                 "PREFIX owl:<http://www.w3.org/2002/07/owl#> "
   626                 PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
   626                 "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "
   627                 SELECT (COUNT(?uri) as ?nb)
   627                 "SELECT (COUNT(?uri) as ?nb) "
   628                 WHERE {{
   628                 "WHERE {{ "
   629                     ?uri skos:inScheme <http://skos.um.es/unescothes/CS000/Countries> .
   629                     "?uri skos:inScheme <http://skos.um.es/unescothes/CS000/Countries> . "
   630                     ?root skos:narrower|skos:member ?uri.
   630                     "?root skos:narrower|skos:member ?uri. "
   631                 }}
   631                 "}}"
   632             """
   632             )
   633         },
   633         },
   634         'languages': {
   634         'languages': {
   635             'url' : SPARQL_QUERY_ENDPOINT,
   635             'url' : SPARQL_QUERY_ENDPOINT,
   636             'filter' : """
   636             'filter' : (
   637                 PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
   637                 "PREFIX skos:<http://www.w3.org/2004/02/skos/core#> "
   638                 PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
   638                 "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
   639                 PREFIX owl:<http://www.w3.org/2002/07/owl#>
   639                 "PREFIX owl:<http://www.w3.org/2002/07/owl#> "
   640                 PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
   640                 "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "
   641                 SELECT DISTINCT ?uri ?label
   641                 "SELECT DISTINCT ?uri ?label "
   642                 WHERE {{
   642                 "WHERE {{ "
   643                     ?uri a skos:Concept.
   643                     "?uri a skos:Concept. "
   644                     ?uri skos:inScheme <http://www.iiep.unesco.org/plan4learning/scheme/Languages> .
   644                     "?uri skos:inScheme <http://www.iiep.unesco.org/plan4learning/scheme/Languages> . "
   645                     ?uri skos:prefLabel ?label.
   645                     "?uri skos:prefLabel ?label. "
   646                     FILTER (lang(?label) = {lang}).
   646                     "FILTER (lang(?label) = {lang}). "
   647                     ?uri skos:prefLabel ?lab.
   647                     "?uri skos:prefLabel ?lab. "
   648                     FILTER regex (str(?lab), ?reg, 'i').
   648                     "FILTER regex (str(?lab), ?reg, 'i'). "
   649                     FILTER (lang (?lab) = {lang}).
   649                     "FILTER (lang (?lab) = {lang}). "
   650                     BIND (STRLEN(STRBEFORE (str(?lab), ?reg)) AS ?place).
   650                     "BIND (STRLEN(STRBEFORE (str(?lab), ?reg)) AS ?place). "
   651                     BIND (STRLEN(STR(?lab)) AS ?len)
   651                     "BIND (STRLEN(STR(?lab)) AS ?len) "
   652                 }}
   652                 "}} "
   653                 ORDER BY ?place ?len ?lab
   653                 "ORDER BY ?place ?len ?lab"
   654             """,
   654             ),
   655             'root' : """
   655             'root' : (
   656                 PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
   656                 "PREFIX skos:<http://www.w3.org/2004/02/skos/core#> "
   657                 PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
   657                 "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
   658                 PREFIX owl:<http://www.w3.org/2002/07/owl#>
   658                 "PREFIX owl:<http://www.w3.org/2002/07/owl#> "
   659                 PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
   659                 "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "
   660                 SELECT DISTINCT ?uri ?label
   660                 "SELECT DISTINCT ?uri ?label "
   661                 WHERE {{
   661                 "WHERE {{ "
   662                     ?uri a skos:Concept ;
   662                     "?uri a skos:Concept ; "
   663                          skos:inScheme <http://www.iiep.unesco.org/plan4learning/scheme/Languages> ;    
   663                          "skos:inScheme <http://www.iiep.unesco.org/plan4learning/scheme/Languages> ;     "
   664                          skos:prefLabel ?label .
   664                          "skos:prefLabel ?label . "
   665                     FILTER (lang(?label) = {lang}). 
   665                     "FILTER (lang(?label) = {lang}).  "
   666                     FILTER NOT EXISTS {{ [skos:narrower ?uri] }}
   666                     "FILTER NOT EXISTS {{ [skos:narrower ?uri] }} "
   667                 }}
   667                 "}} "
   668                 ORDER BY ?label
   668                 "ORDER BY ?label"
   669             """
   669             )
   670         },
   670         },
   671         'projects': {
   671         'projects': {
   672             'url' : SPARQL_QUERY_ENDPOINT,
   672             'url' : SPARQL_QUERY_ENDPOINT,
   673             'filter' : """
   673             'filter' : (
   674                 PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
   674                 "PREFIX skos:<http://www.w3.org/2004/02/skos/core#> "
   675                 PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
   675                 "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
   676                 PREFIX owl:<http://www.w3.org/2002/07/owl#>
   676                 "PREFIX owl:<http://www.w3.org/2002/07/owl#> "
   677                 PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
   677                 "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "
   678                 SELECT DISTINCT ?uri ?label ?acro
   678                 "SELECT DISTINCT ?uri ?label ?acro "
   679                 WHERE {{
   679                 "WHERE {{ "
   680                     ?uri a skos:Concept.
   680                     "?uri a skos:Concept. "
   681                     ?uri skos:inScheme <http://www.iiep.unesco.org/plan4learning/scheme/Projects> .
   681                     "?uri skos:inScheme <http://www.iiep.unesco.org/plan4learning/scheme/Projects> . "
   682                     ?uri skos:prefLabel ?label.
   682                     "?uri skos:prefLabel ?label. "
   683                     ?uri skos:prefLabel ?lab.
   683                     "?uri skos:prefLabel ?lab. "
   684                     OPTIONAL {{ ?uri skos:altLabel ?acro }}.
   684                     "OPTIONAL {{ ?uri skos:altLabel ?acro }}. "
   685                     FILTER regex (str(?lab), ?reg, 'i').
   685                     "FILTER regex (str(?lab), ?reg, 'i'). "
   686                     BIND (STRLEN(STRBEFORE (str(?lab), ?reg)) AS ?place).
   686                     "BIND (STRLEN(STRBEFORE (str(?lab), ?reg)) AS ?place). "
   687                     BIND (STRLEN(STR(?lab)) AS ?len)
   687                     "BIND (STRLEN(STR(?lab)) AS ?len) "
   688                 }}
   688                 "}} "
   689                 ORDER BY ?place ?len ?lab
   689                 "ORDER BY ?place ?len ?lab"
   690             """,
   690             ),
   691             'root' : """
   691             'root' : (
   692                 PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
   692                 "PREFIX skos:<http://www.w3.org/2004/02/skos/core#> "
   693                 PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
   693                 "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
   694                 PREFIX owl:<http://www.w3.org/2002/07/owl#>
   694                 "PREFIX owl:<http://www.w3.org/2002/07/owl#> "
   695                 PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
   695                 "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "
   696                 SELECT DISTINCT ?uri ?label ?acro
   696                 "SELECT DISTINCT ?uri ?label ?acro "
   697                 WHERE {{
   697                 "WHERE {{ "
   698                     ?uri a skos:Concept ;
   698                     "?uri a skos:Concept ; "
   699                     skos:inScheme <http://www.iiep.unesco.org/plan4learning/scheme/Projects> ;    
   699                     "skos:inScheme <http://www.iiep.unesco.org/plan4learning/scheme/Projects> ;     "
   700                     skos:prefLabel ?label .
   700                     "skos:prefLabel ?label . "
   701                     OPTIONAL {{ ?uri skos:altLabel ?acro }}
   701                     "OPTIONAL {{ ?uri skos:altLabel ?acro }} "
   702                 }}
   702                 "}} "
   703                 ORDER BY ?label
   703                 "ORDER BY ?label"
   704             """
   704             )
   705         },
   705         },
   706         'organizations': {
   706         'organizations': {
   707             'url' : SPARQL_QUERY_ENDPOINT,
   707             'url' : SPARQL_QUERY_ENDPOINT,
   708             'filter' : """
   708             'filter' : (
   709                 PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
   709                 "PREFIX skos:<http://www.w3.org/2004/02/skos/core#> "
   710                 PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
   710                 "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
   711                 PREFIX owl:<http://www.w3.org/2002/07/owl#>
   711                 "PREFIX owl:<http://www.w3.org/2002/07/owl#> "
   712                 PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
   712                 "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "
   713                 SELECT DISTINCT ?uri ?label ?acro
   713                 "SELECT DISTINCT ?uri ?label ?acro "
   714                 WHERE {{
   714                 "WHERE {{ "
   715                     ?uri a skos:Concept.
   715                     "?uri a skos:Concept. "
   716                     ?uri skos:inScheme <http://www.iiep.unesco.org/plan4learning/scheme/Organizations> .
   716                     "?uri skos:inScheme <http://www.iiep.unesco.org/plan4learning/scheme/Organizations> . "
   717                     ?uri skos:prefLabel ?label.
   717                     "?uri skos:prefLabel ?label. "
   718                     ?uri skos:prefLabel ?lab.
   718                     "?uri skos:prefLabel ?lab. "
   719                     OPTIONAL {{ ?uri skos:altLabel ?acro }}.
   719                     "OPTIONAL {{ ?uri skos:altLabel ?acro }}. "
   720                     FILTER regex (str(?lab), ?reg, 'i').
   720                     "FILTER regex (str(?lab), ?reg, 'i'). "
   721                     BIND (STRLEN(STRBEFORE (str(?lab), ?reg)) AS ?place).
   721                     "BIND (STRLEN(STRBEFORE (str(?lab), ?reg)) AS ?place). "
   722                     BIND (STRLEN(STR(?lab)) AS ?len)
   722                     "BIND (STRLEN(STR(?lab)) AS ?len) "
   723                 }}
   723                 "}} "
   724                 ORDER BY ?place ?len ?lab
   724                 "ORDER BY ?place ?len ?lab"
   725             """,
   725             ),
   726             'root' : """
   726             'root' : (
   727                 PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
   727                 "PREFIX skos:<http://www.w3.org/2004/02/skos/core#> "
   728                 PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
   728                 "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
   729                 PREFIX owl:<http://www.w3.org/2002/07/owl#>
   729                 "PREFIX owl:<http://www.w3.org/2002/07/owl#> "
   730                 PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
   730                 "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "
   731                 SELECT DISTINCT ?uri ?label ?acro
   731                 "SELECT DISTINCT ?uri ?label ?acro "
   732                 WHERE {{
   732                 "WHERE {{ "
   733                     ?uri a skos:Concept ;
   733                     "?uri a skos:Concept ; "
   734                          skos:inScheme <http://www.iiep.unesco.org/plan4learning/scheme/Organizations> ;    
   734                          "skos:inScheme <http://www.iiep.unesco.org/plan4learning/scheme/Organizations> ;     "
   735                          skos:prefLabel ?label .
   735                          "skos:prefLabel ?label . "
   736                     OPTIONAL {{ ?uri skos:altLabel ?acro }}
   736                     "OPTIONAL {{ ?uri skos:altLabel ?acro }} "
   737                 }}
   737                 "}} "
   738                 ORDER BY ?label
   738                 "ORDER BY ?label"
   739             """
   739             )
   740         },
   740         },
   741         'types': {
   741         'types': {
   742             'url' : SPARQL_QUERY_ENDPOINT,
   742             'url' : SPARQL_QUERY_ENDPOINT,
   743             'filter' : """
   743             'filter' : (
   744                 PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
   744                 "PREFIX skos:<http://www.w3.org/2004/02/skos/core#> "
   745                 PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
   745                 "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
   746                 PREFIX owl:<http://www.w3.org/2002/07/owl#>
   746                 "PREFIX owl:<http://www.w3.org/2002/07/owl#> "
   747                 PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
   747                 "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "
   748                 SELECT DISTINCT ?uri ?label
   748                 "SELECT DISTINCT ?uri ?label "
   749                 WHERE {{
   749                 "WHERE {{ "
   750                     ?uri a skos:Concept.
   750                     "?uri a skos:Concept. "
   751                     ?uri skos:inScheme <http://www.iiep.unesco.org/plan4learning/scheme/DocumentType> .
   751                     "?uri skos:inScheme <http://www.iiep.unesco.org/plan4learning/scheme/DocumentType> . "
   752                     ?uri skos:prefLabel ?label.
   752                     "?uri skos:prefLabel ?label. "
   753                     FILTER (lang(?label) = {lang}).
   753                     "FILTER (lang(?label) = {lang}). "
   754                     ?uri skos:prefLabel ?lab.
   754                     "?uri skos:prefLabel ?lab. "
   755                     FILTER regex (str(?lab), ?reg, 'i').
   755                     "FILTER regex (str(?lab), ?reg, 'i'). "
   756                     FILTER (lang (?lab) = {lang}).
   756                     "FILTER (lang (?lab) = {lang}). "
   757                     BIND (STRLEN(STRBEFORE (str(?lab), ?reg)) AS ?place).
   757                     "BIND (STRLEN(STRBEFORE (str(?lab), ?reg)) AS ?place). "
   758                     BIND (STRLEN(STR(?lab)) AS ?len)
   758                     "BIND (STRLEN(STR(?lab)) AS ?len) "
   759                 }}
   759                 "}} "
   760                 ORDER BY ?place ?len ?lab
   760                 "ORDER BY ?place ?len ?lab"
   761             """,
   761             ),
   762             'root' : """
   762             'root' : (
   763                 PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
   763                 "PREFIX skos:<http://www.w3.org/2004/02/skos/core#> "
   764                 PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
   764                 "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
   765                 PREFIX owl:<http://www.w3.org/2002/07/owl#>
   765                 "PREFIX owl:<http://www.w3.org/2002/07/owl#> "
   766                 PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
   766                 "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "
   767                 SELECT DISTINCT ?uri ?label
   767                 "SELECT DISTINCT ?uri ?label "
   768                 WHERE {{
   768                 "WHERE {{ "
   769                     ?uri a skos:Concept ;
   769                     "?uri a skos:Concept ; "
   770                          skos:inScheme <http://www.iiep.unesco.org/plan4learning/scheme/DocumentType> ;    
   770                          "skos:inScheme <http://www.iiep.unesco.org/plan4learning/scheme/DocumentType> ;     "
   771                          skos:prefLabel ?label .
   771                          "skos:prefLabel ?label . "
   772                     FILTER (lang(?label) = {lang}). 
   772                     "FILTER (lang(?label) = {lang}).  "
   773                     FILTER NOT EXISTS {{ [skos:narrower ?uri] }}
   773                     "FILTER NOT EXISTS {{ [skos:narrower ?uri] }} "
   774                 }}
   774                 "}} "
   775                 ORDER BY ?label
   775                 "ORDER BY ?label "
   776             """
   776             )
   777         },
   777         },
   778         'audiences': {
   778         'audiences': {
   779             'url' : SPARQL_QUERY_ENDPOINT,
   779             'url' : SPARQL_QUERY_ENDPOINT,
   780             "filter" : "",
   780             "filter" : "",
   781             "root" : "",
   781             "root" : "",