Re: AW: List inherited properties
Comments inline > Hi Lorenz > > Thanks for the tip. > > Option A: OWL_DL_MEM_TRANS_INF > > In theory using OWL_DL_MEM_TRANS_INF rather than OWL_DL_MEM works -- I've > managed to print to the console the inherited properties. In theory, both should work. The latter is even more expressive in terms of reasoning. > In practice though, when writing the resulting model to a file, I get a > BadURIException*. But that must be something in your data. Assuming that during parsing this error doesn't occur, I guess you modify die model in your application with some malformed URI or something and expensive URI checks aren't done here. Andy indeed knows better what might happen. But again, code + data would clearly be necessary for further debugging. > Exception in thread "main" org.apache.jena.shared.BadURIException: Only > well-formed absolute URIrefs can be included in RDF/XML output: > <4507792:16831e08128:-78f2> Code: 10/SCHEME_MUST_START_WITH_LETTER in SCHEME: > The scheme component must start with a letter. Do you create any RDF resources during runtime of the app? > That's a bit puzzling because the version of the code that uses OWL_DL_MEM > filter out vectors and does not have this problem (perhaps my code on the > inferred version does not filter enough of these vectors). I wanted to > explore this option further to see where these crop up, and have tried : What is a "vector" and what means "filter out" ? OWL_DL_MEM is more expressive than OWL_DL_TRANS_INF, so it would "produce" or better said entail more triples. > > 1- with a catch, but the resulting file is empty (0KB); > > 2- to allow BadURIs, as per ***, but I am not sure how to set the option for > the default jena writer -- so that the following line of code would work: > model2.write(new FileOutputStream(file), "RDF/XML"); > > > Option B: OWL_DL_MEM_RDFS_INF > > I have also tried OWL_DL_MEM_RDFS_INF but I get a > ConcurrentModificationException for a part of the code** that copies the > ontology header. You copy what into what? And why? > When running the code without this part, I get an out of memory error > even after setting the hip to 4096M. How large is your dataset? Pretty printing the RDF/XML is expensive as it has to build the whole XML tree in-memory. RDF/XML plain supports streams so should be more memory efficient. > > > > I'm afraid I have once more not given enough nor relevant info -- but any > suggestions (in particular on on how to do 2- above) is welcome. > > Cheers, Jos > > > * > Exception in thread "main" org.apache.jena.shared.BadURIException: Only > well-formed absolute URIrefs can be included in RDF/XML output: > <4507792:16831e08128:-78f2> Code: 10/SCHEME_MUST_START_WITH_LETTER in SCHEME: > The scheme component must start with a letter. > > ** > /*HEADER*/ > > while (ontologyProperties.hasNext()) { > > Statement thisProperty = ontologyProperties.next(); > System.out.println("Item: " + thisProperty); > ont2.addProperty(thisProperty.getPredicate(), > thisProperty.getObject()); > > } > > *** > https://jena.apache.org/documentation/io/rdfxml_howto.html > > > Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit > exceeded > > > > > > -Ursprüngliche Nachricht- > Von: Lorenz B. > Gesendet: Dienstag, 8. Januar 2019 08:28 > An: users@jena.apache.org > Betreff: Re: List inherited properties > > Good Morning. > > Next time it would be better to show the Java code instead of the pseudo code > to better see which models you're using and which method exactly you're > calling to get the properties. > > Therefore, I'm just making guesses now (if those are wrong, any help from my > side might/will probably be wrong): > > - you have an OntClass > - you call listDeclaredProperties() > > So, let's have a look and read the Javadoc of this method carefully: > >> Note that many cases of determining whether a property is associated >> with a class depends on RDFS or OWL reasoning. This method may >> therefore return complete results only in models that have an attached >> reasoner. > As stated here, do you use an inference model? With at least RDFS simple as > level of entailment? Otherwise, it can't work - reasoning is clearly > necessary here and this isn't enabled of you just use a default model. > > And as usual, the documentation [1] is pretty good. > > [1] https://jena.apache.org/documentation/inference/ > >> A beginner's problem: >>
AW: List inherited properties
Hi there I seem to have managed Option A in my previous mail by having: model2.write(new FileOutputStream(file), "RDF/XML"); as follows: RDFWriter w = model2.getWriter("RDF/XML"); w.setProperty("allowBadURIs","true"); w.write(model2,new FileOutputStream(file), "RDF/XML"); Jos -Ursprüngliche Nachricht- Von: Jos Lehmann Gesendet: Mittwoch, 9. Januar 2019 11:14 An: users@jena.apache.org Betreff: AW: List inherited properties Hi Lorenz Thanks for the tip. Option A: OWL_DL_MEM_TRANS_INF In theory using OWL_DL_MEM_TRANS_INF rather than OWL_DL_MEM works -- I've managed to print to the console the inherited properties. In practice though, when writing the resulting model to a file, I get a BadURIException*. That's a bit puzzling because the version of the code that uses OWL_DL_MEM filter out vectors and does not have this problem (perhaps my code on the inferred version does not filter enough of these vectors). I wanted to explore this option further to see where these crop up, and have tried : 1- with a catch, but the resulting file is empty (0KB); 2- to allow BadURIs, as per ***, but I am not sure how to set the option for the default jena writer -- so that the following line of code would work: model2.write(new FileOutputStream(file), "RDF/XML"); Option B: OWL_DL_MEM_RDFS_INF I have also tried OWL_DL_MEM_RDFS_INF but I get a ConcurrentModificationException for a part of the code** that copies the ontology header. When running the code without this part, I get an out of memory error even after setting the hip to 4096M. I'm afraid I have once more not given enough nor relevant info -- but any suggestions (in particular on on how to do 2- above) is welcome. Cheers, Jos * Exception in thread "main" org.apache.jena.shared.BadURIException: Only well-formed absolute URIrefs can be included in RDF/XML output: <4507792:16831e08128:-78f2> Code: 10/SCHEME_MUST_START_WITH_LETTER in SCHEME: The scheme component must start with a letter. ** /*HEADER*/ while (ontologyProperties.hasNext()) { Statement thisProperty = ontologyProperties.next(); System.out.println("Item: " + thisProperty); ont2.addProperty(thisProperty.getPredicate(), thisProperty.getObject()); } *** https://jena.apache.org/documentation/io/rdfxml_howto.html Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded -Ursprüngliche Nachricht- Von: Lorenz B. Gesendet: Dienstag, 8. Januar 2019 08:28 An: users@jena.apache.org Betreff: Re: List inherited properties Good Morning. Next time it would be better to show the Java code instead of the pseudo code to better see which models you're using and which method exactly you're calling to get the properties. Therefore, I'm just making guesses now (if those are wrong, any help from my side might/will probably be wrong): - you have an OntClass - you call listDeclaredProperties() So, let's have a look and read the Javadoc of this method carefully: > Note that many cases of determining whether a property is associated > with a class depends on RDFS or OWL reasoning. This method may > therefore return complete results only in models that have an attached > reasoner. As stated here, do you use an inference model? With at least RDFS simple as level of entailment? Otherwise, it can't work - reasoning is clearly necessary here and this isn't enabled of you just use a default model. And as usual, the documentation [1] is pretty good. [1] https://jena.apache.org/documentation/inference/ > A beginner's problem: > > WHAT I'M DOING > 1- I am importing ontology/model O1 and ontology/model O2 into > ontology/model O3 > 2- In O3 I make class C1 (from O1) a subclass of class C2 (from O2) > 3- When querying ontology/model O3 for C1.listProperties() I would > expect to be provided with C1's as well as C2's properties -- but I am > not > > > QUESTION > How do I list all of C1's properties, both its own (from O1) as well those it > inherits from its superclasses (including C2) ? > > > Cheers, Jos > > -- Lorenz Bühmann AKSW group, University of Leipzig Group: http://aksw.org - semantic web research center
AW: List inherited properties
Hi Lorenz Thanks for the tip. Option A: OWL_DL_MEM_TRANS_INF In theory using OWL_DL_MEM_TRANS_INF rather than OWL_DL_MEM works -- I've managed to print to the console the inherited properties. In practice though, when writing the resulting model to a file, I get a BadURIException*. That's a bit puzzling because the version of the code that uses OWL_DL_MEM filter out vectors and does not have this problem (perhaps my code on the inferred version does not filter enough of these vectors). I wanted to explore this option further to see where these crop up, and have tried : 1- with a catch, but the resulting file is empty (0KB); 2- to allow BadURIs, as per ***, but I am not sure how to set the option for the default jena writer -- so that the following line of code would work: model2.write(new FileOutputStream(file), "RDF/XML"); Option B: OWL_DL_MEM_RDFS_INF I have also tried OWL_DL_MEM_RDFS_INF but I get a ConcurrentModificationException for a part of the code** that copies the ontology header. When running the code without this part, I get an out of memory error even after setting the hip to 4096M. I'm afraid I have once more not given enough nor relevant info -- but any suggestions (in particular on on how to do 2- above) is welcome. Cheers, Jos * Exception in thread "main" org.apache.jena.shared.BadURIException: Only well-formed absolute URIrefs can be included in RDF/XML output: <4507792:16831e08128:-78f2> Code: 10/SCHEME_MUST_START_WITH_LETTER in SCHEME: The scheme component must start with a letter. ** /*HEADER*/ while (ontologyProperties.hasNext()) { Statement thisProperty = ontologyProperties.next(); System.out.println("Item: " + thisProperty); ont2.addProperty(thisProperty.getPredicate(), thisProperty.getObject()); } *** https://jena.apache.org/documentation/io/rdfxml_howto.html Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded -Ursprüngliche Nachricht- Von: Lorenz B. Gesendet: Dienstag, 8. Januar 2019 08:28 An: users@jena.apache.org Betreff: Re: List inherited properties Good Morning. Next time it would be better to show the Java code instead of the pseudo code to better see which models you're using and which method exactly you're calling to get the properties. Therefore, I'm just making guesses now (if those are wrong, any help from my side might/will probably be wrong): - you have an OntClass - you call listDeclaredProperties() So, let's have a look and read the Javadoc of this method carefully: > Note that many cases of determining whether a property is associated > with a class depends on RDFS or OWL reasoning. This method may > therefore return complete results only in models that have an attached > reasoner. As stated here, do you use an inference model? With at least RDFS simple as level of entailment? Otherwise, it can't work - reasoning is clearly necessary here and this isn't enabled of you just use a default model. And as usual, the documentation [1] is pretty good. [1] https://jena.apache.org/documentation/inference/ > A beginner's problem: > > WHAT I'M DOING > 1- I am importing ontology/model O1 and ontology/model O2 into > ontology/model O3 > 2- In O3 I make class C1 (from O1) a subclass of class C2 (from O2) > 3- When querying ontology/model O3 for C1.listProperties() I would > expect to be provided with C1's as well as C2's properties -- but I am > not > > > QUESTION > How do I list all of C1's properties, both its own (from O1) as well those it > inherits from its superclasses (including C2) ? > > > Cheers, Jos > > -- Lorenz Bühmann AKSW group, University of Leipzig Group: http://aksw.org - semantic web research center
Re: List inherited properties
Good Morning. Next time it would be better to show the Java code instead of the pseudo code to better see which models you're using and which method exactly you're calling to get the properties. Therefore, I'm just making guesses now (if those are wrong, any help from my side might/will probably be wrong): - you have an OntClass - you call listDeclaredProperties() So, let's have a look and read the Javadoc of this method carefully: > Note that many cases of determining whether a property is associated > with a class depends on RDFS or OWL reasoning. This method may > therefore return complete results only in models that have an attached > reasoner. As stated here, do you use an inference model? With at least RDFS simple as level of entailment? Otherwise, it can't work - reasoning is clearly necessary here and this isn't enabled of you just use a default model. And as usual, the documentation [1] is pretty good. [1] https://jena.apache.org/documentation/inference/ > A beginner's problem: > > WHAT I'M DOING > 1- I am importing ontology/model O1 and ontology/model O2 into ontology/model > O3 > 2- In O3 I make class C1 (from O1) a subclass of class C2 (from O2) > 3- When querying ontology/model O3 for C1.listProperties() I would expect to > be provided with C1's as well as C2's properties -- but I am not > > > QUESTION > How do I list all of C1's properties, both its own (from O1) as well those it > inherits from its superclasses (including C2) ? > > > Cheers, Jos > > -- Lorenz Bühmann AKSW group, University of Leipzig Group: http://aksw.org - semantic web research center
List inherited properties
A beginner's problem: WHAT I'M DOING 1- I am importing ontology/model O1 and ontology/model O2 into ontology/model O3 2- In O3 I make class C1 (from O1) a subclass of class C2 (from O2) 3- When querying ontology/model O3 for C1.listProperties() I would expect to be provided with C1's as well as C2's properties -- but I am not QUESTION How do I list all of C1's properties, both its own (from O1) as well those it inherits from its superclasses (including C2) ? Cheers, Jos