9 Replies Latest reply: Mar 8, 2012 6:23 AM by 525819 RSS

    Syntax of RDFS predicates and objects in triples?

    525819
      Hi,

      I am trying to create and load triples into the staging table from a flat file. My triples are like:

      <myProject:Observation>     rdfs:type     rdfs:Class
      <myProject:MouseWeight>     rdfs:subClassOf     <myProject:Observation>

      Will Oracle recognize this syntax of RDFS predicates and objects [and hence use them in a right way for inferencing, etc..]? Or should I use URL-based syntax, e.g. <http://www.w3.org/2000/01/rdf-schema#Class> instead of rdfs:Class?

      Thanks for your answers,
      Dmitry.
        • 1. Re: Syntax of RDFS predicates and objects in triples?
          JorgeB-Oracle
          Hi,

          In order to use sql*loader to load semantic data into a staging tabble, you need to have the data in N-Triple format.

          Reference to Oracle Doc:
          http://docs.oracle.com/cd/E11882_01/appdev.112/e25609/sdo_rdf_concepts.htm#CHDCEFIE

          This is an example of the N-Triple format:

          <http://www.w3.org/2001/sw/RDFCore/ntriples/> <http://purl.org/dc/elements/1.1/creator> "Dave Beckett" .
          <http://www.w3.org/2001/sw/RDFCore/ntriples/> <http://purl.org/dc/elements/1.1/creator> "Art Barstow" .
          <http://www.w3.org/2001/sw/RDFCore/ntriples/> <http://purl.org/dc/elements/1.1/publisher> <http://www.w3.org/> .

          Reference:
          http://www.w3.org/2001/sw/RDFCore/ntriples/

          Regards!
          Jorge
          • 2. Re: Syntax of RDFS predicates and objects in triples?
            525819
            Hi Jorge,

            Thanks for your reply.
            I did read the reference you pointed out, but could not find there how to explain lines like this:

            http://www.example.org/family/motherOf rdfs:domain http://www.example.org/family/Female .
            <http://www.example.org/family/fatherOf> <rdfs:range> <http://www.example.org/family/Male> .

            These lines I found in $ORACLE_HOME/md/demo/network/rdf_demos/bulkload3.nt file. This file is supposed to be loaded by SQL loader using bulkload.ctl as the control file.


            Actually, the sense of my initial question is how one can specify the standard RDFS vocabulary constructs (like rdfs:Class, rdfs:subClassOf, etc..) in N-triples, and hence make use of Oracle's built-in knowledge of RDFS.
            • 3. Re: Syntax of RDFS predicates and objects in triples?
              JorgeB-Oracle
              Hi,

              Oh, I see, that's a very good question. The SEM_MATCH already knows these prefixes/namespaces

              ('orardf', 'http://xmlns.oracle.com/rdf/')
              ('orageo', 'http://xmlns.oracle.com/rdf/geo/')
              ('owl', 'http://www.w3.org/2002/07/owl#')
              ('rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#')
              ('rdfs', 'http://www.w3.org/2000/01/rdf-schema#')
              ('xsd', 'http://www.w3.org/2001/XMLSchema#')

              I would assume the loader know them as well and that is why bulkload3.nt loads ok with only stating the prefix in <rdfs:range>

              I would leave this open to someone else to comment if that assumption is correct and maybe also to ask if it is possible to add more default namespaces.

              Regards!
              Jorge
              • 4. Re: Syntax of RDFS predicates and objects in triples?
                sdas
                During loading, the following well-known prefixes are supported: rdf:, rdfs:, owl:, and xsd:

                If you are using SQL*Loader, you need to use the following control file: $ORACLE_HOME/md/demo/network/rdf_demos/bulkload.ctl

                If you are using 11.2.0.3, you can also use External Tables instead of SQL*Loader. For more details, please see:
                http://docs.oracle.com/cd/E11882_01/appdev.112/e25609/sdo_rdf_concepts.htm#CIHIIEAC
                • 5. Re: Syntax of RDFS predicates and objects in triples?
                  525819
                  Hi Souri,

                  Thanks for the answer. Yes, I use 11.2.0.3.

                  I found that it is mandatory to enclose RDFS vocabulary constructs in angle brackets, like <rdfs:Class>. If not, loading triples to model using

                  SEM_APIS.BULK_LOAD_FROM_STAGING_TABLE(
                  model_name => 'IMIDIA',
                  table_owner => 'IMIDIA',
                  table_name => 'STABLE',
                  flags => 'IZC_JOIN_HINT=USE_HASH MBV_JOIN_HINT=USE_HASH');

                  produces an error:

                  Error report:
                  ORA-13199: During MBV: [07-MAR-12 04.22.08.947402000 PM +01:00]
                  ORA-13199: Element Parse Error: Invalid value [debug-2 info: 6865821466516486776,,,,] (value: rdfs:Class) [
                  ORA-06512: at "MDSYS.MD", line 1723
                  ORA-06512: at "MDSYS.MDERR", line 17
                  ORA-06512: at "MDSYS.SDO_RDF", line 29
                  ORA-06512: at line 1
                  ORA-06512: at "MDSYS.SDO_RDF_INTERNAL", line 3117

                  ]
                  ORA-06512: at "MDSYS.MD", line 1723
                  ORA-06512: at "MDSYS.MDERR", line 17
                  ORA-06512: at "MDSYS.SDO_RDF_INTERNAL", line 3205
                  ORA-06512: at "MDSYS.SDO_RDF_INTERNAL", line 6223
                  ORA-06512: at "MDSYS.SDO_RDF", line 707
                  ORA-06512: at "MDSYS.RDF_APIS", line 893
                  ORA-06512: at line 2
                  13199. 00000 - "%s"
                  *Cause:    This is an internal error.
                  *Action:   Contact Oracle Support Services.


                  Will e.g. <rdfs:Class> be recognized and used correctly, despite it is enclosed in angle brackets as a user-defined resource?

                  Thanks again,
                  Dmitry.

                  Edited by: user522816 on Mar 7, 2012 8:39 AM
                  • 6. Re: Syntax of RDFS predicates and objects in triples?
                    sdas
                    Dmitry,

                    This error indicates that the staging table content is incorrect. Specifically, it contains the unexpanded RDF term, rdfs:Class, instead of the fully expanded form. Bulk load API expects that all URIs in the staging table are fully expanded (absolute URIs).

                    If sqlldr is used, with bulkload.ctl as the control file, to load the staging table then any references to prefixed terms such as rdfs:Class should automatically get stored in the staging table in a fully expanded form. Please truncate the staging table and re-load it using sqlldr/bulkload.ctl.

                    If you still see this error and need more clarifications, please feel free to send me email directly.

                    Thanks,
                    - Souri.
                    • 7. Re: Syntax of RDFS predicates and objects in triples?
                      sdas
                      Dmitry,

                      A few things:

                      1) We strongly recommend that the instead of using the following triples (from bulkload3.nt):

                      http://www.example.org/family/motherOf rdfs:domain http://www.example.org/family/Female .
                      <http://www.example.org/family/fatherOf> <rdfs:range> <http://www.example.org/family/Male> .

                      use:

                      <http://www.example.org/family/motherOf> rdfs:domain <http://www.example.org/family/Female> .
                      <http://www.example.org/family/fatherOf> rdfs:range <http://www.example.org/family/Male> .

                      2) Please note that <rdfs:range> is no way related to rdfs:range and should not be used because:

                      <rdfs:range> will not get expanded,
                      but
                      rdfs:range will be expanded by sqlldr to: <http://www.w3.org/2000/01/rdf-schema#range>

                      So, in general, use either rdfs:range OR <http://www.w3.org/2000/01/rdf-schema#range>, but NOT <rdfs:range>

                      3) When invoking sem_apis.bulk_load_from_staging_table, consider using the PARSE option, specified as flags => ' PARSE ' (See documentation for more details). This would identify any syntax or value error earlier, during the LBV phase, instead of the MBV phase.

                      Thanks,
                      - Souri.
                      • 8. Re: Syntax of RDFS predicates and objects in triples?
                        sdas
                        1) Here is an updated script for bulk load for 11.2.0.3:

                        -- Assuming semantic network has been created, user rdfuser has been created, RDF model family has been created

                        -- load from flat file to staging table
                        create table stable (
                        RDF$STC_sub varchar2(4000) not null,
                        RDF$STC_pred varchar2(4000) not null,
                        RDF$STC_obj varchar2(4000) not null
                        );

                        host sqlldr userid=rdfuser/rdfuser control=bulkload.ctl data=family.nt direct=true discardmax=0 bad=d0.bad discard=d0.rej log=d0.log errors=1000000

                        -- MDSYS needs some privileges for doing bulk-load
                        grant INSERT on family_rdf_data to MDSYS;
                        grant SELECT on stable to MDSYS;

                        -- invoke bulk-load from staging table
                        exec sem_apis.bulk_load_from_staging_table('FAMILY','rdfuser','stable', flags => ' PARSE ');

                        2) Here is sample RDF data (in file family.nt):

                        <http://x.org/family/John> <http://x.org/family/fatherOf> <http://x.org/family/Suzie> .
                        <http://x.org/family/John> <http://x.org/family/fatherOf> <http://x.org/family/Matt> .
                        <http://x.org/family/Janice> <http://x.org/family/motherOf> <http://x.org/family/Suzie> .
                        <http://x.org/family/Janice> <http://x.org/family/motherOf> <http://x.org/family/Matt> .
                        <http://x.org/family/Sammy> <http://x.org/family/fatherOf> <http://x.org/family/Cathy> .
                        <http://x.org/family/Sammy> <http://x.org/family/fatherOf> <http://x.org/family/Jack> .
                        <http://x.org/family/Suzie> <http://x.org/family/motherOf> <http://x.org/family/Cathy> .
                        <http://x.org/family/Suzie> <http://x.org/family/motherOf> <http://x.org/family/Jack> .
                        <http://x.org/family/Matt> <http://x.org/family/fatherOf> <http://x.org/family/Tom> .
                        <http://x.org/family/Matt> <http://x.org/family/fatherOf> <http://x.org/family/Cindy> .
                        <http://x.org/family/Martha> <http://x.org/family/motherOf> <http://x.org/family/Tom> .
                        <http://x.org/family/Martha> <http://x.org/family/motherOf> <http://x.org/family/Cindy> .
                        <http://x.org/family/Cathy> <http://x.org/family/sisterOf> <http://x.org/family/Jack> .
                        <http://x.org/family/Jack> rdf:type <http://x.org/family/Male> .
                        <http://x.org/family/Tom> rdf:type <http://x.org/family/Male> .
                        <http://x.org/family/Cindy> rdf:type <http://x.org/family/Female> .
                        <http://x.org/family/Person> rdf:type rdfs:Class .
                        <http://x.org/family/Male> rdfs:subClassOf <http://x.org/family/Person> .
                        <http://x.org/family/Female> rdfs:subClassOf <http://x.org/family/Person> .
                        <http://x.org/family/siblingOf> rdf:type rdf:Property .
                        <http://x.org/family/parentOf> rdf:type rdf:Property .
                        <http://x.org/family/brotherOf> rdfs:subPropertyOf <http://x.org/family/siblingOf> .
                        <http://x.org/family/sisterOf> rdfs:subPropertyOf <http://x.org/family/siblingOf> .
                        <http://x.org/family/brotherOf> rdfs:domain <http://x.org/family/Male> .
                        <http://x.org/family/sisterOf> rdfs:domain <http://x.org/family/Female> .
                        <http://x.org/family/fatherOf> rdfs:subPropertyOf <http://x.org/family/parentOf> .
                        <http://x.org/family/motherOf> rdfs:subPropertyOf <http://x.org/family/parentOf> .
                        <http://x.org/family/fatherOf> rdfs:domain <http://x.org/family/Male> .
                        <http://x.org/family/motherOf> rdfs:domain <http://x.org/family/Female> .
                        <http://x.org/family/Cathy> <http://x.org/family/height> "5.8"^^xsd:decimal .
                        <http://x.org/family/Jack> <http://x.org/family/height> "6"^^xsd:integer .
                        <http://x.org/family/Tom> <http://x.org/family/height> "05.75"^^xsd:decimal .
                        <http://x.org/family/Cindy> <http://x.org/family/height> "06.00"^^xsd:decimal .
                        • 9. Re: Syntax of RDFS predicates and objects in triples?
                          525819
                          Hi Souri,

                          Thanks a lot for the informative answers.
                          I really suggest to reflect your answers in the Semantic Technologies Developer's Guide.

                          Dmitry.