Re: How I handle "Null Pointer Exception"

2017-01-17 Thread Lorenz B.

> OntModel model2=ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM);
>InputStream in =FileManager.get().open("F://20-8.owl");
> if (in==null) {
> throw new IllegalArgumentException( "File: " +  " not
> found");
> }  model2.read(in,"");
>
>  String ns="
> http://www.semanticweb.org/t/ontologies/2016/7/myOWL#;;
>
>OntProperty favcat=model2.getOntProperty(ns+ "BestCategory");
> String  name=jTextField1.getText();
> Individual indiv = user1.createIndividual(ns + name);
>   RDFNode phFav=indiv.getPropertyValue(favcat);
>  if (phFav!=null){
>   Literal l1=phFav.asLiteral();
If BestCategory is an object property, why do you cast the value as
literal?!
>
>s1=l1.toString(); }
>  }
> if (s1=="CatPhysics"){
>  JOptionPane.showMessageDialog(null, "Physics");
>   }
>
> The rule itself is
>
> String rule ="[rule1: ( ?x http://www.semanticweb.org/
> t/ontologies/2016/7/myOWL#Physics_Preferred_Category  ?cat1 )" +
>  "( ?x http://www.semanticweb.org/t/ontologies/2016/7/myOWL#
> Chem_Preferred_Category  ?cat2 )" +
> "( ?x http://www.semanticweb.org/t/ontologies/2016/7/myOWL#Geo_
> Preferred_Category  ?cat3 )" +
> "greaterThan(?cat1,?cat2), greaterThan(?cat1,?cat3)"
>  + " ->  (?x  http://www.semanticweb.org/t/
> ontologies/2016/7/myOWL#BestCategory   http://www.semanticweb.org/t/
> ontologies/2016/7/myOWL#BestCategory#Physics   )]";
>
>
> The BestCategory is object property.
>
> Regards
>
>
> On Tue, Jan 17, 2017 at 8:16 PM, Andy Seaborne  wrote:
>
>> A Complete, Minimal Example please.
>>
>>
>> Partial code, no data is not complete.
>> It must compile and run to be complete.
>>
>> Minimal means only what is necessary to ask the question not the whole
>> data or whole application.
>>
>> Andy
>>
>> On 17/01/17 17:14, Sidra shah wrote:
>>
>>> I am surprise that when there is no value in BestCategory, it gives me no
>>> error and when the rule executes and value comes in BestCategory, it gives
>>> me now *"RequiredLiteralException*"
>>>
>>> The code I used here is
>>>
>>>  OntProperty favcat=model2.getOntProperty(ns+ "BestCategory");
>>>
>>> RDFNode phFav=indiv.getPropertyValue(favcat);
>>>  if (phFav!=null){
>>>   Literal l1=phFav.asLiteral();
>>>
>>>s1=l1.toString();}
>>>
>>> if (s1=="CatPhysics"){
>>>  JOptionPane.showMessageDialog(null, "Physics");
>>>   }
>>>
>>> Best regards
>>>
>>> On Tue, Jan 17, 2017 at 5:53 PM, Sidra shah 
>>> wrote:
>>>
>>> Hello Chris, thanks a lot for your suggestion.
 Best regards.

 On Tue, Jan 17, 2017 at 5:37 PM, Chris Dollin <
 chris.dol...@epimorphics.com> wrote:


> On 17/01/17 13:30, Sidra shah wrote:
>
> Hi Lorenz, I am sorry but with much regards, you discussed here the
>> problem, not the solution  :) :)
>>
>> I know this if there is no value, there must be Null exception,
>>
>>
> This is not true.
>
> but can you suggest me a way where we dodge the compiler
>
>>
> No "dodging" of the compiler is required. Instead, just write
> perfectly ordinary code that tests to see if the result of
> getPropertyValue is null, and take one action if it isn't and
> a different one if it is.
>
> There's nothing special about this. You don't need to use
> break (which is for escaping from loops); just an if
> with suitable then and else parts.
>
> I know this is more a Java problem, but any help I will appreciate.
>
>>
> Find someone /local/ doing the same or similar course and talk to
> them (and have them talk to you) about programming and this
> problem. I don't mean copy each other's work; I mean use each
> other to understand what the problem is about and how the code
> works. Each of you will know things that the other doesn't; share.
>
> Chris
>
> --
> "He could not weigh up which was worse and so tried not to think about
> either."
> /The Spellgrinder's
> Apprentice/
>
> Epimorphics Ltd, http://www.epimorphics.com
> Registered address: Court Lodge, 105 High Street, Portishead, Bristol
> BS20 6PT
> Epimorphics Ltd. is a limited company registered in England (number
> 7016688)
>
>

-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center



Re: Line Numbers

2017-01-17 Thread Conal Tuohy
if you want to keep track of the provenance of data, you can use named
graphs. If your graphs are small (fine-grained) enough then this may give
you the necessary precision to refer any triple back to its source.

On 18/01/2017 7:49 am, "Grahame Grieve" 
wrote:

> >
> > Add a stage to parsing which built a Triple to location map
> (ParserProfile
> > receives the line and column number).
> >
> > The look up in that map to find the source of the triple.  Imperfect in
> > the general case but for working on a single file it might do what you
> are
> > looking for.
> >
>
> yes I could do that. I'll add it to my list.
>
> Grahame
>


Re: Line Numbers

2017-01-17 Thread Grahame Grieve
>
> Add a stage to parsing which built a Triple to location map (ParserProfile
> receives the line and column number).
>
> The look up in that map to find the source of the triple.  Imperfect in
> the general case but for working on a single file it might do what you are
> looking for.
>

yes I could do that. I'll add it to my list.

Grahame


Re: Line Numbers

2017-01-17 Thread Andy Seaborne

You could even ...

Add a stage to parsing which built a Triple to location map 
(ParserProfile receives the line and column number).


The look up in that map to find the source of the triple.  Imperfect in 
the general case but for working on a single file it might do what you 
are looking for.


Triples are safe to use as hash keys.

Andy

On 17/01/17 20:23, A. Soroka wrote:

There are several answers.

There is no reason to suppose that any given triple actually derives from a 
file at all. It might have been created programmatically, or by inference, or 
from SPARQL, amongst many possible other means.

You are suggesting the carriage of a really large amount of metadata all 
throughout Jena's internals. The performance implications would be big, and 
entirely negative.

Andy has given you a really good road to go down if what you want is more detailed 
parsing metadata for, as you say, "reporting issues with the content". You can 
take off that metadata and record it elsewhere or record it in RDF in various ways. 
Perhaps you can tell us a little more about your use case and we can help you find a more 
targeted technique for it.

---
A. Soroka
The University of Virginia Library


On Jan 17, 2017, at 3:14 PM, Grahame Grieve 
 wrote:

hi

Yes replacing a library is not simple, but I thought I'd still make the
offer. Other advantages... no, it's just a JSON parser.


You did seem to be asking for a way to get from a triple in a graph to

the line where it was read, and that is not possible. There is no such
association.

why not? the library could provide a way, and retain the association.

Grahame


On Wed, Jan 18, 2017 at 6:58 AM, A. Soroka  wrote:


Replacing the JSON library in use is a considerably bigger proposition
than working with the one we now use in a different way. Are there other
advantages to using your custom code? We want to stick to well-supported
dependencies unless there is a convincing argument otherwise.

As for Turtle, I believe you can take a look at LangTurtleBase to see what
might be done. Keep in mind that there's not necessarily a precise way to
understand what line produces an error-- it might occur in the interaction
between tokens on more than one line.

---
A. Soroka
The University of Virginia Library


On Jan 17, 2017, at 2:42 PM, Grahame Grieve <

grah...@healthintersections.com.au> wrote:


well, I care about turtle and json-ld.  I can contribute a json library
that preserves line numbers when the json is parsed, since the main

stream

ones don't.

Grahame


On Wed, Jan 18, 2017 at 5:38 AM, A. Soroka  wrote:


That will depend a bit on the language. For example, JSON parsing

doesn't

occur directly in Jena, Jena uses a library that parses from JSON to

Java

objects and then works with those objects:

org.apache.jena.riot.lang.JsonLDReader.read(InputStream, String,
ContentType, StreamRDF, Context)

In some other cases, it seems like it should be possible. Do you have a
specific language in mind?

---
A. Soroka
The University of Virginia Library


On Jan 16, 2017, at 6:48 AM, Grahame Grieve <

grah...@healthintersections.com.au> wrote:


Can the Jena parser maintain a link between the triples and the line

number

from which are sourced in the original file? This is really useful for
reporting issues with the content

Grahame


--
-
http://www.healthintersections.com.au / grahame@healthintersections.

com.au

/ +61 411 867 065






--
-
http://www.healthintersections.com.au / grahame@healthintersections.

com.au

/ +61 411 867 065






--
-
http://www.healthintersections.com.au / grah...@healthintersections.com.au
/ +61 411 867 065




Re: Line Numbers

2017-01-17 Thread A. Soroka
There are several answers.

There is no reason to suppose that any given triple actually derives from a 
file at all. It might have been created programmatically, or by inference, or 
from SPARQL, amongst many possible other means.

You are suggesting the carriage of a really large amount of metadata all 
throughout Jena's internals. The performance implications would be big, and 
entirely negative.

Andy has given you a really good road to go down if what you want is more 
detailed parsing metadata for, as you say, "reporting issues with the content". 
You can take off that metadata and record it elsewhere or record it in RDF in 
various ways. Perhaps you can tell us a little more about your use case and we 
can help you find a more targeted technique for it.

---
A. Soroka
The University of Virginia Library

> On Jan 17, 2017, at 3:14 PM, Grahame Grieve 
>  wrote:
> 
> hi
> 
> Yes replacing a library is not simple, but I thought I'd still make the
> offer. Other advantages... no, it's just a JSON parser.
> 
>> You did seem to be asking for a way to get from a triple in a graph to
> the line where it was read, and that is not possible. There is no such
> association.
> 
> why not? the library could provide a way, and retain the association.
> 
> Grahame
> 
> 
> On Wed, Jan 18, 2017 at 6:58 AM, A. Soroka  wrote:
> 
>> Replacing the JSON library in use is a considerably bigger proposition
>> than working with the one we now use in a different way. Are there other
>> advantages to using your custom code? We want to stick to well-supported
>> dependencies unless there is a convincing argument otherwise.
>> 
>> As for Turtle, I believe you can take a look at LangTurtleBase to see what
>> might be done. Keep in mind that there's not necessarily a precise way to
>> understand what line produces an error-- it might occur in the interaction
>> between tokens on more than one line.
>> 
>> ---
>> A. Soroka
>> The University of Virginia Library
>> 
>>> On Jan 17, 2017, at 2:42 PM, Grahame Grieve <
>> grah...@healthintersections.com.au> wrote:
>>> 
>>> well, I care about turtle and json-ld.  I can contribute a json library
>>> that preserves line numbers when the json is parsed, since the main
>> stream
>>> ones don't.
>>> 
>>> Grahame
>>> 
>>> 
>>> On Wed, Jan 18, 2017 at 5:38 AM, A. Soroka  wrote:
>>> 
 That will depend a bit on the language. For example, JSON parsing
>> doesn't
 occur directly in Jena, Jena uses a library that parses from JSON to
>> Java
 objects and then works with those objects:
 
 org.apache.jena.riot.lang.JsonLDReader.read(InputStream, String,
 ContentType, StreamRDF, Context)
 
 In some other cases, it seems like it should be possible. Do you have a
 specific language in mind?
 
 ---
 A. Soroka
 The University of Virginia Library
 
> On Jan 16, 2017, at 6:48 AM, Grahame Grieve <
 grah...@healthintersections.com.au> wrote:
> 
> Can the Jena parser maintain a link between the triples and the line
 number
> from which are sourced in the original file? This is really useful for
> reporting issues with the content
> 
> Grahame
> 
> 
> --
> -
> http://www.healthintersections.com.au / grahame@healthintersections.
 com.au
> / +61 411 867 065
 
 
>>> 
>>> 
>>> --
>>> -
>>> http://www.healthintersections.com.au / grahame@healthintersections.
>> com.au
>>> / +61 411 867 065
>> 
>> 
> 
> 
> -- 
> -
> http://www.healthintersections.com.au / grah...@healthintersections.com.au
> / +61 411 867 065



Re: Line Numbers

2017-01-17 Thread Grahame Grieve
hi

Yes replacing a library is not simple, but I thought I'd still make the
offer. Other advantages... no, it's just a JSON parser.

> You did seem to be asking for a way to get from a triple in a graph to
the line where it was read, and that is not possible. There is no such
association.

why not? the library could provide a way, and retain the association.

Grahame


On Wed, Jan 18, 2017 at 6:58 AM, A. Soroka  wrote:

> Replacing the JSON library in use is a considerably bigger proposition
> than working with the one we now use in a different way. Are there other
> advantages to using your custom code? We want to stick to well-supported
> dependencies unless there is a convincing argument otherwise.
>
> As for Turtle, I believe you can take a look at LangTurtleBase to see what
> might be done. Keep in mind that there's not necessarily a precise way to
> understand what line produces an error-- it might occur in the interaction
> between tokens on more than one line.
>
> ---
> A. Soroka
> The University of Virginia Library
>
> > On Jan 17, 2017, at 2:42 PM, Grahame Grieve <
> grah...@healthintersections.com.au> wrote:
> >
> > well, I care about turtle and json-ld.  I can contribute a json library
> > that preserves line numbers when the json is parsed, since the main
> stream
> > ones don't.
> >
> > Grahame
> >
> >
> > On Wed, Jan 18, 2017 at 5:38 AM, A. Soroka  wrote:
> >
> >> That will depend a bit on the language. For example, JSON parsing
> doesn't
> >> occur directly in Jena, Jena uses a library that parses from JSON to
> Java
> >> objects and then works with those objects:
> >>
> >> org.apache.jena.riot.lang.JsonLDReader.read(InputStream, String,
> >> ContentType, StreamRDF, Context)
> >>
> >> In some other cases, it seems like it should be possible. Do you have a
> >> specific language in mind?
> >>
> >> ---
> >> A. Soroka
> >> The University of Virginia Library
> >>
> >>> On Jan 16, 2017, at 6:48 AM, Grahame Grieve <
> >> grah...@healthintersections.com.au> wrote:
> >>>
> >>> Can the Jena parser maintain a link between the triples and the line
> >> number
> >>> from which are sourced in the original file? This is really useful for
> >>> reporting issues with the content
> >>>
> >>> Grahame
> >>>
> >>>
> >>> --
> >>> -
> >>> http://www.healthintersections.com.au / grahame@healthintersections.
> >> com.au
> >>> / +61 411 867 065
> >>
> >>
> >
> >
> > --
> > -
> > http://www.healthintersections.com.au / grahame@healthintersections.
> com.au
> > / +61 411 867 065
>
>


-- 
-
http://www.healthintersections.com.au / grah...@healthintersections.com.au
/ +61 411 867 065


Re: Line Numbers

2017-01-17 Thread A. Soroka
Replacing the JSON library in use is a considerably bigger proposition than 
working with the one we now use in a different way. Are there other advantages 
to using your custom code? We want to stick to well-supported dependencies 
unless there is a convincing argument otherwise.

As for Turtle, I believe you can take a look at LangTurtleBase to see what 
might be done. Keep in mind that there's not necessarily a precise way to 
understand what line produces an error-- it might occur in the interaction 
between tokens on more than one line.

---
A. Soroka
The University of Virginia Library

> On Jan 17, 2017, at 2:42 PM, Grahame Grieve 
>  wrote:
> 
> well, I care about turtle and json-ld.  I can contribute a json library
> that preserves line numbers when the json is parsed, since the main stream
> ones don't.
> 
> Grahame
> 
> 
> On Wed, Jan 18, 2017 at 5:38 AM, A. Soroka  wrote:
> 
>> That will depend a bit on the language. For example, JSON parsing doesn't
>> occur directly in Jena, Jena uses a library that parses from JSON to Java
>> objects and then works with those objects:
>> 
>> org.apache.jena.riot.lang.JsonLDReader.read(InputStream, String,
>> ContentType, StreamRDF, Context)
>> 
>> In some other cases, it seems like it should be possible. Do you have a
>> specific language in mind?
>> 
>> ---
>> A. Soroka
>> The University of Virginia Library
>> 
>>> On Jan 16, 2017, at 6:48 AM, Grahame Grieve <
>> grah...@healthintersections.com.au> wrote:
>>> 
>>> Can the Jena parser maintain a link between the triples and the line
>> number
>>> from which are sourced in the original file? This is really useful for
>>> reporting issues with the content
>>> 
>>> Grahame
>>> 
>>> 
>>> --
>>> -
>>> http://www.healthintersections.com.au / grahame@healthintersections.
>> com.au
>>> / +61 411 867 065
>> 
>> 
> 
> 
> -- 
> -
> http://www.healthintersections.com.au / grah...@healthintersections.com.au
> / +61 411 867 065



Re: Line Numbers

2017-01-17 Thread Andy Seaborne
RDF does not have the concept of an order to triples and indeed triples 
can be added and deleted to the set of triples from different places.


What you can do is to add stages to the parsing process to produce 
messages as parsing happens.


Andy

On 17/01/17 19:42, Grahame Grieve wrote:

well, I care about turtle and json-ld.  I can contribute a json library
that preserves line numbers when the json is parsed, since the main stream
ones don't.

Grahame


On Wed, Jan 18, 2017 at 5:38 AM, A. Soroka  wrote:


That will depend a bit on the language. For example, JSON parsing doesn't
occur directly in Jena, Jena uses a library that parses from JSON to Java
objects and then works with those objects:

org.apache.jena.riot.lang.JsonLDReader.read(InputStream, String,
ContentType, StreamRDF, Context)

In some other cases, it seems like it should be possible. Do you have a
specific language in mind?

---
A. Soroka
The University of Virginia Library


On Jan 16, 2017, at 6:48 AM, Grahame Grieve <

grah...@healthintersections.com.au> wrote:


Can the Jena parser maintain a link between the triples and the line

number

from which are sourced in the original file? This is really useful for
reporting issues with the content

Grahame


--
-
http://www.healthintersections.com.au / grahame@healthintersections.

com.au

/ +61 411 867 065








Re: Line Numbers

2017-01-17 Thread A. Soroka
You did seem to be asking for a way to get from a triple in a graph to the line 
where it was read, and that is not possible. There is no such association. Andy 
is pointing out that only during parsing can such information be managed (and I 
pointed out that even that is not the case all the time). If that is not what 
you are asking for, perhaps you can clarify.

---
A. Soroka
The University of Virginia Library

> On Jan 17, 2017, at 2:52 PM, Grahame Grieve 
>  wrote:
> 
> I'm not sure where that means it's not possible or of interest to trace the
> triples (or their parts) to source files
> 
> Grahame
> 
> 
> On Wed, Jan 18, 2017 at 6:47 AM, Andy Seaborne  wrote:
> 
>> RDF does not have the concept of an order to triples and indeed triples
>> can be added and deleted to the set of triples from different places.
>> 
>> What you can do is to add stages to the parsing process to produce
>> messages as parsing happens.
>> 
>>Andy
>> 
>> 
>> On 17/01/17 19:42, Grahame Grieve wrote:
>> 
>>> well, I care about turtle and json-ld.  I can contribute a json library
>>> that preserves line numbers when the json is parsed, since the main stream
>>> ones don't.
>>> 
>>> Grahame
>>> 
>>> 
>>> On Wed, Jan 18, 2017 at 5:38 AM, A. Soroka  wrote:
>>> 
>>> That will depend a bit on the language. For example, JSON parsing doesn't
 occur directly in Jena, Jena uses a library that parses from JSON to Java
 objects and then works with those objects:
 
 org.apache.jena.riot.lang.JsonLDReader.read(InputStream, String,
 ContentType, StreamRDF, Context)
 
 In some other cases, it seems like it should be possible. Do you have a
 specific language in mind?
 
 ---
 A. Soroka
 The University of Virginia Library
 
 On Jan 16, 2017, at 6:48 AM, Grahame Grieve <
> 
 grah...@healthintersections.com.au> wrote:
 
> 
> Can the Jena parser maintain a link between the triples and the line
> 
 number
 
> from which are sourced in the original file? This is really useful for
> reporting issues with the content
> 
> Grahame
> 
> 
> --
> -
> http://www.healthintersections.com.au / grahame@healthintersections.
> 
 com.au
 
> / +61 411 867 065
> 
 
 
 
>>> 
>>> 
> 
> 
> -- 
> -
> http://www.healthintersections.com.au / grah...@healthintersections.com.au
> / +61 411 867 065



Re: Line Numbers

2017-01-17 Thread Grahame Grieve
I'm not sure where that means it's not possible or of interest to trace the
triples (or their parts) to source files

Grahame


On Wed, Jan 18, 2017 at 6:47 AM, Andy Seaborne  wrote:

> RDF does not have the concept of an order to triples and indeed triples
> can be added and deleted to the set of triples from different places.
>
> What you can do is to add stages to the parsing process to produce
> messages as parsing happens.
>
> Andy
>
>
> On 17/01/17 19:42, Grahame Grieve wrote:
>
>> well, I care about turtle and json-ld.  I can contribute a json library
>> that preserves line numbers when the json is parsed, since the main stream
>> ones don't.
>>
>> Grahame
>>
>>
>> On Wed, Jan 18, 2017 at 5:38 AM, A. Soroka  wrote:
>>
>> That will depend a bit on the language. For example, JSON parsing doesn't
>>> occur directly in Jena, Jena uses a library that parses from JSON to Java
>>> objects and then works with those objects:
>>>
>>> org.apache.jena.riot.lang.JsonLDReader.read(InputStream, String,
>>> ContentType, StreamRDF, Context)
>>>
>>> In some other cases, it seems like it should be possible. Do you have a
>>> specific language in mind?
>>>
>>> ---
>>> A. Soroka
>>> The University of Virginia Library
>>>
>>> On Jan 16, 2017, at 6:48 AM, Grahame Grieve <

>>> grah...@healthintersections.com.au> wrote:
>>>

 Can the Jena parser maintain a link between the triples and the line

>>> number
>>>
 from which are sourced in the original file? This is really useful for
 reporting issues with the content

 Grahame


 --
 -
 http://www.healthintersections.com.au / grahame@healthintersections.

>>> com.au
>>>
 / +61 411 867 065

>>>
>>>
>>>
>>
>>


-- 
-
http://www.healthintersections.com.au / grah...@healthintersections.com.au
/ +61 411 867 065


Re: Line Numbers

2017-01-17 Thread Grahame Grieve
well, I care about turtle and json-ld.  I can contribute a json library
that preserves line numbers when the json is parsed, since the main stream
ones don't.

Grahame


On Wed, Jan 18, 2017 at 5:38 AM, A. Soroka  wrote:

> That will depend a bit on the language. For example, JSON parsing doesn't
> occur directly in Jena, Jena uses a library that parses from JSON to Java
> objects and then works with those objects:
>
> org.apache.jena.riot.lang.JsonLDReader.read(InputStream, String,
> ContentType, StreamRDF, Context)
>
> In some other cases, it seems like it should be possible. Do you have a
> specific language in mind?
>
> ---
> A. Soroka
> The University of Virginia Library
>
> > On Jan 16, 2017, at 6:48 AM, Grahame Grieve <
> grah...@healthintersections.com.au> wrote:
> >
> > Can the Jena parser maintain a link between the triples and the line
> number
> > from which are sourced in the original file? This is really useful for
> > reporting issues with the content
> >
> > Grahame
> >
> >
> > --
> > -
> > http://www.healthintersections.com.au / grahame@healthintersections.
> com.au
> > / +61 411 867 065
>
>


-- 
-
http://www.healthintersections.com.au / grah...@healthintersections.com.au
/ +61 411 867 065


Re: How I handle "Null Pointer Exception"

2017-01-17 Thread Sidra shah
OntModel model2=ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM);
   InputStream in =FileManager.get().open("F://20-8.owl");
if (in==null) {
throw new IllegalArgumentException( "File: " +  " not
found");
}  model2.read(in,"");

 String ns="
http://www.semanticweb.org/t/ontologies/2016/7/myOWL#;;

   OntProperty favcat=model2.getOntProperty(ns+ "BestCategory");
String  name=jTextField1.getText();
Individual indiv = user1.createIndividual(ns + name);
  RDFNode phFav=indiv.getPropertyValue(favcat);
 if (phFav!=null){
  Literal l1=phFav.asLiteral();

   s1=l1.toString(); }
 }
if (s1=="CatPhysics"){
 JOptionPane.showMessageDialog(null, "Physics");
  }

The rule itself is

String rule ="[rule1: ( ?x http://www.semanticweb.org/
t/ontologies/2016/7/myOWL#Physics_Preferred_Category  ?cat1 )" +
 "( ?x http://www.semanticweb.org/t/ontologies/2016/7/myOWL#
Chem_Preferred_Category  ?cat2 )" +
"( ?x http://www.semanticweb.org/t/ontologies/2016/7/myOWL#Geo_
Preferred_Category  ?cat3 )" +
"greaterThan(?cat1,?cat2), greaterThan(?cat1,?cat3)"
 + " ->  (?x  http://www.semanticweb.org/t/
ontologies/2016/7/myOWL#BestCategory   http://www.semanticweb.org/t/
ontologies/2016/7/myOWL#BestCategory#Physics   )]";


The BestCategory is object property.

Regards


On Tue, Jan 17, 2017 at 8:16 PM, Andy Seaborne  wrote:

> A Complete, Minimal Example please.
>
>
> Partial code, no data is not complete.
> It must compile and run to be complete.
>
> Minimal means only what is necessary to ask the question not the whole
> data or whole application.
>
> Andy
>
> On 17/01/17 17:14, Sidra shah wrote:
>
>> I am surprise that when there is no value in BestCategory, it gives me no
>> error and when the rule executes and value comes in BestCategory, it gives
>> me now *"RequiredLiteralException*"
>>
>> The code I used here is
>>
>>  OntProperty favcat=model2.getOntProperty(ns+ "BestCategory");
>>
>> RDFNode phFav=indiv.getPropertyValue(favcat);
>>  if (phFav!=null){
>>   Literal l1=phFav.asLiteral();
>>
>>s1=l1.toString();}
>>
>> if (s1=="CatPhysics"){
>>  JOptionPane.showMessageDialog(null, "Physics");
>>   }
>>
>> Best regards
>>
>> On Tue, Jan 17, 2017 at 5:53 PM, Sidra shah 
>> wrote:
>>
>> Hello Chris, thanks a lot for your suggestion.
>>>
>>> Best regards.
>>>
>>> On Tue, Jan 17, 2017 at 5:37 PM, Chris Dollin <
>>> chris.dol...@epimorphics.com> wrote:
>>>
>>>

 On 17/01/17 13:30, Sidra shah wrote:

 Hi Lorenz, I am sorry but with much regards, you discussed here the
> problem, not the solution  :) :)
>
> I know this if there is no value, there must be Null exception,
>
>
 This is not true.

 but can you suggest me a way where we dodge the compiler

>
>
 No "dodging" of the compiler is required. Instead, just write
 perfectly ordinary code that tests to see if the result of
 getPropertyValue is null, and take one action if it isn't and
 a different one if it is.

 There's nothing special about this. You don't need to use
 break (which is for escaping from loops); just an if
 with suitable then and else parts.

 I know this is more a Java problem, but any help I will appreciate.

>
>
 Find someone /local/ doing the same or similar course and talk to
 them (and have them talk to you) about programming and this
 problem. I don't mean copy each other's work; I mean use each
 other to understand what the problem is about and how the code
 works. Each of you will know things that the other doesn't; share.

 Chris

 --
 "He could not weigh up which was worse and so tried not to think about
 either."
 /The Spellgrinder's
 Apprentice/

 Epimorphics Ltd, http://www.epimorphics.com
 Registered address: Court Lodge, 105 High Street, Portishead, Bristol
 BS20 6PT
 Epimorphics Ltd. is a limited company registered in England (number
 7016688)


>>>
>>>
>>


Re: Line Numbers

2017-01-17 Thread A. Soroka
That will depend a bit on the language. For example, JSON parsing doesn't occur 
directly in Jena, Jena uses a library that parses from JSON to Java objects and 
then works with those objects:

org.apache.jena.riot.lang.JsonLDReader.read(InputStream, String, ContentType, 
StreamRDF, Context)

In some other cases, it seems like it should be possible. Do you have a 
specific language in mind?

---
A. Soroka
The University of Virginia Library

> On Jan 16, 2017, at 6:48 AM, Grahame Grieve 
>  wrote:
> 
> Can the Jena parser maintain a link between the triples and the line number
> from which are sourced in the original file? This is really useful for
> reporting issues with the content
> 
> Grahame
> 
> 
> -- 
> -
> http://www.healthintersections.com.au / grah...@healthintersections.com.au
> / +61 411 867 065



Re: How I handle "Null Pointer Exception"

2017-01-17 Thread Andy Seaborne

A Complete, Minimal Example please.


Partial code, no data is not complete.
It must compile and run to be complete.

Minimal means only what is necessary to ask the question not the whole 
data or whole application.


Andy

On 17/01/17 17:14, Sidra shah wrote:

I am surprise that when there is no value in BestCategory, it gives me no
error and when the rule executes and value comes in BestCategory, it gives
me now *"RequiredLiteralException*"
The code I used here is

 OntProperty favcat=model2.getOntProperty(ns+ "BestCategory");

RDFNode phFav=indiv.getPropertyValue(favcat);
 if (phFav!=null){
  Literal l1=phFav.asLiteral();

   s1=l1.toString();}

if (s1=="CatPhysics"){
 JOptionPane.showMessageDialog(null, "Physics");
  }

Best regards

On Tue, Jan 17, 2017 at 5:53 PM, Sidra shah  wrote:


Hello Chris, thanks a lot for your suggestion.

Best regards.

On Tue, Jan 17, 2017 at 5:37 PM, Chris Dollin <
chris.dol...@epimorphics.com> wrote:




On 17/01/17 13:30, Sidra shah wrote:


Hi Lorenz, I am sorry but with much regards, you discussed here the
problem, not the solution  :) :)

I know this if there is no value, there must be Null exception,



This is not true.

but can you suggest me a way where we dodge the compiler




No "dodging" of the compiler is required. Instead, just write
perfectly ordinary code that tests to see if the result of
getPropertyValue is null, and take one action if it isn't and
a different one if it is.

There's nothing special about this. You don't need to use
break (which is for escaping from loops); just an if
with suitable then and else parts.

I know this is more a Java problem, but any help I will appreciate.




Find someone /local/ doing the same or similar course and talk to
them (and have them talk to you) about programming and this
problem. I don't mean copy each other's work; I mean use each
other to understand what the problem is about and how the code
works. Each of you will know things that the other doesn't; share.

Chris

--
"He could not weigh up which was worse and so tried not to think about
either."
/The Spellgrinder's
Apprentice/

Epimorphics Ltd, http://www.epimorphics.com
Registered address: Court Lodge, 105 High Street, Portishead, Bristol
BS20 6PT
Epimorphics Ltd. is a limited company registered in England (number
7016688)








Re: How I handle "Null Pointer Exception"

2017-01-17 Thread Sidra shah
I am surprise that when there is no value in BestCategory, it gives me no
error and when the rule executes and value comes in BestCategory, it gives
me now *"RequiredLiteralException*"
The code I used here is

 OntProperty favcat=model2.getOntProperty(ns+ "BestCategory");

RDFNode phFav=indiv.getPropertyValue(favcat);
 if (phFav!=null){
  Literal l1=phFav.asLiteral();

   s1=l1.toString();}

if (s1=="CatPhysics"){
 JOptionPane.showMessageDialog(null, "Physics");
  }

Best regards

On Tue, Jan 17, 2017 at 5:53 PM, Sidra shah  wrote:

> Hello Chris, thanks a lot for your suggestion.
>
> Best regards.
>
> On Tue, Jan 17, 2017 at 5:37 PM, Chris Dollin <
> chris.dol...@epimorphics.com> wrote:
>
>>
>>
>> On 17/01/17 13:30, Sidra shah wrote:
>>
>>> Hi Lorenz, I am sorry but with much regards, you discussed here the
>>> problem, not the solution  :) :)
>>>
>>> I know this if there is no value, there must be Null exception,
>>>
>>
>> This is not true.
>>
>> but can you suggest me a way where we dodge the compiler
>>>
>>
>> No "dodging" of the compiler is required. Instead, just write
>> perfectly ordinary code that tests to see if the result of
>> getPropertyValue is null, and take one action if it isn't and
>> a different one if it is.
>>
>> There's nothing special about this. You don't need to use
>> break (which is for escaping from loops); just an if
>> with suitable then and else parts.
>>
>> I know this is more a Java problem, but any help I will appreciate.
>>>
>>
>> Find someone /local/ doing the same or similar course and talk to
>> them (and have them talk to you) about programming and this
>> problem. I don't mean copy each other's work; I mean use each
>> other to understand what the problem is about and how the code
>> works. Each of you will know things that the other doesn't; share.
>>
>> Chris
>>
>> --
>> "He could not weigh up which was worse and so tried not to think about
>> either."
>> /The Spellgrinder's
>> Apprentice/
>>
>> Epimorphics Ltd, http://www.epimorphics.com
>> Registered address: Court Lodge, 105 High Street, Portishead, Bristol
>> BS20 6PT
>> Epimorphics Ltd. is a limited company registered in England (number
>> 7016688)
>>
>
>


Re: Experience with large number (e.g. 1M) of Named Graphs in Fuseki?

2017-01-17 Thread Andy Seaborne
If you are using TDB, and since Fuseki 2.4.0, for in memory, graph is 
treated just as a column like subject or predicate or object.  It does 
not make much difference; some more indexing (and even then if necessary 
you can tune it).


Default union graph works and does not care much either.

You are right the UI is skewed to small number of graphs, but that is a 
UI and admin issue.


The raw storage and query does not really see much difference. Default 
union graph works and does not care much either.


Andy



On 17/01/17 14:16, Daniel Hernandez wrote:

I do a benchmark with different models with the same data. One model had
more than 65 millions of named graphs. Fuseki had no problems with named
compared with storing the same data in a single graph. You can see the
results of the benchmark in:

https://users.dcc.uchile.cl/~dhernand/research/ssws-2015-reifying.pdf

Cheers,
Daniel


  On mar, 17 ene 2017 06:22:11 -0300 Nikolaos Beredimas  
wrote 
 > My first guess would be no, it wouldn't hurt performance.
 > Although I have limited experience on Fuseki (just using it as a second
 > test endpoint to verify SPARQL compatibility),
 > I am using a similar approach on a different RDF store (currently at about
 > 650,000 graphs on one deployment)
 > I would imagine that Graphs are indexed the same as S, P, or O on Fuseki.
 >
 > One of my main problems with this approach has also been the lack of UI
 > support for administration of large number of graphs as you pointed out.
 > This is something not specific to Fuseki, apparently there isn't enough
 > demand for this use case.
 >
 > On Tue, Jan 17, 2017 at 9:59 AM, Conal Tuohy  wrote:
 >
 > > I am working with Fuseki 2 using the SPARQL Named Graph protocol, and I
 > > wondered if there are practical limits on the number of named graphs in the
 > > graph store?
 > >
 > > I know that many people use Jena only with a very small number of distinct
 > > graphs, and I noticed that Fuseki's own user interface really only works
 > > well when the number of named graphs is small (less than a thousand). That
 > > is not a big problem in itself, since I don't need to use that UI, but I'm
 > > more concerned about performance or other limitations when the number of
 > > graphs is much higher; on the order of a million graphs, or a few million.
 > >
 > > Can anyone reassure me? Has anyone had problems with large number of named
 > > graphs, and if so, were you able to fix them?
 > >
 > > Thanks!
 > >
 > > Conal
 > >
 > > --
 > > Conal Tuohy
 > > http://conaltuohy.com/
 > > @conal_tuohy
 > > +61-466-324297
 > >
 >




Re: How I handle "Null Pointer Exception"

2017-01-17 Thread Sidra shah
Hello Chris, thanks a lot for your suggestion.

Best regards.

On Tue, Jan 17, 2017 at 5:37 PM, Chris Dollin 
wrote:

>
>
> On 17/01/17 13:30, Sidra shah wrote:
>
>> Hi Lorenz, I am sorry but with much regards, you discussed here the
>> problem, not the solution  :) :)
>>
>> I know this if there is no value, there must be Null exception,
>>
>
> This is not true.
>
> but can you suggest me a way where we dodge the compiler
>>
>
> No "dodging" of the compiler is required. Instead, just write
> perfectly ordinary code that tests to see if the result of
> getPropertyValue is null, and take one action if it isn't and
> a different one if it is.
>
> There's nothing special about this. You don't need to use
> break (which is for escaping from loops); just an if
> with suitable then and else parts.
>
> I know this is more a Java problem, but any help I will appreciate.
>>
>
> Find someone /local/ doing the same or similar course and talk to
> them (and have them talk to you) about programming and this
> problem. I don't mean copy each other's work; I mean use each
> other to understand what the problem is about and how the code
> works. Each of you will know things that the other doesn't; share.
>
> Chris
>
> --
> "He could not weigh up which was worse and so tried not to think about
> either."
> /The Spellgrinder's
> Apprentice/
>
> Epimorphics Ltd, http://www.epimorphics.com
> Registered address: Court Lodge, 105 High Street, Portishead, Bristol BS20
> 6PT
> Epimorphics Ltd. is a limited company registered in England (number
> 7016688)
>


Re: How I handle "Null Pointer Exception"

2017-01-17 Thread Chris Dollin



On 17/01/17 13:30, Sidra shah wrote:

Hi Lorenz, I am sorry but with much regards, you discussed here the
problem, not the solution  :) :)

I know this if there is no value, there must be Null exception,


This is not true.


but can you suggest me a way where we dodge the compiler


No "dodging" of the compiler is required. Instead, just write
perfectly ordinary code that tests to see if the result of
getPropertyValue is null, and take one action if it isn't and
a different one if it is.

There's nothing special about this. You don't need to use
break (which is for escaping from loops); just an if
with suitable then and else parts.


I know this is more a Java problem, but any help I will appreciate.


Find someone /local/ doing the same or similar course and talk to
them (and have them talk to you) about programming and this
problem. I don't mean copy each other's work; I mean use each
other to understand what the problem is about and how the code
works. Each of you will know things that the other doesn't; share.

Chris

--
"He could not weigh up which was worse and so tried not to think about either."
/The Spellgrinder's Apprentice/

Epimorphics Ltd, http://www.epimorphics.com
Registered address: Court Lodge, 105 High Street, Portishead, Bristol BS20 6PT
Epimorphics Ltd. is a limited company registered in England (number 7016688)


Re: Listing only asserted propeties Vs filtering property lists

2017-01-17 Thread Dave Reynolds



On 17/01/17 13:02, Jos Lehmann wrote:

Hi there

I am copying Classes and/or Instances as well as their properties from one 
ontology to another.

To get the list of Classe and/or Instance properties from the source ontology I 
use listProperties()

But this gives much more than I need: i.e. superproperties, as well as other 
stuff, which clutters my copy ontology.

I have tried to filter out undesired properties by recursive while calls on 
Next(), or by trying to find a cut-off in the property list. But these 
solutions are not general enough.

I would like to just get the asserted properties when querying the source 
ontology. Is that possible?


Sounds like you have an OntModel with inference, create one without 
inference or access the baseModel (bypassing the inference).


In the absence of any inference then Resource#listProperties will just 
list the asserted properties (irrespective of what type of property).


Dave


Re: Experience with large number (e.g. 1M) of Named Graphs in Fuseki?

2017-01-17 Thread Daniel Hernandez
I do a benchmark with different models with the same data. One model had
more than 65 millions of named graphs. Fuseki had no problems with named
compared with storing the same data in a single graph. You can see the
results of the benchmark in:

https://users.dcc.uchile.cl/~dhernand/research/ssws-2015-reifying.pdf

Cheers,
Daniel


  On mar, 17 ene 2017 06:22:11 -0300 Nikolaos Beredimas  
wrote  
 > My first guess would be no, it wouldn't hurt performance. 
 > Although I have limited experience on Fuseki (just using it as a second 
 > test endpoint to verify SPARQL compatibility), 
 > I am using a similar approach on a different RDF store (currently at about 
 > 650,000 graphs on one deployment) 
 > I would imagine that Graphs are indexed the same as S, P, or O on Fuseki. 
 >  
 > One of my main problems with this approach has also been the lack of UI 
 > support for administration of large number of graphs as you pointed out. 
 > This is something not specific to Fuseki, apparently there isn't enough 
 > demand for this use case. 
 >  
 > On Tue, Jan 17, 2017 at 9:59 AM, Conal Tuohy  wrote: 
 >  
 > > I am working with Fuseki 2 using the SPARQL Named Graph protocol, and I 
 > > wondered if there are practical limits on the number of named graphs in 
 > > the 
 > > graph store? 
 > > 
 > > I know that many people use Jena only with a very small number of distinct 
 > > graphs, and I noticed that Fuseki's own user interface really only works 
 > > well when the number of named graphs is small (less than a thousand). That 
 > > is not a big problem in itself, since I don't need to use that UI, but I'm 
 > > more concerned about performance or other limitations when the number of 
 > > graphs is much higher; on the order of a million graphs, or a few million. 
 > > 
 > > Can anyone reassure me? Has anyone had problems with large number of named 
 > > graphs, and if so, were you able to fix them? 
 > > 
 > > Thanks! 
 > > 
 > > Conal 
 > > 
 > > -- 
 > > Conal Tuohy 
 > > http://conaltuohy.com/ 
 > > @conal_tuohy 
 > > +61-466-324297 
 > > 
 > 




Re: How I handle "Null Pointer Exception"

2017-01-17 Thread Sidra shah
Hello Lorenz, sorry to bother you.

What if we use

RDFNode physicsBestCat=indiv.getPropertyValue(bestcat);

 if (null!=phsicsBestCat) {
  Literal l1=physicsBestCat.asLiteral();
  String s1=l1.toString();}

 In fact, I tried this and it does not give exception, but dont know about
the correct result.

Regards

On Tue, Jan 17, 2017 at 4:30 PM, Sidra shah  wrote:

> Hi Lorenz, I am sorry but with much regards, you discussed here the
> problem, not the solution  :) :)
>
> I know this if there is no value, there must be Null exception, but can
> you suggest me a way where we dodge the compiler and it skip the lines when
> there is no value.
> I know this is more a Java problem, but any help I will appreciate.
>
> Regards
>
> On Tue, Jan 17, 2017 at 4:20 PM, Lorenz B.  leipzig.de> wrote:
>
>> no no no, I told you that the method getPropertyValue(p) can return NULL
>> if there is no such value for the given property p
>>
>> That means what for your line
>>
>>  RDFNode physicsBestCat=indiv.getPropertyValue(bestcat);
>>
>> ?
>>
>> Right, physicsBestCat can be NULL.
>>
>> That means what for your line
>>
>>  Literal l1=physicsBestCat.asLiteral();
>>
>> ?
>>
>> Right, asLiteral() must not be called if physicsBestCat is NULL.
>>
>> > I mean Lorenz, is there any way, if there is no value, it do nothing (do
>> > not give exception) and if there is value, it should simply give us the
>> > value.
>> >
>> > if (l1!=null) supposed to work. :)
>> >
>> > Is it possible if we use something
>> >
>> > if (li==null)
>> > break;
>> >
>> > And we should get out of this snippet?
>> >
>> > Regards
>> >
>> > On Tue, Jan 17, 2017 at 4:10 PM, Lorenz B. <
>> > buehm...@informatik.uni-leipzig.de> wrote:
>> >
>> >> ???
>> >>
>> >> if there is no such value you can't get the value, I do not see the
>> problem
>> >>> Hello Lorenz, thanks.
>> >>>
>> >>> Is there any way (alternative) to get this value as I need it further
>> in
>> >> my
>> >>> operation?
>> >>>
>> >>> Regards
>> >>>
>> >>> On Tue, Jan 17, 2017 at 4:03 PM, Lorenz B. <
>> >>> buehm...@informatik.uni-leipzig.de> wrote:
>> >>>
>> > Hello Lorenz, believe me I have tried this before I write my problem
>> >> here
>> > in the forum but the problem persists. I also tried if s1!=null. .
>> >
>> > RDFNode physicsBestCat=indiv.getPropertyValue(bestcat);
>>  But then the NullPointerException already occurs here.
>> 
>>  getPropertyValue can return NULL if there is no such value, that's
>> also
>>  explained in the Javadoc
>> >   Literal l1=physicsBestCat.asLiteral();
>>  You can't do it if physicsBestCat can be NULL
>> >  if (l1!=null){
>> >   String s1=l1.toString();
>> >
>> >   if (s1=="Physics"){
>> > }}
>> >
>> > Regards
>> >
>> > On Tue, Jan 17, 2017 at 3:48 PM, Lorenz B. <
>> > buehm...@informatik.uni-leipzig.de> wrote:
>> >
>> >> Sorry, but the answer is too obvious, especially for a student in
>> >> computer science.
>> >>
>> >> What about checking if the literal is NULL before calling
>> toString()?
>> >>
>> >>> Hello, I asked about this rule few days ago.
>> >>> String rule ="[rule1: ( ?x http://www.semanticweb.org/t/o
>> >>> ntologies/2016/7/myOWL#Physics_Preferred_Category  ?cat1 )" +
>> >>>  "( ?x http://www.semanticweb.org/t/o
>> ntologies/2016/7/myOWL#Chem_Pr
>> >>> eferred_Category  ?cat2 )" +
>> >>>   //   "( ?x http://www.semanticweb.org/t/o
>> >>> ntologies/2016/7/myOWL#Geo_Preferred_Category  ?cat3 )" +
>> >>>   //  "greaterThan(?cat1,?cat2), greaterThan(?cat1,?cat3)"
>> >>>  + " ->  (?x  http://www.semanticweb.org/t/
>> >>> ontologies/2016/7/myOWL#BestCategory
>> http://www.semanticweb.org/t/
>> >>> ontologies/2016/7/myOWL#BestCategory#Physics   )]";
>> >>>
>> >>> The BestCategory is saved but as you know a user will select all
>> the
>> >> three
>> >>> categories in the quiz, then the rule will execute, otherwise the
>> >> user
>> >> the
>> >>> user will have not the property BestCategory.
>> >>>
>> >>> When I want to extract the value of BestCategory for some
>> operation,
>>  for
>> >>> first time users to the quiz, it gives me Null Pointer Exception,
>> and
>> >>> rightly so because the user has no value of BestCategory.
>> >>>
>> >>>  RDFNode physicsBestCat=indiv.getPropertyValue(bestcat);
>> >>>   Literal l1=physicsBestCat.asLiteral();
>> >>>
>> >>> //*here I think is the exception is*
>> >>>   String s1=l1.toString();
>> >>>
>> >>>   if (s1=="Physics"){
>> >>> }
>> >>>
>> >>> How should I handle this problem please?
>> >>>
>> >>> Much regards
>> >>>
>> >> --
>> >> Lorenz Bühmann
>> >> AKSW group, University of Leipzig
>> >> Group: 

Re: How I handle "Null Pointer Exception"

2017-01-17 Thread Sidra shah
Hi Lorenz, I am sorry but with much regards, you discussed here the
problem, not the solution  :) :)

I know this if there is no value, there must be Null exception, but can you
suggest me a way where we dodge the compiler and it skip the lines when
there is no value.
I know this is more a Java problem, but any help I will appreciate.

Regards

On Tue, Jan 17, 2017 at 4:20 PM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

> no no no, I told you that the method getPropertyValue(p) can return NULL
> if there is no such value for the given property p
>
> That means what for your line
>
>  RDFNode physicsBestCat=indiv.getPropertyValue(bestcat);
>
> ?
>
> Right, physicsBestCat can be NULL.
>
> That means what for your line
>
>  Literal l1=physicsBestCat.asLiteral();
>
> ?
>
> Right, asLiteral() must not be called if physicsBestCat is NULL.
>
> > I mean Lorenz, is there any way, if there is no value, it do nothing (do
> > not give exception) and if there is value, it should simply give us the
> > value.
> >
> > if (l1!=null) supposed to work. :)
> >
> > Is it possible if we use something
> >
> > if (li==null)
> > break;
> >
> > And we should get out of this snippet?
> >
> > Regards
> >
> > On Tue, Jan 17, 2017 at 4:10 PM, Lorenz B. <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >> ???
> >>
> >> if there is no such value you can't get the value, I do not see the
> problem
> >>> Hello Lorenz, thanks.
> >>>
> >>> Is there any way (alternative) to get this value as I need it further
> in
> >> my
> >>> operation?
> >>>
> >>> Regards
> >>>
> >>> On Tue, Jan 17, 2017 at 4:03 PM, Lorenz B. <
> >>> buehm...@informatik.uni-leipzig.de> wrote:
> >>>
> > Hello Lorenz, believe me I have tried this before I write my problem
> >> here
> > in the forum but the problem persists. I also tried if s1!=null. .
> >
> > RDFNode physicsBestCat=indiv.getPropertyValue(bestcat);
>  But then the NullPointerException already occurs here.
> 
>  getPropertyValue can return NULL if there is no such value, that's
> also
>  explained in the Javadoc
> >   Literal l1=physicsBestCat.asLiteral();
>  You can't do it if physicsBestCat can be NULL
> >  if (l1!=null){
> >   String s1=l1.toString();
> >
> >   if (s1=="Physics"){
> > }}
> >
> > Regards
> >
> > On Tue, Jan 17, 2017 at 3:48 PM, Lorenz B. <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >> Sorry, but the answer is too obvious, especially for a student in
> >> computer science.
> >>
> >> What about checking if the literal is NULL before calling
> toString()?
> >>
> >>> Hello, I asked about this rule few days ago.
> >>> String rule ="[rule1: ( ?x http://www.semanticweb.org/t/o
> >>> ntologies/2016/7/myOWL#Physics_Preferred_Category  ?cat1 )" +
> >>>  "( ?x http://www.semanticweb.org/t/ontologies/2016/7/myOWL#Chem_
> Pr
> >>> eferred_Category  ?cat2 )" +
> >>>   //   "( ?x http://www.semanticweb.org/t/o
> >>> ntologies/2016/7/myOWL#Geo_Preferred_Category  ?cat3 )" +
> >>>   //  "greaterThan(?cat1,?cat2), greaterThan(?cat1,?cat3)"
> >>>  + " ->  (?x  http://www.semanticweb.org/t/
> >>> ontologies/2016/7/myOWL#BestCategory
> http://www.semanticweb.org/t/
> >>> ontologies/2016/7/myOWL#BestCategory#Physics   )]";
> >>>
> >>> The BestCategory is saved but as you know a user will select all
> the
> >> three
> >>> categories in the quiz, then the rule will execute, otherwise the
> >> user
> >> the
> >>> user will have not the property BestCategory.
> >>>
> >>> When I want to extract the value of BestCategory for some
> operation,
>  for
> >>> first time users to the quiz, it gives me Null Pointer Exception,
> and
> >>> rightly so because the user has no value of BestCategory.
> >>>
> >>>  RDFNode physicsBestCat=indiv.getPropertyValue(bestcat);
> >>>   Literal l1=physicsBestCat.asLiteral();
> >>>
> >>> //*here I think is the exception is*
> >>>   String s1=l1.toString();
> >>>
> >>>   if (s1=="Physics"){
> >>> }
> >>>
> >>> How should I handle this problem please?
> >>>
> >>> Much regards
> >>>
> >> --
> >> Lorenz Bühmann
> >> AKSW group, University of Leipzig
> >> Group: http://aksw.org - semantic web research center
> >>
> >>
>  --
>  Lorenz Bühmann
>  AKSW group, University of Leipzig
>  Group: http://aksw.org - semantic web research center
> 
> 
> >> --
> >> Lorenz Bühmann
> >> AKSW group, University of Leipzig
> >> Group: http://aksw.org - semantic web research center
> >>
> >>
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
>


Re: How I handle "Null Pointer Exception"

2017-01-17 Thread Lorenz B.
no no no, I told you that the method getPropertyValue(p) can return NULL
if there is no such value for the given property p

That means what for your line

 RDFNode physicsBestCat=indiv.getPropertyValue(bestcat);

?

Right, physicsBestCat can be NULL.

That means what for your line

 Literal l1=physicsBestCat.asLiteral();

?

Right, asLiteral() must not be called if physicsBestCat is NULL.

> I mean Lorenz, is there any way, if there is no value, it do nothing (do
> not give exception) and if there is value, it should simply give us the
> value.
>
> if (l1!=null) supposed to work. :)
>
> Is it possible if we use something
>
> if (li==null)
> break;
>
> And we should get out of this snippet?
>
> Regards
>
> On Tue, Jan 17, 2017 at 4:10 PM, Lorenz B. <
> buehm...@informatik.uni-leipzig.de> wrote:
>
>> ???
>>
>> if there is no such value you can't get the value, I do not see the problem
>>> Hello Lorenz, thanks.
>>>
>>> Is there any way (alternative) to get this value as I need it further in
>> my
>>> operation?
>>>
>>> Regards
>>>
>>> On Tue, Jan 17, 2017 at 4:03 PM, Lorenz B. <
>>> buehm...@informatik.uni-leipzig.de> wrote:
>>>
> Hello Lorenz, believe me I have tried this before I write my problem
>> here
> in the forum but the problem persists. I also tried if s1!=null. .
>
> RDFNode physicsBestCat=indiv.getPropertyValue(bestcat);
 But then the NullPointerException already occurs here.

 getPropertyValue can return NULL if there is no such value, that's also
 explained in the Javadoc
>   Literal l1=physicsBestCat.asLiteral();
 You can't do it if physicsBestCat can be NULL
>  if (l1!=null){
>   String s1=l1.toString();
>
>   if (s1=="Physics"){
> }}
>
> Regards
>
> On Tue, Jan 17, 2017 at 3:48 PM, Lorenz B. <
> buehm...@informatik.uni-leipzig.de> wrote:
>
>> Sorry, but the answer is too obvious, especially for a student in
>> computer science.
>>
>> What about checking if the literal is NULL before calling toString()?
>>
>>> Hello, I asked about this rule few days ago.
>>> String rule ="[rule1: ( ?x http://www.semanticweb.org/t/o
>>> ntologies/2016/7/myOWL#Physics_Preferred_Category  ?cat1 )" +
>>>  "( ?x http://www.semanticweb.org/t/ontologies/2016/7/myOWL#Chem_Pr
>>> eferred_Category  ?cat2 )" +
>>>   //   "( ?x http://www.semanticweb.org/t/o
>>> ntologies/2016/7/myOWL#Geo_Preferred_Category  ?cat3 )" +
>>>   //  "greaterThan(?cat1,?cat2), greaterThan(?cat1,?cat3)"
>>>  + " ->  (?x  http://www.semanticweb.org/t/
>>> ontologies/2016/7/myOWL#BestCategory   http://www.semanticweb.org/t/
>>> ontologies/2016/7/myOWL#BestCategory#Physics   )]";
>>>
>>> The BestCategory is saved but as you know a user will select all the
>> three
>>> categories in the quiz, then the rule will execute, otherwise the
>> user
>> the
>>> user will have not the property BestCategory.
>>>
>>> When I want to extract the value of BestCategory for some operation,
 for
>>> first time users to the quiz, it gives me Null Pointer Exception, and
>>> rightly so because the user has no value of BestCategory.
>>>
>>>  RDFNode physicsBestCat=indiv.getPropertyValue(bestcat);
>>>   Literal l1=physicsBestCat.asLiteral();
>>>
>>> //*here I think is the exception is*
>>>   String s1=l1.toString();
>>>
>>>   if (s1=="Physics"){
>>> }
>>>
>>> How should I handle this problem please?
>>>
>>> Much regards
>>>
>> --
>> Lorenz Bühmann
>> AKSW group, University of Leipzig
>> Group: http://aksw.org - semantic web research center
>>
>>
 --
 Lorenz Bühmann
 AKSW group, University of Leipzig
 Group: http://aksw.org - semantic web research center


>> --
>> Lorenz Bühmann
>> AKSW group, University of Leipzig
>> Group: http://aksw.org - semantic web research center
>>
>>
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center



Re: How I handle "Null Pointer Exception"

2017-01-17 Thread Sidra shah
I mean Lorenz, is there any way, if there is no value, it do nothing (do
not give exception) and if there is value, it should simply give us the
value.

if (l1!=null) supposed to work. :)

Is it possible if we use something

if (li==null)
break;

And we should get out of this snippet?

Regards

On Tue, Jan 17, 2017 at 4:10 PM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

> ???
>
> if there is no such value you can't get the value, I do not see the problem
> > Hello Lorenz, thanks.
> >
> > Is there any way (alternative) to get this value as I need it further in
> my
> > operation?
> >
> > Regards
> >
> > On Tue, Jan 17, 2017 at 4:03 PM, Lorenz B. <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >>
> >>> Hello Lorenz, believe me I have tried this before I write my problem
> here
> >>> in the forum but the problem persists. I also tried if s1!=null. .
> >>>
> >>> RDFNode physicsBestCat=indiv.getPropertyValue(bestcat);
> >> But then the NullPointerException already occurs here.
> >>
> >> getPropertyValue can return NULL if there is no such value, that's also
> >> explained in the Javadoc
> >>>   Literal l1=physicsBestCat.asLiteral();
> >> You can't do it if physicsBestCat can be NULL
> >>>  if (l1!=null){
> >>>   String s1=l1.toString();
> >>>
> >>>   if (s1=="Physics"){
> >>> }}
> >>>
> >>> Regards
> >>>
> >>> On Tue, Jan 17, 2017 at 3:48 PM, Lorenz B. <
> >>> buehm...@informatik.uni-leipzig.de> wrote:
> >>>
>  Sorry, but the answer is too obvious, especially for a student in
>  computer science.
> 
>  What about checking if the literal is NULL before calling toString()?
> 
> > Hello, I asked about this rule few days ago.
> > String rule ="[rule1: ( ?x http://www.semanticweb.org/t/o
> > ntologies/2016/7/myOWL#Physics_Preferred_Category  ?cat1 )" +
> >  "( ?x http://www.semanticweb.org/t/ontologies/2016/7/myOWL#Chem_Pr
> > eferred_Category  ?cat2 )" +
> >   //   "( ?x http://www.semanticweb.org/t/o
> > ntologies/2016/7/myOWL#Geo_Preferred_Category  ?cat3 )" +
> >   //  "greaterThan(?cat1,?cat2), greaterThan(?cat1,?cat3)"
> >  + " ->  (?x  http://www.semanticweb.org/t/
> > ontologies/2016/7/myOWL#BestCategory   http://www.semanticweb.org/t/
> > ontologies/2016/7/myOWL#BestCategory#Physics   )]";
> >
> > The BestCategory is saved but as you know a user will select all the
>  three
> > categories in the quiz, then the rule will execute, otherwise the
> user
>  the
> > user will have not the property BestCategory.
> >
> > When I want to extract the value of BestCategory for some operation,
> >> for
> > first time users to the quiz, it gives me Null Pointer Exception, and
> > rightly so because the user has no value of BestCategory.
> >
> >  RDFNode physicsBestCat=indiv.getPropertyValue(bestcat);
> >   Literal l1=physicsBestCat.asLiteral();
> >
> > //*here I think is the exception is*
> >   String s1=l1.toString();
> >
> >   if (s1=="Physics"){
> > }
> >
> > How should I handle this problem please?
> >
> > Much regards
> >
>  --
>  Lorenz Bühmann
>  AKSW group, University of Leipzig
>  Group: http://aksw.org - semantic web research center
> 
> 
> >> --
> >> Lorenz Bühmann
> >> AKSW group, University of Leipzig
> >> Group: http://aksw.org - semantic web research center
> >>
> >>
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
>


Re: How I handle "Null Pointer Exception"

2017-01-17 Thread Lorenz B.
???

if there is no such value you can't get the value, I do not see the problem
> Hello Lorenz, thanks.
>
> Is there any way (alternative) to get this value as I need it further in my
> operation?
>
> Regards
>
> On Tue, Jan 17, 2017 at 4:03 PM, Lorenz B. <
> buehm...@informatik.uni-leipzig.de> wrote:
>
>>
>>> Hello Lorenz, believe me I have tried this before I write my problem here
>>> in the forum but the problem persists. I also tried if s1!=null. .
>>>
>>> RDFNode physicsBestCat=indiv.getPropertyValue(bestcat);
>> But then the NullPointerException already occurs here.
>>
>> getPropertyValue can return NULL if there is no such value, that's also
>> explained in the Javadoc
>>>   Literal l1=physicsBestCat.asLiteral();
>> You can't do it if physicsBestCat can be NULL
>>>  if (l1!=null){
>>>   String s1=l1.toString();
>>>
>>>   if (s1=="Physics"){
>>> }}
>>>
>>> Regards
>>>
>>> On Tue, Jan 17, 2017 at 3:48 PM, Lorenz B. <
>>> buehm...@informatik.uni-leipzig.de> wrote:
>>>
 Sorry, but the answer is too obvious, especially for a student in
 computer science.

 What about checking if the literal is NULL before calling toString()?

> Hello, I asked about this rule few days ago.
> String rule ="[rule1: ( ?x http://www.semanticweb.org/t/o
> ntologies/2016/7/myOWL#Physics_Preferred_Category  ?cat1 )" +
>  "( ?x http://www.semanticweb.org/t/ontologies/2016/7/myOWL#Chem_Pr
> eferred_Category  ?cat2 )" +
>   //   "( ?x http://www.semanticweb.org/t/o
> ntologies/2016/7/myOWL#Geo_Preferred_Category  ?cat3 )" +
>   //  "greaterThan(?cat1,?cat2), greaterThan(?cat1,?cat3)"
>  + " ->  (?x  http://www.semanticweb.org/t/
> ontologies/2016/7/myOWL#BestCategory   http://www.semanticweb.org/t/
> ontologies/2016/7/myOWL#BestCategory#Physics   )]";
>
> The BestCategory is saved but as you know a user will select all the
 three
> categories in the quiz, then the rule will execute, otherwise the user
 the
> user will have not the property BestCategory.
>
> When I want to extract the value of BestCategory for some operation,
>> for
> first time users to the quiz, it gives me Null Pointer Exception, and
> rightly so because the user has no value of BestCategory.
>
>  RDFNode physicsBestCat=indiv.getPropertyValue(bestcat);
>   Literal l1=physicsBestCat.asLiteral();
>
> //*here I think is the exception is*
>   String s1=l1.toString();
>
>   if (s1=="Physics"){
> }
>
> How should I handle this problem please?
>
> Much regards
>
 --
 Lorenz Bühmann
 AKSW group, University of Leipzig
 Group: http://aksw.org - semantic web research center


>> --
>> Lorenz Bühmann
>> AKSW group, University of Leipzig
>> Group: http://aksw.org - semantic web research center
>>
>>
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center



Re: AW: AW: Listing all individuals of an ontology, including those defined in the ontology as individuals of classes coming from import ontology

2017-01-17 Thread Lorenz B.
I do not understand. I meant that the URIs can't be resolved, you can
try it in the browser or using curl, wget etc.

You have to use the URIs resp. URLs where your ontologies exist, I don't
know where this is in your environment.

> Hi Lorenz
>
> I see -- how should the URI be given?
>
> Thanks, Jos
>
>
> -Ursprüngliche Nachricht-
> Von: Lorenz B. [mailto:buehm...@informatik.uni-leipzig.de] 
> Gesendet: Dienstag, 17. Januar 2017 13:57
> An: users@jena.apache.org
> Betreff: Re: AW: Listing all individuals of an ontology, including those 
> defined in the ontology as individuals of classes coming from import ontology
>
> It does but not if the URI are given as you've shown. Both URIs can't be 
> resolved to ontology files.
>> Hi Andreas,
>>
>> Yes, I had not read in the import ontology. I thought that would be 
>> automatic. 
>>
>> Thanks, Jos
>>
>>
>> -Ursprüngliche Nachricht-
>> Von: Andreas Prieß [mailto:a...@metaphysis.net]
>> Gesendet: Samstag, 14. Januar 2017 19:47
>> An: users@jena.apache.org
>> Betreff: Re: Listing all individuals of an ontology, including those 
>> defined in the ontology as individuals of classes coming from import 
>> ontology
>>
>> Hi,
>>
>> you probably should check explicitly whether the second ontology was 
>> actually imported.
>>
>> Have a look at
>>
>> OntModel.hasLoadedImport(String uri)
>> or
>> OntModel.listSubModels(boolean withImports)
>>
>> I suppose there is a problem importing the second ontology since the URL 
>> seems not to be resolvable.
>>
>>
>> ~ Andreas
>>
>>
>> On 12.01.2017 16:30, Jos Lehmann wrote:
>>> Hi there
>>>
>>> SITUATION
>>>
>>> -- A
>>>
>>> I am working with ontology L (denoted as Ontology_input_file in Code below) 
>>> with URI:
>>> http://www.b-l.net/ontologies/2016/L_Ontology.owl#
>>>
>>>
>>> -- B
>>>
>>> This ontology imports an ontology PS with URI:
>>> http://www.b-l.net/ontologies/2016/PS_Ontology.owl#
>>>
>>> Note that I have added a number of indivuduals to L, as individuals of 
>>> classes coming from import ontology PS. I.e. these individuals have L's URI 
>>> but are of types defined in PS.
>>>
>>> PROBLEM
>>>
>>> In order to get the complete list of individuals I use the following code:
>>>
>>> OntModel model = ModelFactory.createOntologyModel();
>>> model.read(Ontology_input_file);
>>>
>>> ExtendedIterator individuals = model.listIndividuals(); while 
>>> (individuals.hasNext()) { Individual thisIndividual = (Individual) 
>>> individuals.next();
>>> System.out.println(thisIndividual.toString())
>>> }
>>>
>>>
>>> With this code I only get individuals defined in L as instances of classes 
>>> that have L's URI.
>>>
>>> How do I get the entire list of individuals, including those described in B 
>>> above?
>>> 
>>>
>>> Thanks, Jos 
>>
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
>
>
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center



Re: How I handle "Null Pointer Exception"

2017-01-17 Thread Sidra shah
Hello Lorenz, thanks.

Is there any way (alternative) to get this value as I need it further in my
operation?

Regards

On Tue, Jan 17, 2017 at 4:03 PM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

>
>
> > Hello Lorenz, believe me I have tried this before I write my problem here
> > in the forum but the problem persists. I also tried if s1!=null. .
> >
> > RDFNode physicsBestCat=indiv.getPropertyValue(bestcat);
> But then the NullPointerException already occurs here.
>
> getPropertyValue can return NULL if there is no such value, that's also
> explained in the Javadoc
> >   Literal l1=physicsBestCat.asLiteral();
> You can't do it if physicsBestCat can be NULL
> >
> >  if (l1!=null){
> >   String s1=l1.toString();
> >
> >   if (s1=="Physics"){
> > }}
> >
> > Regards
> >
> > On Tue, Jan 17, 2017 at 3:48 PM, Lorenz B. <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >> Sorry, but the answer is too obvious, especially for a student in
> >> computer science.
> >>
> >> What about checking if the literal is NULL before calling toString()?
> >>
> >>> Hello, I asked about this rule few days ago.
> >>> String rule ="[rule1: ( ?x http://www.semanticweb.org/t/o
> >>> ntologies/2016/7/myOWL#Physics_Preferred_Category  ?cat1 )" +
> >>>  "( ?x http://www.semanticweb.org/t/ontologies/2016/7/myOWL#Chem_Pr
> >>> eferred_Category  ?cat2 )" +
> >>>   //   "( ?x http://www.semanticweb.org/t/o
> >>> ntologies/2016/7/myOWL#Geo_Preferred_Category  ?cat3 )" +
> >>>   //  "greaterThan(?cat1,?cat2), greaterThan(?cat1,?cat3)"
> >>>  + " ->  (?x  http://www.semanticweb.org/t/
> >>> ontologies/2016/7/myOWL#BestCategory   http://www.semanticweb.org/t/
> >>> ontologies/2016/7/myOWL#BestCategory#Physics   )]";
> >>>
> >>> The BestCategory is saved but as you know a user will select all the
> >> three
> >>> categories in the quiz, then the rule will execute, otherwise the user
> >> the
> >>> user will have not the property BestCategory.
> >>>
> >>> When I want to extract the value of BestCategory for some operation,
> for
> >>> first time users to the quiz, it gives me Null Pointer Exception, and
> >>> rightly so because the user has no value of BestCategory.
> >>>
> >>>  RDFNode physicsBestCat=indiv.getPropertyValue(bestcat);
> >>>   Literal l1=physicsBestCat.asLiteral();
> >>>
> >>> //*here I think is the exception is*
> >>>   String s1=l1.toString();
> >>>
> >>>   if (s1=="Physics"){
> >>> }
> >>>
> >>> How should I handle this problem please?
> >>>
> >>> Much regards
> >>>
> >> --
> >> Lorenz Bühmann
> >> AKSW group, University of Leipzig
> >> Group: http://aksw.org - semantic web research center
> >>
> >>
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
>


AW: AW: Listing all individuals of an ontology, including those defined in the ontology as individuals of classes coming from import ontology

2017-01-17 Thread Jos Lehmann
Hi Lorenz

I see -- how should the URI be given?

Thanks, Jos


-Ursprüngliche Nachricht-
Von: Lorenz B. [mailto:buehm...@informatik.uni-leipzig.de] 
Gesendet: Dienstag, 17. Januar 2017 13:57
An: users@jena.apache.org
Betreff: Re: AW: Listing all individuals of an ontology, including those 
defined in the ontology as individuals of classes coming from import ontology

It does but not if the URI are given as you've shown. Both URIs can't be 
resolved to ontology files.
> Hi Andreas,
>
> Yes, I had not read in the import ontology. I thought that would be 
> automatic. 
>
> Thanks, Jos
>
>
> -Ursprüngliche Nachricht-
> Von: Andreas Prieß [mailto:a...@metaphysis.net]
> Gesendet: Samstag, 14. Januar 2017 19:47
> An: users@jena.apache.org
> Betreff: Re: Listing all individuals of an ontology, including those 
> defined in the ontology as individuals of classes coming from import 
> ontology
>
> Hi,
>
> you probably should check explicitly whether the second ontology was actually 
> imported.
>
> Have a look at
>
> OntModel.hasLoadedImport(String uri)
> or
> OntModel.listSubModels(boolean withImports)
>
> I suppose there is a problem importing the second ontology since the URL 
> seems not to be resolvable.
>
>
> ~ Andreas
>
>
> On 12.01.2017 16:30, Jos Lehmann wrote:
>> Hi there
>>
>> SITUATION
>>
>> -- A
>>
>> I am working with ontology L (denoted as Ontology_input_file in Code below) 
>> with URI:
>> http://www.b-l.net/ontologies/2016/L_Ontology.owl#
>>
>>
>> -- B
>>
>> This ontology imports an ontology PS with URI:
>> http://www.b-l.net/ontologies/2016/PS_Ontology.owl#
>>
>> Note that I have added a number of indivuduals to L, as individuals of 
>> classes coming from import ontology PS. I.e. these individuals have L's URI 
>> but are of types defined in PS.
>>
>> PROBLEM
>>
>> In order to get the complete list of individuals I use the following code:
>>
>> OntModel model = ModelFactory.createOntologyModel();
>> model.read(Ontology_input_file);
>>
>> ExtendedIterator individuals = model.listIndividuals(); while 
>> (individuals.hasNext()) { Individual thisIndividual = (Individual) 
>> individuals.next();
>> System.out.println(thisIndividual.toString())
>> }
>>
>>
>> With this code I only get individuals defined in L as instances of classes 
>> that have L's URI.
>>
>> How do I get the entire list of individuals, including those described in B 
>> above?
>>  
>>
>> Thanks, Jos  
>
>
--
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center



Re: How I handle "Null Pointer Exception"

2017-01-17 Thread Lorenz B.


> Hello Lorenz, believe me I have tried this before I write my problem here
> in the forum but the problem persists. I also tried if s1!=null. .
>
> RDFNode physicsBestCat=indiv.getPropertyValue(bestcat);
But then the NullPointerException already occurs here.

getPropertyValue can return NULL if there is no such value, that's also
explained in the Javadoc
>   Literal l1=physicsBestCat.asLiteral();
You can't do it if physicsBestCat can be NULL
>
>  if (l1!=null){
>   String s1=l1.toString();
>
>   if (s1=="Physics"){
> }}
>
> Regards
>
> On Tue, Jan 17, 2017 at 3:48 PM, Lorenz B. <
> buehm...@informatik.uni-leipzig.de> wrote:
>
>> Sorry, but the answer is too obvious, especially for a student in
>> computer science.
>>
>> What about checking if the literal is NULL before calling toString()?
>>
>>> Hello, I asked about this rule few days ago.
>>> String rule ="[rule1: ( ?x http://www.semanticweb.org/t/o
>>> ntologies/2016/7/myOWL#Physics_Preferred_Category  ?cat1 )" +
>>>  "( ?x http://www.semanticweb.org/t/ontologies/2016/7/myOWL#Chem_Pr
>>> eferred_Category  ?cat2 )" +
>>>   //   "( ?x http://www.semanticweb.org/t/o
>>> ntologies/2016/7/myOWL#Geo_Preferred_Category  ?cat3 )" +
>>>   //  "greaterThan(?cat1,?cat2), greaterThan(?cat1,?cat3)"
>>>  + " ->  (?x  http://www.semanticweb.org/t/
>>> ontologies/2016/7/myOWL#BestCategory   http://www.semanticweb.org/t/
>>> ontologies/2016/7/myOWL#BestCategory#Physics   )]";
>>>
>>> The BestCategory is saved but as you know a user will select all the
>> three
>>> categories in the quiz, then the rule will execute, otherwise the user
>> the
>>> user will have not the property BestCategory.
>>>
>>> When I want to extract the value of BestCategory for some operation, for
>>> first time users to the quiz, it gives me Null Pointer Exception, and
>>> rightly so because the user has no value of BestCategory.
>>>
>>>  RDFNode physicsBestCat=indiv.getPropertyValue(bestcat);
>>>   Literal l1=physicsBestCat.asLiteral();
>>>
>>> //*here I think is the exception is*
>>>   String s1=l1.toString();
>>>
>>>   if (s1=="Physics"){
>>> }
>>>
>>> How should I handle this problem please?
>>>
>>> Much regards
>>>
>> --
>> Lorenz Bühmann
>> AKSW group, University of Leipzig
>> Group: http://aksw.org - semantic web research center
>>
>>
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center



Listing only asserted propeties Vs filtering property lists

2017-01-17 Thread Jos Lehmann
Hi there

I am copying Classes and/or Instances as well as their properties from one 
ontology to another. 

To get the list of Classe and/or Instance properties from the source ontology I 
use listProperties()

But this gives much more than I need: i.e. superproperties, as well as other 
stuff, which clutters my copy ontology. 

I have tried to filter out undesired properties by recursive while calls on 
Next(), or by trying to find a cut-off in the property list. But these 
solutions are not general enough.

I would like to just get the asserted properties when querying the source 
ontology. Is that possible?

I can give more detail if needed.

Thanks, Jos


Re: How I handle "Null Pointer Exception"

2017-01-17 Thread Sidra shah
Hello Lorenz, believe me I have tried this before I write my problem here
in the forum but the problem persists. I also tried if s1!=null. .

RDFNode physicsBestCat=indiv.getPropertyValue(bestcat);
  Literal l1=physicsBestCat.asLiteral();

 if (l1!=null){
  String s1=l1.toString();

  if (s1=="Physics"){
}}

Regards

On Tue, Jan 17, 2017 at 3:48 PM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

> Sorry, but the answer is too obvious, especially for a student in
> computer science.
>
> What about checking if the literal is NULL before calling toString()?
>
> > Hello, I asked about this rule few days ago.
> > String rule ="[rule1: ( ?x http://www.semanticweb.org/t/o
> > ntologies/2016/7/myOWL#Physics_Preferred_Category  ?cat1 )" +
> >  "( ?x http://www.semanticweb.org/t/ontologies/2016/7/myOWL#Chem_Pr
> > eferred_Category  ?cat2 )" +
> >   //   "( ?x http://www.semanticweb.org/t/o
> > ntologies/2016/7/myOWL#Geo_Preferred_Category  ?cat3 )" +
> >   //  "greaterThan(?cat1,?cat2), greaterThan(?cat1,?cat3)"
> >  + " ->  (?x  http://www.semanticweb.org/t/
> > ontologies/2016/7/myOWL#BestCategory   http://www.semanticweb.org/t/
> > ontologies/2016/7/myOWL#BestCategory#Physics   )]";
> >
> > The BestCategory is saved but as you know a user will select all the
> three
> > categories in the quiz, then the rule will execute, otherwise the user
> the
> > user will have not the property BestCategory.
> >
> > When I want to extract the value of BestCategory for some operation, for
> > first time users to the quiz, it gives me Null Pointer Exception, and
> > rightly so because the user has no value of BestCategory.
> >
> >  RDFNode physicsBestCat=indiv.getPropertyValue(bestcat);
> >   Literal l1=physicsBestCat.asLiteral();
> >
> > //*here I think is the exception is*
> >   String s1=l1.toString();
> >
> >   if (s1=="Physics"){
> > }
> >
> > How should I handle this problem please?
> >
> > Much regards
> >
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
>


Re: AW: Listing all individuals of an ontology, including those defined in the ontology as individuals of classes coming from import ontology

2017-01-17 Thread Lorenz B.
It does but not if the URI are given as you've shown. Both URIs can't be
resolved to ontology files.
> Hi Andreas, 
>
> Yes, I had not read in the import ontology. I thought that would be 
> automatic. 
>
> Thanks, Jos
>
>
> -Ursprüngliche Nachricht-
> Von: Andreas Prieß [mailto:a...@metaphysis.net] 
> Gesendet: Samstag, 14. Januar 2017 19:47
> An: users@jena.apache.org
> Betreff: Re: Listing all individuals of an ontology, including those defined 
> in the ontology as individuals of classes coming from import ontology
>
> Hi,
>
> you probably should check explicitly whether the second ontology was actually 
> imported.
>
> Have a look at
>
> OntModel.hasLoadedImport(String uri)
> or
> OntModel.listSubModels(boolean withImports)
>
> I suppose there is a problem importing the second ontology since the URL 
> seems not to be resolvable.
>
>
> ~ Andreas
>
>
> On 12.01.2017 16:30, Jos Lehmann wrote:
>> Hi there
>>
>> SITUATION
>>
>> -- A
>>
>> I am working with ontology L (denoted as Ontology_input_file in Code below) 
>> with URI:
>> http://www.b-l.net/ontologies/2016/L_Ontology.owl#
>>
>>
>> -- B
>>
>> This ontology imports an ontology PS with URI:
>> http://www.b-l.net/ontologies/2016/PS_Ontology.owl#
>>
>> Note that I have added a number of indivuduals to L, as individuals of 
>> classes coming from import ontology PS. I.e. these individuals have L's URI 
>> but are of types defined in PS.
>>
>> PROBLEM
>>
>> In order to get the complete list of individuals I use the following code:
>>
>> OntModel model = ModelFactory.createOntologyModel();
>> model.read(Ontology_input_file);
>>
>> ExtendedIterator individuals = model.listIndividuals();
>> while (individuals.hasNext()) {
>> Individual thisIndividual = (Individual) individuals.next();
>> System.out.println(thisIndividual.toString())
>> }
>>
>>
>> With this code I only get individuals defined in L as instances of classes 
>> that have L's URI.
>>
>> How do I get the entire list of individuals, including those described in B 
>> above?
>>  
>>
>> Thanks, Jos  
>
>
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center



AW: Listing all individuals of an ontology, including those defined in the ontology as individuals of classes coming from import ontology

2017-01-17 Thread Jos Lehmann
Hi Andreas, 

Yes, I had not read in the import ontology. I thought that would be automatic. 

Thanks, Jos


-Ursprüngliche Nachricht-
Von: Andreas Prieß [mailto:a...@metaphysis.net] 
Gesendet: Samstag, 14. Januar 2017 19:47
An: users@jena.apache.org
Betreff: Re: Listing all individuals of an ontology, including those defined in 
the ontology as individuals of classes coming from import ontology

Hi,

you probably should check explicitly whether the second ontology was actually 
imported.

Have a look at

OntModel.hasLoadedImport(String uri)
or
OntModel.listSubModels(boolean withImports)

I suppose there is a problem importing the second ontology since the URL seems 
not to be resolvable.


~ Andreas


On 12.01.2017 16:30, Jos Lehmann wrote:
> Hi there
>
> SITUATION
>
> -- A
>
> I am working with ontology L (denoted as Ontology_input_file in Code below) 
> with URI:
> http://www.b-l.net/ontologies/2016/L_Ontology.owl#
>
>
> -- B
>
> This ontology imports an ontology PS with URI:
> http://www.b-l.net/ontologies/2016/PS_Ontology.owl#
>
> Note that I have added a number of indivuduals to L, as individuals of 
> classes coming from import ontology PS. I.e. these individuals have L's URI 
> but are of types defined in PS.
>
> PROBLEM
>
> In order to get the complete list of individuals I use the following code:
>
> OntModel model = ModelFactory.createOntologyModel();
> model.read(Ontology_input_file);
>
> ExtendedIterator individuals = model.listIndividuals();
> while (individuals.hasNext()) {
> Individual thisIndividual = (Individual) individuals.next();
> System.out.println(thisIndividual.toString())
> }
>
>
> With this code I only get individuals defined in L as instances of classes 
> that have L's URI.
>
> How do I get the entire list of individuals, including those described in B 
> above?
>   
>
> Thanks, Jos   



Re: How I handle "Null Pointer Exception"

2017-01-17 Thread Lorenz B.
Sorry, but the answer is too obvious, especially for a student in
computer science.

What about checking if the literal is NULL before calling toString()?

> Hello, I asked about this rule few days ago.
> String rule ="[rule1: ( ?x http://www.semanticweb.org/t/o
> ntologies/2016/7/myOWL#Physics_Preferred_Category  ?cat1 )" +
>  "( ?x http://www.semanticweb.org/t/ontologies/2016/7/myOWL#Chem_Pr
> eferred_Category  ?cat2 )" +
>   //   "( ?x http://www.semanticweb.org/t/o
> ntologies/2016/7/myOWL#Geo_Preferred_Category  ?cat3 )" +
>   //  "greaterThan(?cat1,?cat2), greaterThan(?cat1,?cat3)"
>  + " ->  (?x  http://www.semanticweb.org/t/
> ontologies/2016/7/myOWL#BestCategory   http://www.semanticweb.org/t/
> ontologies/2016/7/myOWL#BestCategory#Physics   )]";
>
> The BestCategory is saved but as you know a user will select all the three
> categories in the quiz, then the rule will execute, otherwise the user the
> user will have not the property BestCategory.
>
> When I want to extract the value of BestCategory for some operation, for
> first time users to the quiz, it gives me Null Pointer Exception, and
> rightly so because the user has no value of BestCategory.
>
>  RDFNode physicsBestCat=indiv.getPropertyValue(bestcat);
>   Literal l1=physicsBestCat.asLiteral();
>
> //*here I think is the exception is*
>   String s1=l1.toString();
>
>   if (s1=="Physics"){
> }
>
> How should I handle this problem please?
>
> Much regards
>
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center



How I handle "Null Pointer Exception"

2017-01-17 Thread Sidra shah
Hello, I asked about this rule few days ago.
String rule ="[rule1: ( ?x http://www.semanticweb.org/t/o
ntologies/2016/7/myOWL#Physics_Preferred_Category  ?cat1 )" +
 "( ?x http://www.semanticweb.org/t/ontologies/2016/7/myOWL#Chem_Pr
eferred_Category  ?cat2 )" +
  //   "( ?x http://www.semanticweb.org/t/o
ntologies/2016/7/myOWL#Geo_Preferred_Category  ?cat3 )" +
  //  "greaterThan(?cat1,?cat2), greaterThan(?cat1,?cat3)"
 + " ->  (?x  http://www.semanticweb.org/t/
ontologies/2016/7/myOWL#BestCategory   http://www.semanticweb.org/t/
ontologies/2016/7/myOWL#BestCategory#Physics   )]";

The BestCategory is saved but as you know a user will select all the three
categories in the quiz, then the rule will execute, otherwise the user the
user will have not the property BestCategory.

When I want to extract the value of BestCategory for some operation, for
first time users to the quiz, it gives me Null Pointer Exception, and
rightly so because the user has no value of BestCategory.

 RDFNode physicsBestCat=indiv.getPropertyValue(bestcat);
  Literal l1=physicsBestCat.asLiteral();

//*here I think is the exception is*
  String s1=l1.toString();

  if (s1=="Physics"){
}

How should I handle this problem please?

Much regards


Re: Experience with large number (e.g. 1M) of Named Graphs in Fuseki?

2017-01-17 Thread Nikolaos Beredimas
My first guess would be no, it wouldn't hurt performance.
Although I have limited experience on Fuseki (just using it as a second
test endpoint to verify SPARQL compatibility),
I am using a similar approach on a different RDF store (currently at about
650,000 graphs on one deployment)
I would imagine that Graphs are indexed the same as S, P, or O on Fuseki.

One of my main problems with this approach has also been the lack of UI
support for administration of large number of graphs as you pointed out.
This is something not specific to Fuseki, apparently there isn't enough
demand for this use case.

On Tue, Jan 17, 2017 at 9:59 AM, Conal Tuohy  wrote:

> I am working with Fuseki 2 using the SPARQL Named Graph protocol, and I
> wondered if there are practical limits on the number of named graphs in the
> graph store?
>
> I know that many people use Jena only with a very small number of distinct
> graphs, and I noticed that Fuseki's own user interface really only works
> well when the number of named graphs is small (less than a thousand). That
> is not a big problem in itself, since I don't need to use that UI, but I'm
> more concerned about performance or other limitations when the number of
> graphs is much higher; on the order of a million graphs, or a few million.
>
> Can anyone reassure me? Has anyone had problems with large number of named
> graphs, and if so, were you able to fix them?
>
> Thanks!
>
> Conal
>
> --
> Conal Tuohy
> http://conaltuohy.com/
> @conal_tuohy
> +61-466-324297
>


Experience with large number (e.g. 1M) of Named Graphs in Fuseki?

2017-01-17 Thread Conal Tuohy
I am working with Fuseki 2 using the SPARQL Named Graph protocol, and I
wondered if there are practical limits on the number of named graphs in the
graph store?

I know that many people use Jena only with a very small number of distinct
graphs, and I noticed that Fuseki's own user interface really only works
well when the number of named graphs is small (less than a thousand). That
is not a big problem in itself, since I don't need to use that UI, but I'm
more concerned about performance or other limitations when the number of
graphs is much higher; on the order of a million graphs, or a few million.

Can anyone reassure me? Has anyone had problems with large number of named
graphs, and if so, were you able to fix them?

Thanks!

Conal

-- 
Conal Tuohy
http://conaltuohy.com/
@conal_tuohy
+61-466-324297