3 Replies Latest reply on Mar 15, 2010 2:22 PM by 758212

    Batch Loading of Semantic Data

    758212
      I am trying to load an N3 file into an Oracle 11g instance. Basically it's the same data that is in the family example (here: http://tinyurl.com/yl9zqtl) that I put into an N3 file. I'm executing a command like below (according to: http://tinyurl.com/yjp4olv)


      java -Ddb.user=<dbuser> -Ddb.password=<pass> -Ddb.host=127.0.0.1 -Ddb.port=11521 -Ddb.sid=oracle -cp sdordf.jar:ojdbc6.jar oracle.spatial.rdf.client.BatchLoader family.n3 family_rdf_data rdf_tablespace fam

      The "family.n3" file looks like:

      @prefix fam: <http://www.example.org/family.rdf#> .
      @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

      fam:John rdf:type fam:Male;
           fam:fatherOf fam:Suzie;
           fam:fatherOf fam:Matt.

      fam:Janice fam:motherOf fam:Suzie;
           fam:motherOf fam:Matt.

      fam:Sammy fam:fatherOf fam:Cathy;
           fam:fatherOf fam:Jack.

      ...etc


      I then get an error message from the BatchLoader program:

      Batch loading started...
      Subject: @prefix
      Property: rdf:
      Object: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

      Loading up to rows = 2
      java.lang.StringIndexOutOfBoundsException: String index out of range: -1
           at java.lang.String.substring(String.java:1937)
           at oracle.spatial.rdf.client.NTripleTokenizer.parse(NTripleTokenizer.java:71)
           at oracle.spatial.rdf.client.NTripleConverter.loadNTriple(NTripleConverter.java:534)
           at oracle.spatial.rdf.client.BatchLoader.main(BatchLoader.java:302)


      It errors on the first line if I remove the second line above. Am I doing something wrong? I pasted the N3 file into an N3 validator (found here: http://www.rdfabout.com/demo/validator/) and it validates, so the N3 file at least looks like it is working fine.

      Thanks,

      Ryan
        • 1. Re: Batch Loading of Semantic Data
          alwu-Oracle
          Hi Ryan,

          The batch loader in sdordf.jar does not accept N3 format. You can try one of the following
          - using Jena Adaptor (which accepts N3, NTRIPLE, RDF/XML), or
          - convert N3 to NTriple format and re-try the batch loading.

          Cheers,

          Zhe Wu
          • 2. Re: Batch Loading of Semantic Data
            681909
            Ryan,

            you can use the jena library to load an oracle model directly from an N3 file:

            GraphOracleSem oracleGraph = new GraphOracleSem(oracle, "myModel", true);
            oracleModel = new ModelOracleSem(oracleGraph);
            InputStream is = FileManager.get().open("xxx.n3");
            // read file contents into oracleModel
            oracleModel.read(is, "", "N3");
            is.close();
                                
            System.out.printf("Size of Oracle model is %d\n", oracleModel.size());
            oracleModel.close();
            oracleGraph.close();

            Edited by: reb57 on Mar 5, 2010 1:04 PM
            1 person found this helpful
            • 3. Re: Batch Loading of Semantic Data
              758212
              Switching to the Jena API solved the problem. Thanks for the help!

              -Ryan