TizianaPasciuto / CTP_Ontology

Creative Commons Attribution 4.0 International
0 stars 0 forks source link

Testing of the SPARQL Query tab in JENA or similar for the CTP core ontology; #16

Closed riccardoAlbertoni closed 3 months ago

riccardoAlbertoni commented 7 months ago

The Testing of the SPARQL Query tab in Protege for the CTP core ontology failed; We are going to check the query using other technologies.

_Originally posted by @TizianaPasciuto in https://github.com/TizianaPasciuto/CTP_Ontology/issues/5#issuecomment-2012750370_

riccardoAlbertoni commented 6 months ago

We can use the bin/sparql command

  Control
      --explain              Explain and log query execution
      --repeat=N or N,M      Do N times or N warmup and then M times (use for timing to overcome start up costs of Java)
      --optimize=            Turn the query optimizer on or off (default: on)
  Time
      --time                 Time the operation
  Query Engine
      --engine=EngineName    Register another engine factory[ref]
      --unengine=EngineName   Unregister an engine factory
  Dataset
      --data=FILE            Data for the dataset - triple or quad formats
      --graph=FILE           Graph for default graph of the datset
      --namedGraph=FILE      Add a graph into the dataset as a named graph
  Results
      --results=             Results format (Result set: text, XML, JSON, CSV, TSV; Graph: RDF serialization)
      --desc=                Assembler description file
  Query
      --query, --file        File containing a query
      --syntax, --in         Syntax of the query
      --base                 Base URI for the query
  Symbol definition
      --set                  Set a configuration symbol to a value
  General
      -v   --verbose         Verbose
      -q   --quiet           Run with minimal output
      --debug                Output information for debugging
      --help
      --version              Version information
      --strict               Operate in strict SPARQL mode (no extensions of any kind)
riccardoAlbertoni commented 6 months ago

I have created a new branch testingTheSparqlQuery , in which,

I have created

I have merged the core ontology and all the instances, using the following command in the directory for Mac riot CTP_Ontology_core.ttl Instances/CTP_Ontology_core_Instance* >TestSparql/20240508/CTPcatWhole.n3 for Windows riot CTP_Ontology_core.ttl Instances\CTP_Ontology_core_Instance* >TestSparql\20240508\CTPcatWhole.n3

Then we can execute the sparql query for Mac sparql --data=TestSparql/20240508/CTPcatWhole.n3 --query=TestSparql/20240508/CQs/CQ2.sparql for Windows sparql.bat --data=TestSparql\20240508\CTPcatWhole.n3 --query=TestSparql\20240508\CQs\CQ2.sparql

which returns

10:10:28 WARN  riot            :: [line: 858, col: 67] Bad IRI: <https://w3id.org/ctp/ncf#Fabbroni_16:_Reale_Museo_di_fisica_e_storia_naturale:_modelli_anatomici._[1770]> Code: 0/ILLEGAL_CHARACTER in FRAGMENT: The character violates the grammar rules for URIs/IRIs.
10:10:28 WARN  riot            :: [line: 868, col: 67] Bad IRI: <https://w3id.org/ctp/ncf#Fabbroni_16:_Reale_Museo_di_fisica_e_storia_naturale:_modelli_anatomici._[1770]> Code: 0/ILLEGAL_CHARACTER in FRAGMENT: The character violates the grammar rules for URIs/IRIs.
10:10:28 WARN  riot            :: [line: 925, col: 71] Lexical form 'Poisons' not valid for datatype XSD date
10:10:28 WARN  riot            :: [line: 976, col: 64] Lexical form '1751' not valid for datatype XSD date
10:10:28 WARN  riot            :: [line: 983, col: 64] Lexical form '1765' not valid for datatype XSD date
10:10:28 WARN  riot            :: [line: 986, col: 64] Lexical form '1770' not valid for datatype XSD date
10:10:28 WARN  riot            :: [line: 993, col: 67] Lexical form '1772-02' not valid for datatype XSD date
10:10:28 WARN  riot            :: [line: 1000, col: 67] Lexical form '1772-03' not valid for datatype XSD date
10:10:28 WARN  riot            :: [line: 1003, col: 64] Lexical form '1783' not valid for datatype XSD date
10:10:28 WARN  riot            :: [line: 1006, col: 64] Lexical form '1800' not valid for datatype XSD date
10:10:28 WARN  riot            :: [line: 1009, col: 64] Lexical form '1801' not valid for datatype XSD date
10:10:28 WARN  riot            :: [line: 1033, col: 1 ] Bad IRI: <https://w3id.org/ctp/ncf#Fabbroni_16:_Reale_Museo_di_fisica_e_storia_naturale:_modelli_anatomici._[1770]> Code: 0/ILLEGAL_CHARACTER in FRAGMENT: The character violates the grammar rules for URIs/IRIs.
10:10:28 WARN  riot            :: [line: 1034, col: 1 ] Bad IRI: <https://w3id.org/ctp/ncf#Fabbroni_16:_Reale_Museo_di_fisica_e_storia_naturale:_modelli_anatomici._[1770]> Code: 0/ILLEGAL_CHARACTER in FRAGMENT: The character violates the grammar rules for URIs/IRIs.
10:10:28 WARN  riot            :: [line: 1035, col: 1 ] Bad IRI: <https://w3id.org/ctp/ncf#Fabbroni_16:_Reale_Museo_di_fisica_e_storia_naturale:_modelli_anatomici._[1770]> Code: 0/ILLEGAL_CHARACTER in FRAGMENT: The character violates the grammar rules for URIs/IRIs.
10:10:28 WARN  riot            :: [line: 1036, col: 1 ] Bad IRI: <https://w3id.org/ctp/ncf#Fabbroni_16:_Reale_Museo_di_fisica_e_storia_naturale:_modelli_anatomici._[1770]> Code: 0/ILLEGAL_CHARACTER in FRAGMENT: The character violates the grammar rules for URIs/IRIs.
10:10:28 WARN  riot            :: [line: 1037, col: 1 ] Bad IRI: <https://w3id.org/ctp/ncf#Fabbroni_16:_Reale_Museo_di_fisica_e_storia_naturale:_modelli_anatomici._[1770]> Code: 0/ILLEGAL_CHARACTER in FRAGMENT: The character violates the grammar rules for URIs/IRIs.
10:10:28 WARN  riot            :: [line: 1038, col: 1 ] Bad IRI: <https://w3id.org/ctp/ncf#Fabbroni_16:_Reale_Museo_di_fisica_e_storia_naturale:_modelli_anatomici._[1770]> Code: 0/ILLEGAL_CHARACTER in FRAGMENT: The character violates the grammar rules for URIs/IRIs.
10:10:28 WARN  riot            :: [line: 1039, col: 1 ] Bad IRI: <https://w3id.org/ctp/ncf#Fabbroni_16:_Reale_Museo_di_fisica_e_storia_naturale:_modelli_anatomici._[1770]> Code: 0/ILLEGAL_CHARACTER in FRAGMENT: The character violates the grammar rules for URIs/IRIs.
10:10:28 WARN  riot            :: [line: 1040, col: 1 ] Bad IRI: <https://w3id.org/ctp/ncf#Fabbroni_16:_Reale_Museo_di_fisica_e_storia_naturale:_modelli_anatomici._[1770]> Code: 0/ILLEGAL_CHARACTER in FRAGMENT: The character violates the grammar rules for URIs/IRIs.
10:10:28 WARN  riot            :: [line: 1041, col: 1 ] Bad IRI: <https://w3id.org/ctp/ncf#Fabbroni_16:_Reale_Museo_di_fisica_e_storia_naturale:_modelli_anatomici._[1770]> Code: 0/ILLEGAL_CHARACTER in FRAGMENT: The character violates the grammar rules for URIs/IRIs.
10:10:28 WARN  riot            :: [line: 1042, col: 1 ] Bad IRI: <https://w3id.org/ctp/ncf#Fabbroni_16:_Reale_Museo_di_fisica_e_storia_naturale:_modelli_anatomici._[1770]> Code: 0/ILLEGAL_CHARACTER in FRAGMENT: The character violates the grammar rules for URIs/IRIs.
10:10:28 WARN  riot            :: [line: 1314, col: 81] Lexical form '1075' not valid for datatype XSD date
10:10:28 WARN  riot            :: [line: 1317, col: 81] Lexical form '1101' not valid for datatype XSD date
10:10:28 WARN  riot            :: [line: 1320, col: 81] Lexical form '1200' not valid for datatype XSD date
10:10:28 WARN  riot            :: [line: 1323, col: 81] Lexical form '1201' not valid for datatype XSD date
10:10:28 WARN  riot            :: [line: 1326, col: 81] Lexical form '1300' not valid for datatype XSD date
10:10:28 WARN  riot            :: [line: 1329, col: 81] Lexical form '1550' not valid for datatype XSD date
10:10:28 WARN  riot            :: [line: 1471, col: 94] Lexical form '2023.01.01' not valid for datatype XSD date
10:10:28 WARN  riot            :: [line: 1563, col: 91] Lexical form '2023.01.01' not valid for datatype XSD date
10:10:28 WARN  riot            :: [line: 1656, col: 72] Lexical form '1850' not valid for datatype XSD date
10:10:28 WARN  riot            :: [line: 1672, col: 72] Lexical form '2023' not valid for datatype XSD date
------------------------------------------------------------------------------------------------------------------------------------------------------------------
| ThematicPath                                                               | Theme                                                                             |
==================================================================================================================================================================
| <https://w3id.org/ctp/ncf#Anatomy_tp>                                      | <https://w3id.org/ctp/ncf#Animal_physics_theme>                                   |
| <https://w3id.org/ctp/santiagodecompostela#Road_to_Santiago_de_Compostela> | <https://w3id.org/ctp/santiagodecompostela#Santiago_de_Compostela_pilgrim_routes> |
| <https://w3id.org/ctp/ncf#Anatomy_tp>                                      | <https://w3id.org/ctp/ncf#Anatomy_theme>                                          |
| <https://w3id.org/ctp/transitions#Enterprise_section>                      | <https://w3id.org/ctp/transitions#Enterprise_theme>                               |
| <https://w3id.org/ctp/transitions#Transitions>                             | <https://w3id.org/ctp/transitions#Transitions_theme>                              |
| <https://w3id.org/ctp/transitions#Work_section>                            | <https://w3id.org/ctp/transitions#Work_theme>                                     |
| <https://w3id.org/ctp/ncf#Poisons_tp>                                      | <https://w3id.org/ctp/ncf#Poisons_theme>                                          |
| <https://w3id.org/ctp/transitions#Society_section>                         | <https://w3id.org/ctp/transitions#Society_theme>                                  |
------------------------------------------------------------------------------------------------------------------------------------------------------------------
riccardoAlbertoni commented 6 months ago

What is next? we should consider to

riccardoAlbertoni commented 6 months ago
  • How to query having the OWL reasoning materialized?

The RDFs Reasoning can be materialized through Riot option --rdfs=FileConOntologia

For example, we could use the core as the ontology and apply it on the union of all instances, with a command similar to the following

riot --rdfs=CTP_Ontology_core.ttl --formatted=TTL Instances/CTP_Ontology_core_Instance* >TestSparql/20240508/CTPcatWhole_formatted.ttl

assuming to have run riot --formatted=TTL Instances/CTP_Ontology_core_Instance* >TestSparql/20240508/CTPcatWhole_formatted.ttl

we can try to see what statements have been added via RDFs Reasoning via riot TestSparql/20240508/CTPcatWhole_formatted.ttl TestSparql/20240508/CTPcatWhole_formatted_reasoned.ttl