Error in Jena code, when switch to another computer

2018-05-26 Thread javed khan
Hello

I have created an application using Jena and Java swings. It was working
fine. I switched to another laptop and opened the same file on new laptop
(I re-installed Netbeans), but it gives me error everywhere asLiteral() and
asResource() are used. The  asLiteral() and asResource() are used in
multiple places but everywhere it is highlighted as error.

Could you please highlight the issue ? What could be the problem?

Regards


Re: Error in Jena code, when switch to another computer

2018-05-26 Thread javed khan
Thanks for your reply

I use almost the same versions of Java, Netbeans and Protege as my previous
system.

The error is:

ERROR [main] (RDFDefaultErrorHandler.java:44) -
file:///C:/Users/Utente/Downloads/LAPTOP/getset/(line 1 column 1): Content
is not allowed in prolog.
Exception in thread "main" org.xml.sax.SAXParseException; systemId:
file:///C:/Users/Utente/Downloads/LAPTOP/getset/; lineNumber: 1;
columnNumber: 1; Content is not allowed in prolog.

On Sun, May 27, 2018 at 2:05 AM, Bruno P. Kinoshita <
brunodepau...@yahoo.com.br.invalid> wrote:

> Very likely something in your environment, especially given it's working
> on the other laptop.
> I think it won't be easy for others to spot what's wrong, without looking
> at the code, and without knowing more about your environment.
> Might be easier for yourself to compare the two environments and try to
> isolate what's different, especially Java version, and IDE configuration.
> CheersBruno
>
>   From: javed khan 
>  To: users@jena.apache.org
>  Sent: Sunday, 27 May 2018 11:12 AM
>  Subject: Error in Jena code, when switch to another computer
>
> Hello
>
> I have created an application using Jena and Java swings. It was working
> fine. I switched to another laptop and opened the same file on new laptop
> (I re-installed Netbeans), but it gives me error everywhere asLiteral() and
> asResource() are used. The  asLiteral() and asResource() are used in
> multiple places but everywhere it is highlighted as error.
>
> Could you please highlight the issue ? What could be the problem?
>
> Regards
>
>
>
>


Re: Error in Jena code, when switch to another computer

2018-05-27 Thread javed khan
Hello Lorenz, the problem is not in the code because it works fine on
another computer. When I open the same file on other system (both have same
version of java ), it just highlight the error everywhere asLiteral() and
asResource() is mentioned. When I run the code , it gives me the error
mentioned above "content is not allowed in prolog" which is usually caused
by whitespace etc.

On Sun, May 27, 2018 at 11:54 AM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

> sorry to say that, but **this** is almost **no information** to help you
> ...
>
> 1) previously you said, that you're getting compiler errors but didn't
> show any code ...
>
> 2) no you're showing RDF format errors. again,, you're not showing us
> the relevant information which in fact is the data
>
>
> On 27.05.2018 03:15, javed khan wrote:
> > Thanks for your reply
> >
> > I use almost the same versions of Java, Netbeans and Protege as my
> previous
> > system.
> >
> > The error is:
> >
> > ERROR [main] (RDFDefaultErrorHandler.java:44) -
> > file:///C:/Users/Utente/Downloads/LAPTOP/getset/(line 1 column 1):
> Content
> > is not allowed in prolog.
> > Exception in thread "main" org.xml.sax.SAXParseException; systemId:
> > file:///C:/Users/Utente/Downloads/LAPTOP/getset/; lineNumber: 1;
> > columnNumber: 1; Content is not allowed in prolog.
> >
> > On Sun, May 27, 2018 at 2:05 AM, Bruno P. Kinoshita <
> > brunodepau...@yahoo.com.br.invalid> wrote:
> >
> >> Very likely something in your environment, especially given it's working
> >> on the other laptop.
> >> I think it won't be easy for others to spot what's wrong, without
> looking
> >> at the code, and without knowing more about your environment.
> >> Might be easier for yourself to compare the two environments and try to
> >> isolate what's different, especially Java version, and IDE
> configuration.
> >> CheersBruno
> >>
> >>   From: javed khan 
> >>  To: users@jena.apache.org
> >>  Sent: Sunday, 27 May 2018 11:12 AM
> >>  Subject: Error in Jena code, when switch to another computer
> >>
> >> Hello
> >>
> >> I have created an application using Jena and Java swings. It was working
> >> fine. I switched to another laptop and opened the same file on new
> laptop
> >> (I re-installed Netbeans), but it gives me error everywhere asLiteral()
> and
> >> asResource() are used. The  asLiteral() and asResource() are used in
> >> multiple places but everywhere it is highlighted as error.
> >>
> >> Could you please highlight the issue ? What could be the problem?
> >>
> >> Regards
> >>
> >>
> >>
> >>
>
>


Re: Error in Jena code, when switch to another computer

2018-05-27 Thread javed khan
package getset;

//import static com.hp.hpl.jena.assembler.JA.OntModel;
import com.hp.hpl.jena.ontology.Individual;
import com.hp.hpl.jena.ontology.OntClass;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.ontology.OntModelSpec;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.util.FileManager;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;


public class set extends javax.swing.JFrame {


 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {


OntModel model=ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM);
  InputStream in2 =FileManager.get().open("E://ML.owl");


   String ds=jComboBox1.getSelectedItem().toString();



if (in2==null) {
throw new IllegalArgumentException( "File: " +  " not
found");
}   model.read(in2,"");



 String str=  "PREFIX rdf:<
http://www.w3.org/1999/02/22-rdf-syntax-ns#> "+
  "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
"+

  "PREFIX ont:<
http://www.semanticweb.org/ontologies/2018/2/untitled-ontology-845#> "+

 "select * " +

" WHERE { "
 + "?x  ont:ML ?m."
 + "?x ont:dataset ?d ." + "?x  ont:accuracy ?a . "


   + "Filter (?d ='"+ds+"') . "

   + "}" ;

   Query query = QueryFactory.create(str);
QueryExecution qexec = QueryExecutionFactory.create(query, model) ;
ResultSet results =  qexec.execSelect() ;




while (results.hasNext())
{
QuerySolution binding = results.nextSolution();
Resource subj = (Resource) binding.get("x");
String str2=subj.asResource().getLocalName();  //HERE THE
ERROR IS MENTIONED

 jTextArea1.append("*** THE PUBLICATION: " + " " + str2 + "
");



}



// TODO add your handling code here:
}


On Sun, May 27, 2018 at 4:10 PM, ajs6f  wrote:

> The fact that the code worked once in one execution environment proves
> nothing about its correctness.
>
> Please do as you have been repeatedly advised and show your code and at
> least an appropriate sample of your data and give full details about the
> two ways you are trying to execute your program. Otherwise there is little
> point in trying to help you.
>
> ajs6f
>
> > On May 27, 2018, at 10:02 AM, javed khan  wrote:
> >
> > Hello Lorenz, the problem is not in the code because it works fine on
> > another computer. When I open the same file on other system (both have
> same
> > version of java ), it just highlight the error everywhere asLiteral() and
> > asResource() is mentioned. When I run the code , it gives me the error
> > mentioned above "content is not allowed in prolog" which is usually
> caused
> > by whitespace etc.
> >
> > On Sun, May 27, 2018 at 11:54 AM, Lorenz Buehmann <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >> sorry to say that, but **this** is almost **no information** to help you
> >> ...
> >>
> >> 1) previously you said, that you're getting compiler errors but didn't
> >> show any code ...
> >>
> >> 2) no you're showing RDF format errors. again,, you're not showing us
> >> the relevant information which in fact is the data
> >>
> >>
> >> On 27.05.2018 03:15, javed khan wrote:
> >>> Thanks for your reply
> >>>
> >>> I use almost the same versions of Java, Netbeans and Protege as my
> >> previous
> >>> system.
> >>>
> >>> The error is:
> >>>
> >>> ERROR [main] (RDFDefaultErrorHandler.java:44) -
> >>> file:///C:/Users/Utente/Downloads/LAPTOP/getset/(line 1 column 1):
> >> Content
> >>> is not allowed in prolog.
> >>> Exception in thread "main" org.xml.sax.SAXParseException; systemId:
> >>> file:///C:/Users/Uten

Re: Error in Jena code, when switch to another computer

2018-05-27 Thread javed khan
I want to replace Jena 2 with Jena 3. When I import it in netbeans, I
include "lib" folder in classpath, lib-src folder in Sources tab but what
to include as Javadoc because there is no doc folder installed with Jena 3
version.

I installed Jena 3 and imported in the project but still give error

Uncompatible source code - package com.hp.hpl.jena.ontology does not exist

However, it does not show the previous error of as(Resource() and
asLiteral()

On Sun, May 27, 2018 at 4:56 PM, Andy Seaborne  wrote:

> No data.
>
> On 27/05/18 15:39, javed khan wrote:
>
>>   String str2=subj.asResource().getLocalName();  //HERE THE
>> ERROR IS MENTIONED
>>
>
> The code does not match the report.
>
> You said the error was "Content is not allowed in prolog." and that line
> does not cause that.
>
> and "file:///C:/Users/Utente/Downloads/LAPTOP/getset/" is
> not "E://ML.owl"
>
> > import com.hp.hpl.jena.query
>
> Old Jena, per Jena3. Upgrade.
>
> Andy
>


log4j error

2018-05-29 Thread javed khan
Hello

I have installed and importe Jena 2.10. When I run my program, it gives me
the error:
WARN No appenders could be found for logger
(com.hp.hpl.jena.sparql.mgt.ARQMgt).
log4j:WARN Please initialize the log4j system properly.

I have included the "properties" file with the following code, but still it
gives me the error.

log4j.rootLogger=INFO, stdout

# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{-MM-dd HH:mm:ss} %-5p
%c{1}:%L - %m%n


Re: log4j error

2018-05-29 Thread javed khan
I have already imported Jena-4jlog.properties, but still it gives the error.



On Tue, May 29, 2018 at 9:56 PM, Andy Seaborne  wrote:

>
>
> On 29/05/18 20:29, javed khan wrote:
>
>> Hello
>>
>> I have installed and importe Jena 2.10. When I run my program, it gives me
>> the error:
>> WARN No appenders could be found for logger
>> (com.hp.hpl.jena.sparql.mgt.ARQMgt).
>> log4j:WARN Please initialize the log4j system properly.
>>
>> I have included the "properties" file with the following code, but still
>> it
>> gives me the error.
>>
>
> The message means log4j1 can't find a logging setup.
>
> Add the appropriate "-Dlog4j.configuration=file:..."  to the java
> invocation.
>
> Add "-Dlog4j.debug" to debug.
>
> See the log4j documentation.
>
> Andy
>
>
>
>> log4j.rootLogger=INFO, stdout
>>
>> # Direct log messages to stdout
>> log4j.appender.stdout=org.apache.log4j.ConsoleAppender
>> log4j.appender.stdout.Target=System.out
>> log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
>> log4j.appender.stdout.layout.ConversionPattern=%d{-MM-dd HH:mm:ss}
>> %-5p
>> %c{1}:%L - %m%n
>>
>>


Re: log4j error

2018-05-29 Thread javed khan
By import I mean include the file.

I have included the file with the following code:

log4j.rootLogger=INFO, stdlog
## log4j.rootLogger=INFO, FusekiFileLog

log4j.appender.stdlog=org.apache.log4j.ConsoleAppender
## log4j.appender.stdlog.target=System.err
log4j.appender.stdlog.layout=org.apache.log4j.PatternLayout
log4j.appender.stdlog.layout.ConversionPattern=%d{HH:mm:ss} %-5p %-20c{1}
:: %m%n

## # Example for file logging.
## log4j.appender.FusekiFileLog=org.apache.log4j.DailyRollingFileAppender
## log4j.appender.FusekiFileLog.DatePattern='.'-MM-dd
## log4j.appender.FusekiFileLog.File=fuseki-log
## log4j.appender.FusekiFileLog.layout=org.apache.log4j.PatternLayout
## log4j.appender.FusekiFileLog.layout.ConversionPattern=%d{HH:mm:ss} %-5p
%-20c{1} :: %m%n

# Jetty - Fuseki catches Jetty errors and reports them.
log4j.logger.org.eclipse.jetty=FATAL

# Execution logging
log4j.logger.com.hp.hpl.jena.arq.info=INFO
log4j.logger.com.hp.hpl.jena.arq.exec=INFO

# TDB loader
log4j.logger.com.hp.hpl.jena.tdb.loader=INFO
# TDB syslog.
log4j.logger.TDB=INFO

# Everything else in Jena
log4j.logger.com.hp.hpl.jena=WARN
log4j.logger.org.openjena=WARN
log4j.logger.org.openjena.riot=INFO

# Fuseki
# Server log.
log4j.logger.org.openjena.fuseki.Server=INFO
# Request log.
log4j.logger.org.openjena.fuseki.Fuseki=INFO
# Internal logs
log4j.logger.org.openjena.fuseki=INFO




On Tue, May 29, 2018 at 11:14 PM, Andy Seaborne  wrote:

>
> Log4j initializes very early (use -Dlog4j.debug).
>
> It must be initialised before calling any Jena code except Log.setLog4j
> (and that looks for file "log4j.properties", nothing else).
>
> Use -Dlog4j.configuration
>
> (Jena 2.10 is 5 years old)
>
> Andy
>
> On 29/05/18 22:07, javed khan wrote:
>
>> I have already imported Jena-4jlog.properties, but still it gives the
>> error.
>>
>   ^
> What does "import" mean?
> What's that?
>
>
>
>>
>>
>> On Tue, May 29, 2018 at 9:56 PM, Andy Seaborne  wrote:
>>
>>
>>>
>>> On 29/05/18 20:29, javed khan wrote:
>>>
>>> Hello
>>>>
>>>> I have installed and importe Jena 2.10. When I run my program, it gives
>>>> me
>>>> the error:
>>>> WARN No appenders could be found for logger
>>>> (com.hp.hpl.jena.sparql.mgt.ARQMgt).
>>>> log4j:WARN Please initialize the log4j system properly.
>>>>
>>>> I have included the "properties" file with the following code, but still
>>>> it
>>>> gives me the error.
>>>>
>>>>
>>> The message means log4j1 can't find a logging setup.
>>>
>>> Add the appropriate "-Dlog4j.configuration=file:..."  to the java
>>> invocation.
>>>
>>> Add "-Dlog4j.debug" to debug.
>>>
>>> See the log4j documentation.
>>>
>>>  Andy
>>>
>>>
>>>
>>> log4j.rootLogger=INFO, stdout
>>>>
>>>> # Direct log messages to stdout
>>>> log4j.appender.stdout=org.apache.log4j.ConsoleAppender
>>>> log4j.appender.stdout.Target=System.out
>>>> log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
>>>> log4j.appender.stdout.layout.ConversionPattern=%d{-MM-dd HH:mm:ss}
>>>> %-5p
>>>> %c{1}:%L - %m%n
>>>>
>>>>
>>>>
>>


feature subset selection using Ontology

2018-08-08 Thread javed khan
Hello

For instance, we have to select some features ( for data mining) , can we
do it using Semantic Web technologies like Ontology and SPARQL. ?

Thanks


Re: feature subset selection using Ontology

2018-08-09 Thread javed khan
Hello Lorenz sorry for inconvenience.

Suppose we have a dataset about software effort estimation which have about
100 attributes (line of code, complexity etc). To extract the subset of
features (as all 100 attributes are not important), we usually used some
data mining algorithms (Genetic algorithm etc). Now I want to make these
attributes as Ontology and get the attributes via SPARQL but not sure how
can I select the most appropriate features using SPARQL (because the
Genetic algorithm and other select the most appropriate features
automatically).

Best regards

On Thu, Aug 9, 2018 at 7:53 AM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

> Javed...I don't know how many mails you wrote to this list (and the
> Protege Users list), but shouldn't you already have learned that you
> have to provide more information, data, code, queries, use case, etc. in
> order to get help?!
>
> What do you expect as an answer on a question "can we ..." - my answer
> is, "yes, you can". And now?
>
> Just to clarify, SPARQL is a query language for RDF data, thus, you can
> query any explicit information that is contained in an RDF dataset.
>
>
> On 08.08.2018 21:56, javed khan wrote:
> > Hello
> >
> > For instance, we have to select some features ( for data mining) , can we
> > do it using Semantic Web technologies like Ontology and SPARQL. ?
> >
> > Thanks
> >
>
>


Re: feature subset selection using Ontology

2018-08-09 Thread javed khan
Hello Lorenz,

I also have same thinking i.e to make (data property) values (like 1,2,3)
> for each feature and then fetch them . For example, we have dataset of a
> Student and want to predict their performance, with features, name,
> midExam-score, finalExam-score, lecture-attendance, address, etc.. Then
> certainly we dont need here features like name, address so we will assign
> these features a different number (say 2) and assign a number 1 to the
> features which have more relevance.


Lorenz, if you could give me (based on your experience of Semantic Web)
some suggestions here to implement this procedure.

Thanks

On Thu, Aug 9, 2018 at 11:16 AM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

> no no no ...
>
> SPARQL is a query language and not a machine learning algorithm.
>
> RDF dataset D -> SPARQL query Q -> Q(D) = part of the data by means of
> graph pattern matching. there is no induction, confidence values, etc.
>
> define "most appropriate", then write the query to select those
> "features" - to repeate myself, your query just returns facts from the
> RDF dataset. nothing more, nothing less. which facts has to be defined
> by yourself.
>
>
> On 09.08.2018 09:08, javed khan wrote:
> > Hello Lorenz sorry for inconvenience.
> >
> > Suppose we have a dataset about software effort estimation which have
> about
> > 100 attributes (line of code, complexity etc). To extract the subset of
> > features (as all 100 attributes are not important), we usually used some
> > data mining algorithms (Genetic algorithm etc). Now I want to make these
> > attributes as Ontology and get the attributes via SPARQL but not sure how
> > can I select the most appropriate features using SPARQL (because the
> > Genetic algorithm and other select the most appropriate features
> > automatically).
> >
> > Best regards
> >
> > On Thu, Aug 9, 2018 at 7:53 AM, Lorenz Buehmann <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >> Javed...I don't know how many mails you wrote to this list (and the
> >> Protege Users list), but shouldn't you already have learned that you
> >> have to provide more information, data, code, queries, use case, etc. in
> >> order to get help?!
> >>
> >> What do you expect as an answer on a question "can we ..." - my answer
> >> is, "yes, you can". And now?
> >>
> >> Just to clarify, SPARQL is a query language for RDF data, thus, you can
> >> query any explicit information that is contained in an RDF dataset.
> >>
> >>
> >> On 08.08.2018 21:56, javed khan wrote:
> >>> Hello
> >>>
> >>> For instance, we have to select some features ( for data mining) , can
> we
> >>> do it using Semantic Web technologies like Ontology and SPARQL. ?
> >>>
> >>> Thanks
> >>>
> >>
>
>
>


Re: Jena generic rules

2016-07-27 Thread javed khan
I have rule body:I want instance x which are in both classes to assign to
another class "StudentExpert" which have no other instances. But does not
work.
(My Owl inverse property and transitive property rule works but this
generic rule does not work)

String rule = "*[rule1:(?x
 http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type
<http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type>
http://www.semanticweb.org/141#Student
<http://www.semanticweb.org/141#Student>) " +*
*  "(?x
http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type
<http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type>
http://www.semanticweb.org/141#Expert
<http://www.semanticweb.org/141#Expert> )" + *

 "->(?x  http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type
http://www.semanticweb.org/141#StudentExpert )]";

After prefixes, my query is:

"Select * " + "where {  ?x  rdf:type std:StudentExpert.   }";

My Reasoner and InfModel classes are:

Reasoner reasoner2 = new GenericRuleReasoner(Rule.parseRules(rule));

InfModel inf = ModelFactory.createInfModel(reasoner2, model);

Then query is executed as usual in jena.




On Mon, Jul 25, 2016 at 2:38 PM, Dave Reynolds 
wrote:

> On 25/07/16 19:33, javed khan wrote:
>
>> I have a Student class (Phd students) and Teacher class, having instances.
>> There are some students which are also Teacher (teaching to junior
>> classes).
>> ?x rdf:type ont:Student   ?y rdf:type ont:Teacher -->  ?
>> This will give us Students and teachers instances.
>>
>> I want Jena generic rule(Forward chaining) which filters those who are
>> both
>> Teachers and Students. Is there any way to do so?
>>
>
> Yes. You are nearly there but you want the rule body to be more like:
>
> (?x rdf:type ont:Student)  (?x rdf:type ont:Teacher) ->  ...
>
> the rule consequent could assert a new type or some other property to
> indicate that ?x is in both classes.
>
> Dave
>
>


Re: Jena generic rules

2016-07-27 Thread javed khan
I am sorry that is just the mistake when I copy code from my IDE to email.
In the original code, its written just once.

On Wed, Jul 27, 2016 at 1:11 AM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

> I'm not an expert, but why do you have each URI twice in the rule?
>
> > I have rule body:I want instance x which are in both classes to assign to
> > another class "StudentExpert" which have no other instances. But does not
> > work.
> > (My Owl inverse property and transitive property rule works but this
> > generic rule does not work)
> >
> > String rule = "*[rule1:(?x
> >  http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type
> > <http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type>
> > http://www.semanticweb.org/141#Student
> > <http://www.semanticweb.org/141#Student>) " +*
> > *  "(?x
> > http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type
> > <http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type>
> > http://www.semanticweb.org/141#Expert
> > <http://www.semanticweb.org/141#Expert> )" + *
> >
> >  "->(?x  http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type
> > http://www.semanticweb.org/141#StudentExpert )]";
> >
> > After prefixes, my query is:
> >
> > "Select * " + "where {  ?x  rdf:type std:StudentExpert.   }";
> >
> > My Reasoner and InfModel classes are:
> >
> > Reasoner reasoner2 = new GenericRuleReasoner(Rule.parseRules(rule));
> >
> > InfModel inf = ModelFactory.createInfModel(reasoner2, model);
> >
> > Then query is executed as usual in jena.
> >
> >
> >
> >
> > On Mon, Jul 25, 2016 at 2:38 PM, Dave Reynolds <
> dave.e.reyno...@gmail.com>
> > wrote:
> >
> >> On 25/07/16 19:33, javed khan wrote:
> >>
> >>> I have a Student class (Phd students) and Teacher class, having
> instances.
> >>> There are some students which are also Teacher (teaching to junior
> >>> classes).
> >>> ?x rdf:type ont:Student   ?y rdf:type ont:Teacher -->  ?
> >>> This will give us Students and teachers instances.
> >>>
> >>> I want Jena generic rule(Forward chaining) which filters those who are
> >>> both
> >>> Teachers and Students. Is there any way to do so?
> >>>
> >> Yes. You are nearly there but you want the rule body to be more like:
> >>
> >> (?x rdf:type ont:Student)  (?x rdf:type ont:Teacher) ->  ...
> >>
> >> the rule consequent could assert a new type or some other property to
> >> indicate that ?x is in both classes.
> >>
> >> Dave
> >>
> >>
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
>


Re: Jena generic rules

2016-07-27 Thread javed khan
If my email (code) is not understandable, I am just explaining in plain
text.

I have class Expert which have some researches i-e "Tim hasResearch
Ontologies". I have another class Student (subclasses Master Phd). Khan is
instance of Phd class (ultimately of Student class also). Phd student can
also have some researches as Expert class and have type both : Student and
Expert in Protege.

I want instances which are both in Student and Expert i-e Khan in this case.

If ?x rdf:type std:Expert and ?x rdf:type std:Student -> ?x rdf:type
std:StudentExpert (a new class in the ontology).

my query is : select * where { ?x rdf:type std:StudentExpert}

On Wed, Jul 27, 2016 at 1:20 AM, javed khan  wrote:

> I am sorry that is just the mistake when I copy code from my IDE to email.
> In the original code, its written just once.
>
> On Wed, Jul 27, 2016 at 1:11 AM, Lorenz B. <
> buehm...@informatik.uni-leipzig.de> wrote:
>
>> I'm not an expert, but why do you have each URI twice in the rule?
>>
>> > I have rule body:I want instance x which are in both classes to assign
>> to
>> > another class "StudentExpert" which have no other instances. But does
>> not
>> > work.
>> > (My Owl inverse property and transitive property rule works but this
>> > generic rule does not work)
>> >
>> > String rule = "*[rule1:(?x
>> >  http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type
>> > <http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type>
>> > http://www.semanticweb.org/141#Student
>> > <http://www.semanticweb.org/141#Student>) " +*
>> > *  "(?x
>> > http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type
>> > <http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type>
>> > http://www.semanticweb.org/141#Expert
>> > <http://www.semanticweb.org/141#Expert> )" + *
>> >
>> >  "->(?x  http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type
>> > http://www.semanticweb.org/141#StudentExpert )]";
>> >
>> > After prefixes, my query is:
>> >
>> > "Select * " + "where {  ?x  rdf:type std:StudentExpert.   }";
>> >
>> > My Reasoner and InfModel classes are:
>> >
>> > Reasoner reasoner2 = new GenericRuleReasoner(Rule.parseRules(rule));
>> >
>> > InfModel inf = ModelFactory.createInfModel(reasoner2, model);
>> >
>> > Then query is executed as usual in jena.
>> >
>> >
>> >
>> >
>> > On Mon, Jul 25, 2016 at 2:38 PM, Dave Reynolds <
>> dave.e.reyno...@gmail.com>
>> > wrote:
>> >
>> >> On 25/07/16 19:33, javed khan wrote:
>> >>
>> >>> I have a Student class (Phd students) and Teacher class, having
>> instances.
>> >>> There are some students which are also Teacher (teaching to junior
>> >>> classes).
>> >>> ?x rdf:type ont:Student   ?y rdf:type ont:Teacher -->  ?
>> >>> This will give us Students and teachers instances.
>> >>>
>> >>> I want Jena generic rule(Forward chaining) which filters those who are
>> >>> both
>> >>> Teachers and Students. Is there any way to do so?
>> >>>
>> >> Yes. You are nearly there but you want the rule body to be more like:
>> >>
>> >> (?x rdf:type ont:Student)  (?x rdf:type ont:Teacher) ->  ...
>> >>
>> >> the rule consequent could assert a new type or some other property to
>> >> indicate that ?x is in both classes.
>> >>
>> >> Dave
>> >>
>> >>
>> --
>> Lorenz Bühmann
>> AKSW group, University of Leipzig
>> Group: http://aksw.org - semantic web research center
>>
>>
>


Re: Jena generic rules

2016-07-27 Thread javed khan
 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type>

are wrong. Either use the correct URI:

   <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>

or use the prefix form:

   rdf:type


I am sorry due to too many threads, I did not read this reply.

Thanks Dave, let me try.

On Wed, Jul 27, 2016 at 1:35 AM, Dave Reynolds 
wrote:

> See my earlier reply, you had an error in the URLs in your rules.
>
> Dave
>
>
> On 27/07/16 09:33, javed khan wrote:
>
>> If my email (code) is not understandable, I am just explaining in plain
>> text.
>>
>> I have class Expert which have some researches i-e "Tim hasResearch
>> Ontologies". I have another class Student (subclasses Master Phd). Khan is
>> instance of Phd class (ultimately of Student class also). Phd student can
>> also have some researches as Expert class and have type both : Student and
>> Expert in Protege.
>>
>> I want instances which are both in Student and Expert i-e Khan in this
>> case.
>>
>> If ?x rdf:type std:Expert and ?x rdf:type std:Student -> ?x rdf:type
>> std:StudentExpert (a new class in the ontology).
>>
>> my query is : select * where { ?x rdf:type std:StudentExpert}
>>
>> On Wed, Jul 27, 2016 at 1:20 AM, javed khan 
>> wrote:
>>
>> I am sorry that is just the mistake when I copy code from my IDE to email.
>>> In the original code, its written just once.
>>>
>>> On Wed, Jul 27, 2016 at 1:11 AM, Lorenz B. <
>>> buehm...@informatik.uni-leipzig.de> wrote:
>>>
>>> I'm not an expert, but why do you have each URI twice in the rule?
>>>>
>>>> I have rule body:I want instance x which are in both classes to assign
>>>>>
>>>> to
>>>>
>>>>> another class "StudentExpert" which have no other instances. But does
>>>>>
>>>> not
>>>>
>>>>> work.
>>>>> (My Owl inverse property and transitive property rule works but this
>>>>> generic rule does not work)
>>>>>
>>>>> String rule = "*[rule1:(?x
>>>>>   http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type
>>>>> <http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type>
>>>>> http://www.semanticweb.org/141#Student
>>>>> <http://www.semanticweb.org/141#Student>) " +*
>>>>> *  "(?x
>>>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type
>>>>> <http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type>
>>>>> http://www.semanticweb.org/141#Expert
>>>>> <http://www.semanticweb.org/141#Expert> )" + *
>>>>>
>>>>>   "->(?x  http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type
>>>>> http://www.semanticweb.org/141#StudentExpert )]";
>>>>>
>>>>> After prefixes, my query is:
>>>>>
>>>>> "Select * " + "where {  ?x  rdf:type std:StudentExpert.   }";
>>>>>
>>>>> My Reasoner and InfModel classes are:
>>>>>
>>>>> Reasoner reasoner2 = new GenericRuleReasoner(Rule.parseRules(rule));
>>>>>
>>>>> InfModel inf = ModelFactory.createInfModel(reasoner2, model);
>>>>>
>>>>> Then query is executed as usual in jena.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Mon, Jul 25, 2016 at 2:38 PM, Dave Reynolds <
>>>>>
>>>> dave.e.reyno...@gmail.com>
>>>>
>>>>> wrote:
>>>>>
>>>>> On 25/07/16 19:33, javed khan wrote:
>>>>>>
>>>>>> I have a Student class (Phd students) and Teacher class, having
>>>>>>>
>>>>>> instances.
>>>>
>>>>> There are some students which are also Teacher (teaching to junior
>>>>>>> classes).
>>>>>>> ?x rdf:type ont:Student   ?y rdf:type ont:Teacher -->  ?
>>>>>>> This will give us Students and teachers instances.
>>>>>>>
>>>>>>> I want Jena generic rule(Forward chaining) which filters those who
>>>>>>> are
>>>>>>> both
>>>>>>> Teachers and Students. Is there any way to do so?
>>>>>>>
>>>>>>> Yes. You are nearly there but you want the rule body to be more like:
>>>>>>
>>>>>> (?x rdf:type ont:Student)  (?x rdf:type ont:Teacher) ->  ...
>>>>>>
>>>>>> the rule consequent could assert a new type or some other property to
>>>>>> indicate that ?x is in both classes.
>>>>>>
>>>>>> Dave
>>>>>>
>>>>>>
>>>>>> --
>>>> Lorenz Bühmann
>>>> AKSW group, University of Leipzig
>>>> Group: http://aksw.org - semantic web research center
>>>>
>>>>
>>>>
>>>
>>


Re: Jena generic rules

2016-07-27 Thread javed khan
Sorry but still not working.

When I query instances of Expert, it shows "Tim" which is fine. When I
query instance of Student, it shows "Khan", which is also fine.
Even when I query both in one, it shows "Khan" which is also ok because
Khan is also Expert and Student, but when I try to assign it(Khan) to
another class, it does not work.

I am afraid if Jena generic rules does not work on classes and only it
supports properties like transitive property and inverse property.

On Wed, Jul 27, 2016 at 1:39 AM, javed khan  wrote:

>  <http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type>
>
> are wrong. Either use the correct URI:
>
><http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
>
> or use the prefix form:
>
>rdf:type
>
>
> I am sorry due to too many threads, I did not read this reply.
>
> Thanks Dave, let me try.
>
> On Wed, Jul 27, 2016 at 1:35 AM, Dave Reynolds 
> wrote:
>
>> See my earlier reply, you had an error in the URLs in your rules.
>>
>> Dave
>>
>>
>> On 27/07/16 09:33, javed khan wrote:
>>
>>> If my email (code) is not understandable, I am just explaining in plain
>>> text.
>>>
>>> I have class Expert which have some researches i-e "Tim hasResearch
>>> Ontologies". I have another class Student (subclasses Master Phd). Khan
>>> is
>>> instance of Phd class (ultimately of Student class also). Phd student can
>>> also have some researches as Expert class and have type both : Student
>>> and
>>> Expert in Protege.
>>>
>>> I want instances which are both in Student and Expert i-e Khan in this
>>> case.
>>>
>>> If ?x rdf:type std:Expert and ?x rdf:type std:Student -> ?x rdf:type
>>> std:StudentExpert (a new class in the ontology).
>>>
>>> my query is : select * where { ?x rdf:type std:StudentExpert}
>>>
>>> On Wed, Jul 27, 2016 at 1:20 AM, javed khan 
>>> wrote:
>>>
>>> I am sorry that is just the mistake when I copy code from my IDE to
>>>> email.
>>>> In the original code, its written just once.
>>>>
>>>> On Wed, Jul 27, 2016 at 1:11 AM, Lorenz B. <
>>>> buehm...@informatik.uni-leipzig.de> wrote:
>>>>
>>>> I'm not an expert, but why do you have each URI twice in the rule?
>>>>>
>>>>> I have rule body:I want instance x which are in both classes to assign
>>>>>>
>>>>> to
>>>>>
>>>>>> another class "StudentExpert" which have no other instances. But does
>>>>>>
>>>>> not
>>>>>
>>>>>> work.
>>>>>> (My Owl inverse property and transitive property rule works but this
>>>>>> generic rule does not work)
>>>>>>
>>>>>> String rule = "*[rule1:(?x
>>>>>>   http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type
>>>>>> <http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type>
>>>>>> http://www.semanticweb.org/141#Student
>>>>>> <http://www.semanticweb.org/141#Student>) " +*
>>>>>> *  "(?x
>>>>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type
>>>>>> <http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type>
>>>>>> http://www.semanticweb.org/141#Expert
>>>>>> <http://www.semanticweb.org/141#Expert> )" + *
>>>>>>
>>>>>>   "->(?x  http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type
>>>>>> http://www.semanticweb.org/141#StudentExpert )]";
>>>>>>
>>>>>> After prefixes, my query is:
>>>>>>
>>>>>> "Select * " + "where {  ?x  rdf:type std:StudentExpert.   }";
>>>>>>
>>>>>> My Reasoner and InfModel classes are:
>>>>>>
>>>>>> Reasoner reasoner2 = new GenericRuleReasoner(Rule.parseRules(rule));
>>>>>>
>>>>>> InfModel inf = ModelFactory.createInfModel(reasoner2, model);
>>>>>>
>>>>>> Then query is executed as usual in jena.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Mon, Jul 25, 2016 at 2:38 PM, Dave Reynolds <
>>>>>>
>>>>> dave.e.reyno...@gmail.com>
>>>>>
>>>>>> wrote:
>>>>>>
>>>>>> On 25/07/16 19:33, javed khan wrote:
>>>>>>>
>>>>>>> I have a Student class (Phd students) and Teacher class, having
>>>>>>>>
>>>>>>> instances.
>>>>>
>>>>>> There are some students which are also Teacher (teaching to junior
>>>>>>>> classes).
>>>>>>>> ?x rdf:type ont:Student   ?y rdf:type ont:Teacher -->  ?
>>>>>>>> This will give us Students and teachers instances.
>>>>>>>>
>>>>>>>> I want Jena generic rule(Forward chaining) which filters those who
>>>>>>>> are
>>>>>>>> both
>>>>>>>> Teachers and Students. Is there any way to do so?
>>>>>>>>
>>>>>>>> Yes. You are nearly there but you want the rule body to be more
>>>>>>> like:
>>>>>>>
>>>>>>> (?x rdf:type ont:Student)  (?x rdf:type ont:Teacher) ->  ...
>>>>>>>
>>>>>>> the rule consequent could assert a new type or some other property to
>>>>>>> indicate that ?x is in both classes.
>>>>>>>
>>>>>>> Dave
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>> Lorenz Bühmann
>>>>> AKSW group, University of Leipzig
>>>>> Group: http://aksw.org - semantic web research center
>>>>>
>>>>>
>>>>>
>>>>
>>>
>


Re: Jena generic rules

2016-07-27 Thread javed khan
Thanks Dave and Lorenz for your time, I finally fixed it.

I passed "model" as second orgument to QueryExecutionFactory , which should
be InfModel rather..

QueryExecution qe=QueryExecutionFactory.create(query, inf);

regards

On Wed, Jul 27, 2016 at 2:10 AM, Dave Reynolds 
wrote:

> On 27/07/16 09:54, javed khan wrote:
>
>> Sorry but still not working.
>>
>> When I query instances of Expert, it shows "Tim" which is fine. When I
>> query instance of Student, it shows "Khan", which is also fine.
>> Even when I query both in one, it shows "Khan" which is also ok because
>> Khan is also Expert and Student, but when I try to assign it(Khan) to
>> another class, it does not work.
>>
>
> That's too imprecise to comment on.
>
> If you can show exactly your data and your rules then we might be able to
> spot the problem.
>
> I am afraid if Jena generic rules does not work on classes and only it
>> supports properties like transitive property and inverse property.
>>
>
> Generic rules just work in terms of triples. They can be used on instances
> or classes equally well. You just need to be clear on what you rules need
> to do and write the patterns accordingly.
>
> Dave
>
>
>
> On Wed, Jul 27, 2016 at 1:39 AM, javed khan  wrote:
>>
>>   <http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type>
>>>
>>> are wrong. Either use the correct URI:
>>>
>>> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
>>>
>>> or use the prefix form:
>>>
>>> rdf:type
>>>
>>>
>>> I am sorry due to too many threads, I did not read this reply.
>>>
>>> Thanks Dave, let me try.
>>>
>>> On Wed, Jul 27, 2016 at 1:35 AM, Dave Reynolds <
>>> dave.e.reyno...@gmail.com>
>>> wrote:
>>>
>>> See my earlier reply, you had an error in the URLs in your rules.
>>>>
>>>> Dave
>>>>
>>>>
>>>> On 27/07/16 09:33, javed khan wrote:
>>>>
>>>> If my email (code) is not understandable, I am just explaining in plain
>>>>> text.
>>>>>
>>>>> I have class Expert which have some researches i-e "Tim hasResearch
>>>>> Ontologies". I have another class Student (subclasses Master Phd). Khan
>>>>> is
>>>>> instance of Phd class (ultimately of Student class also). Phd student
>>>>> can
>>>>> also have some researches as Expert class and have type both : Student
>>>>> and
>>>>> Expert in Protege.
>>>>>
>>>>> I want instances which are both in Student and Expert i-e Khan in this
>>>>> case.
>>>>>
>>>>> If ?x rdf:type std:Expert and ?x rdf:type std:Student -> ?x rdf:type
>>>>> std:StudentExpert (a new class in the ontology).
>>>>>
>>>>> my query is : select * where { ?x rdf:type std:StudentExpert}
>>>>>
>>>>> On Wed, Jul 27, 2016 at 1:20 AM, javed khan 
>>>>> wrote:
>>>>>
>>>>> I am sorry that is just the mistake when I copy code from my IDE to
>>>>>
>>>>>> email.
>>>>>> In the original code, its written just once.
>>>>>>
>>>>>> On Wed, Jul 27, 2016 at 1:11 AM, Lorenz B. <
>>>>>> buehm...@informatik.uni-leipzig.de> wrote:
>>>>>>
>>>>>> I'm not an expert, but why do you have each URI twice in the rule?
>>>>>>
>>>>>>>
>>>>>>> I have rule body:I want instance x which are in both classes to
>>>>>>> assign
>>>>>>>
>>>>>>>>
>>>>>>>> to
>>>>>>>
>>>>>>> another class "StudentExpert" which have no other instances. But does
>>>>>>>>
>>>>>>>> not
>>>>>>>
>>>>>>> work.
>>>>>>>> (My Owl inverse property and transitive property rule works but this
>>>>>>>> generic rule does not work)
>>>>>>>>
>>>>>>>> String rule = "*[rule1:(?x
>>>>>>>>http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type
>>>>>>>> <http://www.w3.org/1999/02/22-rdf-syntax-ns#rdf:type>
>>>>>>>> http://www.semanticw

Operations on Jena rules

2016-07-28 Thread javed khan
I have instances from GraduateCourses and UnderGradCourses classes:

GraduateCourses UnderGradCourses

Computer Vision   Databases
Network Security   Network Security
Neural NetworksAssembly Language
Semantic Web  Semantic Web

?x  rdf:type  std:GradCourses?y  rdf:type
 std:UnderGradCourses

Now ?x  and  ?y  contains courses with "Semantic Web and Network security"
common in both.

Can we do some arithmetic or comparison inside Jena rules which will
query/answer us the courses which are common in both?


Re: Operations on Jena rules

2016-07-28 Thread javed khan
can we do this:

(?a rdf:type :SemanticWeb)
   (?a rdf:type :NetworkSecurity)

Because SemanticWeb and NetworkSecurity are instances and not classes.?

On Thu, Jul 28, 2016 at 11:42 AM, Paul Houle  wrote:

> Something like
>
> [
>(?a rdf:type :SemanticWeb)
>(?a rdf:type :NetworkSecurity)
> ->
>(?a rdf:type :SemanticWebAndNetworkSecurity)
> ]
>
> ?
>
>
> On Thu, Jul 28, 2016 at 2:36 PM, javed khan  wrote:
>
> > I have instances from GraduateCourses and UnderGradCourses classes:
> >
> > GraduateCourses UnderGradCourses
> >
> > Computer Vision   Databases
> > Network Security   Network Security
> > Neural NetworksAssembly Language
> > Semantic Web  Semantic Web
> >
> > ?x  rdf:type  std:GradCourses?y  rdf:type
> >  std:UnderGradCourses
> >
> > Now ?x  and  ?y  contains courses with "Semantic Web and Network
> security"
> > common in both.
> >
> > Can we do some arithmetic or comparison inside Jena rules which will
> > query/answer us the courses which are common in both?
> >
>
>
>
> --
> Paul Houle
>
> *Applying Schemas for Natural Language Processing, Distributed Systems,
> Classification and Text Mining and Data Lakes*
>
> (607) 539 6254paul.houle on Skype   ontolo...@gmail.com
>
> :BaseKB -- Query Freebase Data With SPARQL
> http://basekb.com/gold/
>
> Legal Entity Identifier Lookup
> https://legalentityidentifier.info/lei/lookup/
> <http://legalentityidentifier.info/lei/lookup/>
>
> Join our Data Lakes group on LinkedIn
> https://www.linkedin.com/grp/home?gid=8267275
>


Re: Operations on Jena rules

2016-07-28 Thread javed khan
Hello Dave, thanks a lot. It works.

 -> (?x rdf:type std:BothGradAndUnderGradCourses)

Initially I thought, it will copy all the four instances of GradCourses and
all the four instances of UnderGradCourses to the new class "
std:BothGradAndUnderGradCourses"

I am surprised which operator/logic actually used in the above (Then) part
of the rule which has perform the intersection?

On Thu, Jul 28, 2016 at 1:08 PM, Dave Reynolds 
wrote:

> On 28/07/16 19:36, javed khan wrote:
>
>> I have instances from GraduateCourses and UnderGradCourses classes:
>>
>> GraduateCourses UnderGradCourses
>>
>> Computer Vision   Databases
>> Network Security   Network Security
>> Neural NetworksAssembly Language
>> Semantic Web  Semantic Web
>>
>> ?x  rdf:type  std:GradCourses?y  rdf:type
>>  std:UnderGradCourses
>>
>> Now ?x  and  ?y  contains courses with "Semantic Web and Network security"
>> common in both.
>>
>> Can we do some arithmetic or comparison inside Jena rules which will
>> query/answer us the courses which are common in both?
>>
>>
> (?x rdf:type std:GradCourses) (?x rdf:type std:UnderGradCourses)
>-> (?x rdf:type std:BothGradAndUnderGradCourses)
>
> or whatever you want to call the intersection class.
>
> This sort of intersection checking is possible in rules, in OWL or in
> SPARQL queries. Just depends what you want to do.
>
> Dave
>
>


Re: Operations on Jena rules

2016-07-28 Thread javed khan
Thanks Adrian, I got the logic. I did not notice it before, thats why
experience matters.

On Thu, Jul 28, 2016 at 2:05 PM, Dave Reynolds 
wrote:

> On 28/07/16 21:31, javed khan wrote:
>
>> Hello Dave, thanks a lot. It works.
>>
>>  -> (?x rdf:type std:BothGradAndUnderGradCourses)
>>
>> Initially I thought, it will copy all the four instances of GradCourses
>> and
>> all the four instances of UnderGradCourses to the new class "
>> std:BothGradAndUnderGradCourses"
>>
>> I am surprised which operator/logic actually used in the above (Then) part
>> of the rule which has perform the intersection?
>>
>
> None. There is an implicit "AND" between each term in the *if* part of the
> rules. Think of the rules as being:
>
>   (pattern1) AND (pattern2) AND ... -> (conclusion-pattern)
>
> So only if ?x is a GradCourse AND ?x is an UnderGradCourse do we assert
> that ?x is a BothGradAndUnderGradCourse.
>
> Dave
>
>
> On Thu, Jul 28, 2016 at 1:08 PM, Dave Reynolds 
>> wrote:
>>
>> On 28/07/16 19:36, javed khan wrote:
>>>
>>> I have instances from GraduateCourses and UnderGradCourses classes:
>>>>
>>>> GraduateCourses UnderGradCourses
>>>>
>>>> Computer Vision   Databases
>>>> Network Security   Network Security
>>>> Neural NetworksAssembly Language
>>>> Semantic Web  Semantic Web
>>>>
>>>> ?x  rdf:type  std:GradCourses?y  rdf:type
>>>>  std:UnderGradCourses
>>>>
>>>> Now ?x  and  ?y  contains courses with "Semantic Web and Network
>>>> security"
>>>> common in both.
>>>>
>>>> Can we do some arithmetic or comparison inside Jena rules which will
>>>> query/answer us the courses which are common in both?
>>>>
>>>>
>>>> (?x rdf:type std:GradCourses) (?x rdf:type std:UnderGradCourses)
>>>-> (?x rdf:type std:BothGradAndUnderGradCourses)
>>>
>>> or whatever you want to call the intersection class.
>>>
>>> This sort of intersection checking is possible in rules, in OWL or in
>>> SPARQL queries. Just depends what you want to do.
>>>
>>> Dave
>>>
>>>
>>>
>>
>


Jena rules on data properties

2016-08-17 Thread javed khan
Hello

Can we use the Jena rules like Jena generic rules or transitive rules on
data properties like we do on Object properties?

If yes, then the same method is used or some sort of modification(s)
required?

Regards


Arithmetic in Jena rules

2016-08-25 Thread javed khan
Can we do some mathematical/arithmetic operations on the Jena rules. For
instance, if we want to do something like this: if some Employee has salary
more than ten thousands dollars, then Employee is on Manager post.

Can we do this and others like (>=, <=, ==) ?

Any web links to the literature related to this will be highly appreciated?

Thank you.


Re: Arithmetic in Jena rules

2016-08-26 Thread javed khan
Thank you Niels for your time.

regards

On Thu, Aug 25, 2016 at 12:36 PM, Niels Andersen  wrote:

> See LessThan and GreaterThan here https://jena.apache.org/
> documentation/inference/#builtin-primitives
>
> Niels
>
> -Original Message-----
> From: javed khan [mailto:javedbtk...@gmail.com]
> Sent: Thursday, August 25, 2016 11:34
> To: users@jena.apache.org
> Subject: Arithmetic in Jena rules
>
> Can we do some mathematical/arithmetic operations on the Jena rules. For
> instance, if we want to do something like this: if some Employee has salary
> more than ten thousands dollars, then Employee is on Manager post.
>
> Can we do this and others like (>=, <=, ==) ?
>
> Any web links to the literature related to this will be highly appreciated?
>
> Thank you.
>


Jena rules

2016-09-01 Thread javed khan
Hello I have Employee ontology where different employees have different
positions and tasks. Some are in technical positions performing technical
tasks and have low salaries. Some are on managerial posts and have huge
salaries.
I will add salaries dynamically using Jena for each employee using Property
and value.

Select * where { emp:employee emp:hasTask ?task} It will display all
employees tasks i-e both technical and managerial.

I need Jena rules in which we can say: emp:employee emp:hasSalary greater
than $4,000, the query returns only managerial tasks and technical tasks
hides from her.

Thanks for understanding my problem. If some one needs more explanation, I
can provide.

regards


Re: Jena rules

2016-09-02 Thread javed khan
Thanks Paul, I need Jena rules but I will also keen to know how can it be
achieved using changing the query?

On Thu, Sep 1, 2016 at 5:03 PM, Paul Houle  wrote:

> Do you really need to use rules or would you be OK with just changing the
> query a little?
>
> Also,  do you have a sample of the data you are using?
>
> On Thu, Sep 1, 2016 at 2:53 PM, javed khan  wrote:
>
> > Hello I have Employee ontology where different employees have different
> > positions and tasks. Some are in technical positions performing technical
> > tasks and have low salaries. Some are on managerial posts and have huge
> > salaries.
> > I will add salaries dynamically using Jena for each employee using
> Property
> > and value.
> >
> > Select * where { emp:employee emp:hasTask ?task} It will display all
> > employees tasks i-e both technical and managerial.
> >
> > I need Jena rules in which we can say: emp:employee emp:hasSalary greater
> > than $4,000, the query returns only managerial tasks and technical tasks
> > hides from her.
> >
> > Thanks for understanding my problem. If some one needs more explanation,
> I
> > can provide.
> >
> > regards
> >
>
>
>
> --
> Paul Houle
>
> (607) 539 6254paul.houle on Skype   ontolo...@gmail.com
>
> Ontology2 Edition of DBpedia 2015-10
> https://aws.amazon.com/marketplace/pp/B01HMUNH4Q/ <http://basekb.com/gold/
> >
> http://ontology2.com/the-book/o2dbpedia-info.html
> http://ontology2.com/book/chapter2/part1/dbpedia-examples.html
>
> RDF: A new Slant
> http://ontology2.com/the-book/rdf-a-new-slant.html
> <https://www.linkedin.com/grp/home?gid=8267275>
>
> Data Lakes, Data Ponds, and Data Droplets
> http://ontology2.com/the-book/data-lakes-ponds-and-droplets.html
>


Jena rules to assign individuals to subclasses

2016-09-06 Thread javed khan
I have *Student* class, having *ExcellentStudents* and *PoorStudents* as
subclasses.
My ontology contains Student *marks* (*marks is data property*) and based
on marks students can be assigned to ExcellentStudents and PoorStudents.

My requirements is to achieve it using Jena rules. I need some help in
getting to this.  I want something like :

If Student X marks>60, assign Student X to ExcellentStudent class else
assign to PoorStudents class. I have attempted the following but could not
succeeded.


String rule = "[rule1:"(?x
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.owlontologies.com/Student.owl#*Student*)+

 (?x http://www.owl-ontologies.com/Student.owl#marks  *>60*)" +


 "->(?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.owlontologies.com/Student.owl#*ExcellentStudent*)]";


I think the problem will be in marks>60 because I do not know how to
compare things inside Jena rules.


Re: Jena rules to assign individuals to subclasses

2016-09-06 Thread javed khan
Thanks Soroka.

I do not know how to use* greaterThan(?x, ?y) here in my case? How can I
compare the marks data property with this?*

On Tue, Sep 6, 2016 at 12:09 PM, A. Soroka  wrote:

> https://jena.apache.org/documentation/inference/index.html#RULEbuiltins
>
> ---
> A. Soroka
> The University of Virginia Library
>
> > On Sep 6, 2016, at 3:05 PM, javed khan  wrote:
> >
> > I have *Student* class, having *ExcellentStudents* and *PoorStudents* as
> > subclasses.
> > My ontology contains Student *marks* (*marks is data property*) and based
> > on marks students can be assigned to ExcellentStudents and PoorStudents.
> >
> > My requirements is to achieve it using Jena rules. I need some help in
> > getting to this.  I want something like :
> >
> > If Student X marks>60, assign Student X to ExcellentStudent class else
> > assign to PoorStudents class. I have attempted the following but could
> not
> > succeeded.
> >
> >
> > String rule = "[rule1:"(?x
> > http://www.w3.org/1999/02/22-rdf-syntax-ns#type
> > http://www.owlontologies.com/Student.owl#*Student*)+
> >
> > (?x http://www.owl-ontologies.com/Student.owl#marks  *>60*)" +
> >
> >
> > "->(?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type
> > http://www.owlontologies.com/Student.owl#*ExcellentStudent*)]";
> >
> >
> > I think the problem will be in marks>60 because I do not know how to
> > compare things inside Jena rules.
>
>


Re: Jena rules to assign individuals to subclasses

2016-09-07 Thread javed khan
Thanks Soroka for your help.

On Tue, Sep 6, 2016 at 12:46 PM, A. Soroka  wrote:

> [ exstu: (?stu rdf:type Student), (?stu marks ?m), greaterThan(?m, 60) ->
> (?stu rdf:type ExcellentStudents) ]
>
> is one way to do this. Please look at the examples on that same page.
>
> ---
> A. Soroka
> The University of Virginia Library
>
> > On Sep 6, 2016, at 3:30 PM, javed khan  wrote:
> >
> > Thanks Soroka.
> >
> > I do not know how to use* greaterThan(?x, ?y) here in my case? How can I
> > compare the marks data property with this?*
> >
> > On Tue, Sep 6, 2016 at 12:09 PM, A. Soroka  wrote:
> >
> >> https://jena.apache.org/documentation/inference/index.html#RULEbuiltins
> >>
> >> ---
> >> A. Soroka
> >> The University of Virginia Library
> >>
> >>> On Sep 6, 2016, at 3:05 PM, javed khan  wrote:
> >>>
> >>> I have *Student* class, having *ExcellentStudents* and *PoorStudents*
> as
> >>> subclasses.
> >>> My ontology contains Student *marks* (*marks is data property*) and
> based
> >>> on marks students can be assigned to ExcellentStudents and
> PoorStudents.
> >>>
> >>> My requirements is to achieve it using Jena rules. I need some help in
> >>> getting to this.  I want something like :
> >>>
> >>> If Student X marks>60, assign Student X to ExcellentStudent class else
> >>> assign to PoorStudents class. I have attempted the following but could
> >> not
> >>> succeeded.
> >>>
> >>>
> >>> String rule = "[rule1:"(?x
> >>> http://www.w3.org/1999/02/22-rdf-syntax-ns#type
> >>> http://www.owlontologies.com/Student.owl#*Student*)+
> >>>
> >>> (?x http://www.owl-ontologies.com/Student.owl#marks  *>60*)" +
> >>>
> >>>
> >>>"->(?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type
> >>> http://www.owlontologies.com/Student.owl#*ExcellentStudent*)]";
> >>>
> >>>
> >>> I think the problem will be in marks>60 because I do not know how to
> >>> compare things inside Jena rules.
> >>
> >>
>
>


Jena rules Error

2016-09-17 Thread javed khan
String rule="[rule1:(?x   http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.semanticweb.org#Student) " +

 "( http://www.semanticweb.org#Student
http://www.semanticweb.org#GPA  ?gpa)   +  greaterThan(?gpa, 3)

 " ->  (?x   http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.semanticweb.org#GoodUser )]";

GPA is a data property here, but it gives me error. I think the error is
in greaterThan(?score, 10)

What is the error ?


Re: Jena rules Error

2016-09-17 Thread javed khan
The error goes away but the rules does not work i-e I can not find the rdf
type of GoodUser/GoodStudent.
Also after result display, it gives me some exception .

Exception in thread "AWT-EventQueue-0"
com.hp.hpl.jena.reasoner.rulesys.Rule$ParserException: Triple with 4 nodes!
At '[ rule1: ( ?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.semanticweb.org/t/ontologies/2016/7/myOWL#User ) (
http://www.semanticweb.org/t/ontologies/2016/7/myOWL#User
http://www.semanticweb.org/t/ontologies/2016/7/myOWL#score ?score + ) '

On Sat, Sep 17, 2016 at 12:15 PM, javed khan  wrote:

> String rule="[rule1:(?x   http://www.w3.org/1999/02/22-rdf-syntax-ns#type
>  http://www.semanticweb.org#Student) " +
>
>  "( http://www.semanticweb.org#Student
> http://www.semanticweb.org#GPA  ?gpa)   +  greaterThan(?gpa, 3)
>
>  " ->  (?x   http://www.w3.org/1999/02/22-rdf-syntax-ns#type
> http://www.semanticweb.org#GoodUser )]";
>
> GPA is a data property here, but it gives me error. I think the error is
> in greaterThan(?score, 10)
>
> What is the error ?
>


Re: Jena rules Error

2016-09-18 Thread javed khan
Hello Dave, thank you for your comment but is the semantic (logic) in the
rule above correct? Because it does not give me the required result and
when I query ?student rdf:type std:GoodStudent, it does not give me any
result.

Regards

On Sun, Sep 18, 2016 at 1:11 AM, Dave Reynolds 
wrote:

> On 17/09/16 22:31, javed khan wrote:
>
>> The error goes away but the rules does not work i-e I can not find the rdf
>> type of GoodUser/GoodStudent.
>> Also after result display, it gives me some exception .
>>
>> Exception in thread "AWT-EventQueue-0"
>> com.hp.hpl.jena.reasoner.rulesys.Rule$ParserException: Triple with 4
>> nodes!
>> At '[ rule1: ( ?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type
>> http://www.semanticweb.org/t/ontologies/2016/7/myOWL#User ) (
>> http://www.semanticweb.org/t/ontologies/2016/7/myOWL#User
>> http://www.semanticweb.org/t/ontologies/2016/7/myOWL#score ?score + ) '
>>
>
> Look closely at the line above. You can see that there's a spurious "+"
> character in your string.
>
> Dave
>
>
>
>> On Sat, Sep 17, 2016 at 12:15 PM, javed khan 
>> wrote:
>>
>> String rule="[rule1:(?x   http://www.w3.org/1999/02/22-rdf-syntax-ns#type
>>>  http://www.semanticweb.org#Student) " +
>>>
>>>  "( http://www.semanticweb.org#Student
>>> http://www.semanticweb.org#GPA  ?gpa)   +  greaterThan(?gpa, 3)
>>>
>>>  " ->  (?x   http://www.w3.org/1999/02/22-rdf-syntax-ns#type
>>> http://www.semanticweb.org#GoodUser )]";
>>>
>>> GPA is a data property here, but it gives me error. I think the error is
>>> in greaterThan(?score, 10)
>>>
>>> What is the error ?
>>>
>>>
>>
>


Jena rules not working

2016-09-18 Thread javed khan
This code does not work. I want to save student marks/GPA in the file and
based on GPA assign students to GoodStudent or WorstStudents sub classes of
Student via Jena rules.




OntModel model=ModelFactory.createOntologyModel();

 InputStream in =FileManager.get().open("C://std.owl");
if (in==null) {
throw new IllegalArgumentException( "File: " +  " not
found");
}   model.read(in,"");

 String ns="http://www.semanticweb.org#";;

OntClass user1 = model.getOntClass(ns + "Student");

   Individual indiv = user1.createIndividual(ns + name); //name is
variable

Property prop= model.getProperty(ns,"GPA");

indiv.addLiteral(prop, marks); //marks also variable having
some value i-e 3.0



 String rule="[rule1:(?x   http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.semanticweb.org#Student) " +
 "( http://www.semanticweb.org#Student
http://www.semanticweb.org#GPA  ?marks +   )"   + "greaterThan(?marks, 2) "+
 " ->  (?x   http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.semanticweb.org#GoodStudent )]";

 String queryString= "PREFIX std:
"+
 "PREFIX rdfs: "  +
  "PREFIX rdf: "+
  "SELECT  * " +
" WHERE {  ?x rdf:type std:GoodStudent}";

 Reasoner reasoner2 = new
GenericRuleReasoner(Rule.parseRules(rule));
  InfModel inf = ModelFactory.createInfModel(reasoner2, model);
 Query query = QueryFactory.create(queryString);
  QueryExecution qe = QueryExecutionFactory.create(query, inf);
 ResultSet results = qe.execSelect();
 ResultSetFormatter.out(System.out, results, query);
 qe.close();



 try (FileOutputStream writer = new
FileOutputStream("C://std.owl")) {
model.write(writer, "RDF/XML");
} catch (IOException ex) {
Logger.getLogger(stdinfo.class.getName()).log(Level.SEVERE,
null, ex);
}
model.write(System.out, "N3");

}


Re: Jena rules not working

2016-09-18 Thread javed khan
Thanks Lorenz and Dave, I have corrected the  http://www.semanticweb.org#
<http://www.semanticweb.org/#GPA>Student to ?x but it does not
work.Actually it does not save the updated marks/GPA of student and when I
remove the Jena rules part, it then updates and save the GPA.
I also try the SPARQL query inside Protege Query tab but it does not give
me any instance of the GoodStudent class.

On Sun, Sep 18, 2016 at 12:40 PM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

> The second condition of your rule doesn't make any sense as the subject
> is Student and it should be ?x.
>
>
> On 18.09.2016 17:41, javed khan wrote:
> > This code does not work. I want to save student marks/GPA in the file and
> > based on GPA assign students to GoodStudent or WorstStudents sub classes
> of
> > Student via Jena rules.
> >
> >
> >
> >
> > OntModel model=ModelFactory.createOntologyModel();
> >
> >  InputStream in =FileManager.get().open("C://std.owl");
> > if (in==null) {
> > throw new IllegalArgumentException( "File: " +  " not
> > found");
> > }   model.read(in,"");
> >
> >  String ns="http://www.semanticweb.org#";;
> >
> > OntClass user1 = model.getOntClass(ns + "Student");
> >
> >Individual indiv = user1.createIndividual(ns + name); //name
> is
> > variable
> >
> > Property prop= model.getProperty(ns,"GPA");
> >
> > indiv.addLiteral(prop, marks); //marks also variable having
> > some value i-e 3.0
> >
> >
> >
> >  String rule="[rule1:(?x   http://www.w3.org/1999/02/22-
> rdf-syntax-ns#type
> > http://www.semanticweb.org#Student) " +
> >  "( http://www.semanticweb.org#Student
> > http://www.semanticweb.org#GPA  ?marks +   )"   + "greaterThan(?marks,
> 2) "+
> >  " ->  (?x   http://www.w3.org/1999/02/22-rdf-syntax-ns#type
> > http://www.semanticweb.org#GoodStudent )]";
> >
> >  String queryString= "PREFIX std:<http://www.semanticweb.
> org#>
> > "+
> >  "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "  +
> >   "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "+
> >   "SELECT  * " +
> > " WHERE {  ?x rdf:type std:GoodStudent}";
> >
> >  Reasoner reasoner2 = new
> > GenericRuleReasoner(Rule.parseRules(rule));
> >   InfModel inf = ModelFactory.createInfModel(reasoner2, model);
> >  Query query = QueryFactory.create(queryString);
> >   QueryExecution qe = QueryExecutionFactory.create(query, inf);
> >  ResultSet results = qe.execSelect();
> >  ResultSetFormatter.out(System.out, results, query);
> >  qe.close();
> >
> >
> >
> >  try (FileOutputStream writer = new
> > FileOutputStream("C://std.owl")) {
> > model.write(writer, "RDF/XML");
> > } catch (IOException ex) {
> > Logger.getLogger(stdinfo.class.getName()).log(Level.SEVERE,
> > null, ex);
> > }
> > model.write(System.out, "N3");
> >
> > }
> >
>
>


Re: Jena rules not working

2016-09-18 Thread javed khan
Thanks a lot Dave, let me try it. I hope it will help.

Regards

On Sun, Sep 18, 2016 at 1:28 PM, Dave Reynolds 
wrote:

> On 18/09/16 21:24, javed khan wrote:
>
>> Thanks Lorenz and Dave, I have corrected the  http://www.semanticweb.org#
>> <http://www.semanticweb.org/#GPA>Student to ?x but it does not
>> work.Actually it does not save the updated marks/GPA of student and when I
>> remove the Jena rules part, it then updates and save the GPA.
>> I also try the SPARQL query inside Protege Query tab but it does not give
>> me any instance of the GoodStudent class.
>>
>
> The example I showed does work. If you write inf to file or std out you
> can see the class, if you run your sparql query it lists s1.
>
> Dave
>
>
> On Sun, Sep 18, 2016 at 12:40 PM, Lorenz Buehmann <
>> buehm...@informatik.uni-leipzig.de> wrote:
>>
>> The second condition of your rule doesn't make any sense as the subject
>>> is Student and it should be ?x.
>>>
>>>
>>> On 18.09.2016 17:41, javed khan wrote:
>>>
>>>> This code does not work. I want to save student marks/GPA in the file
>>>> and
>>>> based on GPA assign students to GoodStudent or WorstStudents sub classes
>>>>
>>> of
>>>
>>>> Student via Jena rules.
>>>>
>>>>
>>>>
>>>>
>>>> OntModel model=ModelFactory.createOntologyModel();
>>>>
>>>>  InputStream in =FileManager.get().open("C://std.owl");
>>>> if (in==null) {
>>>> throw new IllegalArgumentException( "File: " +  " not
>>>> found");
>>>> }   model.read(in,"");
>>>>
>>>>  String ns="http://www.semanticweb.org#";;
>>>>
>>>> OntClass user1 = model.getOntClass(ns + "Student");
>>>>
>>>>Individual indiv = user1.createIndividual(ns + name); //name
>>>>
>>> is
>>>
>>>> variable
>>>>
>>>> Property prop= model.getProperty(ns,"GPA");
>>>>
>>>> indiv.addLiteral(prop, marks); //marks also variable having
>>>> some value i-e 3.0
>>>>
>>>>
>>>>
>>>>  String rule="[rule1:(?x   http://www.w3.org/1999/02/22-
>>>>
>>> rdf-syntax-ns#type
>>>
>>>> http://www.semanticweb.org#Student) " +
>>>>  "( http://www.semanticweb.org#Student
>>>> http://www.semanticweb.org#GPA  ?marks +   )"   + "greaterThan(?marks,
>>>>
>>> 2) "+
>>>
>>>>  " ->  (?x   http://www.w3.org/1999/02/22-rdf-syntax-ns#type
>>>> http://www.semanticweb.org#GoodStudent )]";
>>>>
>>>>  String queryString= "PREFIX std:<http://www.semanticweb.
>>>>
>>> org#>
>>>
>>>> "+
>>>>  "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "  +
>>>>   "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "+
>>>>   "SELECT  * " +
>>>> " WHERE {  ?x rdf:type std:GoodStudent}";
>>>>
>>>>  Reasoner reasoner2 = new
>>>> GenericRuleReasoner(Rule.parseRules(rule));
>>>>   InfModel inf = ModelFactory.createInfModel(reasoner2, model);
>>>>  Query query = QueryFactory.create(queryString);
>>>>   QueryExecution qe = QueryExecutionFactory.create(query, inf);
>>>>  ResultSet results = qe.execSelect();
>>>>  ResultSetFormatter.out(System.out, results, query);
>>>>  qe.close();
>>>>
>>>>
>>>>
>>>>  try (FileOutputStream writer = new
>>>> FileOutputStream("C://std.owl")) {
>>>> model.write(writer, "RDF/XML");
>>>> } catch (IOException ex) {
>>>> Logger.getLogger(stdinfo.class.getName()).log(Level.SEVERE,
>>>> null, ex);
>>>> }
>>>> model.write(System.out, "N3");
>>>>
>>>> }
>>>>
>>>>
>>>
>>>
>>
>


Re: Jena rules not working

2016-09-19 Thread javed khan
Hello Dave, though I have Student class in my owl and GoodStudent as the
subclass of Student but this statement gives me error and does not
recognize GoodStudent.

 for (Iterator i = inf.listResourcesWithProperty(RDF.type, *GoodStudent*);
i.hasNext();) {
System.out.println("Good student: " + i.next());

On Sun, Sep 18, 2016 at 1:36 PM, javed khan  wrote:

> Thanks a lot Dave, let me try it. I hope it will help.
>
> Regards
>
> On Sun, Sep 18, 2016 at 1:28 PM, Dave Reynolds 
> wrote:
>
>> On 18/09/16 21:24, javed khan wrote:
>>
>>> Thanks Lorenz and Dave, I have corrected the
>>> http://www.semanticweb.org#
>>> <http://www.semanticweb.org/#GPA>Student to ?x but it does not
>>> work.Actually it does not save the updated marks/GPA of student and when
>>> I
>>> remove the Jena rules part, it then updates and save the GPA.
>>> I also try the SPARQL query inside Protege Query tab but it does not give
>>> me any instance of the GoodStudent class.
>>>
>>
>> The example I showed does work. If you write inf to file or std out you
>> can see the class, if you run your sparql query it lists s1.
>>
>> Dave
>>
>>
>> On Sun, Sep 18, 2016 at 12:40 PM, Lorenz Buehmann <
>>> buehm...@informatik.uni-leipzig.de> wrote:
>>>
>>> The second condition of your rule doesn't make any sense as the subject
>>>> is Student and it should be ?x.
>>>>
>>>>
>>>> On 18.09.2016 17:41, javed khan wrote:
>>>>
>>>>> This code does not work. I want to save student marks/GPA in the file
>>>>> and
>>>>> based on GPA assign students to GoodStudent or WorstStudents sub
>>>>> classes
>>>>>
>>>> of
>>>>
>>>>> Student via Jena rules.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> OntModel model=ModelFactory.createOntologyModel();
>>>>>
>>>>>  InputStream in =FileManager.get().open("C://std.owl");
>>>>> if (in==null) {
>>>>> throw new IllegalArgumentException( "File: " +  " not
>>>>> found");
>>>>> }   model.read(in,"");
>>>>>
>>>>>  String ns="http://www.semanticweb.org#";;
>>>>>
>>>>> OntClass user1 = model.getOntClass(ns + "Student");
>>>>>
>>>>>Individual indiv = user1.createIndividual(ns + name); //name
>>>>>
>>>> is
>>>>
>>>>> variable
>>>>>
>>>>> Property prop= model.getProperty(ns,"GPA");
>>>>>
>>>>> indiv.addLiteral(prop, marks); //marks also variable having
>>>>> some value i-e 3.0
>>>>>
>>>>>
>>>>>
>>>>>  String rule="[rule1:(?x   http://www.w3.org/1999/02/22-
>>>>>
>>>> rdf-syntax-ns#type
>>>>
>>>>> http://www.semanticweb.org#Student) " +
>>>>>  "( http://www.semanticweb.org#Student
>>>>> http://www.semanticweb.org#GPA  ?marks +   )"   + "greaterThan(?marks,
>>>>>
>>>> 2) "+
>>>>
>>>>>  " ->  (?x   http://www.w3.org/1999/02/22-rdf-syntax-ns#type
>>>>> http://www.semanticweb.org#GoodStudent )]";
>>>>>
>>>>>  String queryString= "PREFIX std:<http://www.semanticweb.
>>>>>
>>>> org#>
>>>>
>>>>> "+
>>>>>  "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "  +
>>>>>   "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "+
>>>>>   "SELECT  * " +
>>>>> " WHERE {  ?x rdf:type std:GoodStudent}";
>>>>>
>>>>>  Reasoner reasoner2 = new
>>>>> GenericRuleReasoner(Rule.parseRules(rule));
>>>>>   InfModel inf = ModelFactory.createInfModel(reasoner2, model);
>>>>>  Query query = QueryFactory.create(queryString);
>>>>>   QueryExecution qe = QueryExecutionFactory.create(query,
>>>>> inf);
>>>>>  ResultSet results = qe.execSelect();
>>>>>  ResultSetFormatter.out(System.out, results, query);
>>>>>  qe.close();
>>>>>
>>>>>
>>>>>
>>>>>  try (FileOutputStream writer = new
>>>>> FileOutputStream("C://std.owl")) {
>>>>> model.write(writer, "RDF/XML");
>>>>> } catch (IOException ex) {
>>>>> Logger.getLogger(stdinfo.class
>>>>> .getName()).log(Level.SEVERE,
>>>>> null, ex);
>>>>> }
>>>>> model.write(System.out, "N3");
>>>>>
>>>>> }
>>>>>
>>>>>
>>>>
>>>>
>>>
>>
>


Re: Jena rules not working

2016-09-19 Thread javed khan
It does not recognize the class name but only property names.

On Mon, Sep 19, 2016 at 9:14 AM, javed khan  wrote:

> Hello Dave, though I have Student class in my owl and GoodStudent as the
> subclass of Student but this statement gives me error and does not
> recognize GoodStudent.
>
>  for (Iterator i = inf.listResourcesWithProperty(RDF.type, *GoodStudent*);
> i.hasNext();) {
> System.out.println("Good student: " + i.next());
>
> On Sun, Sep 18, 2016 at 1:36 PM, javed khan  wrote:
>
>> Thanks a lot Dave, let me try it. I hope it will help.
>>
>> Regards
>>
>> On Sun, Sep 18, 2016 at 1:28 PM, Dave Reynolds > > wrote:
>>
>>> On 18/09/16 21:24, javed khan wrote:
>>>
>>>> Thanks Lorenz and Dave, I have corrected the
>>>> http://www.semanticweb.org#
>>>> <http://www.semanticweb.org/#GPA>Student to ?x but it does not
>>>> work.Actually it does not save the updated marks/GPA of student and
>>>> when I
>>>> remove the Jena rules part, it then updates and save the GPA.
>>>> I also try the SPARQL query inside Protege Query tab but it does not
>>>> give
>>>> me any instance of the GoodStudent class.
>>>>
>>>
>>> The example I showed does work. If you write inf to file or std out you
>>> can see the class, if you run your sparql query it lists s1.
>>>
>>> Dave
>>>
>>>
>>> On Sun, Sep 18, 2016 at 12:40 PM, Lorenz Buehmann <
>>>> buehm...@informatik.uni-leipzig.de> wrote:
>>>>
>>>> The second condition of your rule doesn't make any sense as the subject
>>>>> is Student and it should be ?x.
>>>>>
>>>>>
>>>>> On 18.09.2016 17:41, javed khan wrote:
>>>>>
>>>>>> This code does not work. I want to save student marks/GPA in the file
>>>>>> and
>>>>>> based on GPA assign students to GoodStudent or WorstStudents sub
>>>>>> classes
>>>>>>
>>>>> of
>>>>>
>>>>>> Student via Jena rules.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> OntModel model=ModelFactory.createOntologyModel();
>>>>>>
>>>>>>  InputStream in =FileManager.get().open("C://std.owl");
>>>>>> if (in==null) {
>>>>>> throw new IllegalArgumentException( "File: " +  " not
>>>>>> found");
>>>>>> }   model.read(in,"");
>>>>>>
>>>>>>  String ns="http://www.semanticweb.org#";;
>>>>>>
>>>>>> OntClass user1 = model.getOntClass(ns + "Student");
>>>>>>
>>>>>>Individual indiv = user1.createIndividual(ns + name);
>>>>>> //name
>>>>>>
>>>>> is
>>>>>
>>>>>> variable
>>>>>>
>>>>>> Property prop= model.getProperty(ns,"GPA");
>>>>>>
>>>>>> indiv.addLiteral(prop, marks); //marks also variable
>>>>>> having
>>>>>> some value i-e 3.0
>>>>>>
>>>>>>
>>>>>>
>>>>>>  String rule="[rule1:(?x   http://www.w3.org/1999/02/22-
>>>>>>
>>>>> rdf-syntax-ns#type
>>>>>
>>>>>> http://www.semanticweb.org#Student) " +
>>>>>>  "( http://www.semanticweb.org#Student
>>>>>> http://www.semanticweb.org#GPA  ?marks +   )"   +
>>>>>> "greaterThan(?marks,
>>>>>>
>>>>> 2) "+
>>>>>
>>>>>>  " ->  (?x   http://www.w3.org/1999/02/22-rdf-syntax-ns#type
>>>>>> http://www.semanticweb.org#GoodStudent )]";
>>>>>>
>>>>>>  String queryString= "PREFIX std:<http://www.semanticweb.
>>>>>>
>>>>> org#>
>>>>>
>>>>>> "+
>>>>>>  "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "  +
>>>>>>   "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>>>>>> "+
>>>>>>   "SELECT  * " +
>>>>>> " WHERE {  ?x rdf:type std:GoodStudent}";
>>>>>>
>>>>>>  Reasoner reasoner2 = new
>>>>>> GenericRuleReasoner(Rule.parseRules(rule));
>>>>>>   InfModel inf = ModelFactory.createInfModel(reasoner2, model);
>>>>>>  Query query = QueryFactory.create(queryString);
>>>>>>   QueryExecution qe = QueryExecutionFactory.create(query,
>>>>>> inf);
>>>>>>  ResultSet results = qe.execSelect();
>>>>>>  ResultSetFormatter.out(System.out, results, query);
>>>>>>  qe.close();
>>>>>>
>>>>>>
>>>>>>
>>>>>>  try (FileOutputStream writer = new
>>>>>> FileOutputStream("C://std.owl")) {
>>>>>> model.write(writer, "RDF/XML");
>>>>>> } catch (IOException ex) {
>>>>>> Logger.getLogger(stdinfo.class
>>>>>> .getName()).log(Level.SEVERE,
>>>>>> null, ex);
>>>>>> }
>>>>>> model.write(System.out, "N3");
>>>>>>
>>>>>> }
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>


Re: Jena rules not working

2016-09-20 Thread javed khan
public class Student {



//here call from another class where name is student name and score is
GPA

static void use(String name, int score)

{

int userscore=score;

OntModel model=ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);



 InputStream in =FileManager.get().open("D://std.owl");

if (in==null) {

throw new IllegalArgumentException( "File: " +  " not
found");

}   model.read(in,"");

 String ns="http://www.semanticweb.org#";;

OntClass user1 = model.getOntClass(ns + "Student");



 // OntClass good=model.getOntClass(ns+ "GoodStudent");

//name is entered by user in text field

   Individual indiv = user1.createIndividual(ns + name);

Property prop= model.getProperty(ns,"GPA");



indiv.addLiteral(prop, userscore);



String rule="[rule1:(?x   http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.semanticweb.org#Student) " +

 "( ?x  http://www.semanticweb.org#GPA  ?score +   )"   +
"greaterThan(?score, userscore) "+

 " ->  (?x   http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.semanticweb.org#GoodStudent )]";



 String queryString= "PREFIX std:<http://www.semanticweb.org#>
"+

 "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "  +

  "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "+

  "SELECT  * " +

" WHERE {  ?x rdf:type std:GoodStudent}";


Reasoner reasoner2 = new
GenericRuleReasoner(Rule.parseRules(rule));

InfModel inf = ModelFactory.createInfModel(reasoner2, model);



 for (Iterator i = inf.listResourcesWithProperty(RDF.type,
"GoodStudent"); i.hasNext();) {



System.out.println("Good student: " + i.next());



}


//saving to file


 try (FileOutputStream writer = new
FileOutputStream("D://std.owl")) {

model.write(writer, "RDF/XML");

} catch (IOException ex) {

Logger.getLogger(mystdclass.class.getName()).log(Level.SEVERE,
null, ex);

}

model.write(System.out, "N3");







}

On Tue, Sep 20, 2016 at 12:35 AM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

> @Javed:
>
> It would be good if you show us the WHOLE CURRENT part of the code and
> some sample data, otherwise it's useless to continue the discussion here.
>
> > On 19/09/16 17:14, javed khan wrote:
> >> Hello Dave, though I have Student class in my owl and GoodStudent as the
> >> subclass of Student but this statement gives me error and does not
> >> recognize GoodStudent.
> >>
> >>  for (Iterator i = inf.listResourcesWithProperty(RDF.type,
> >> *GoodStudent*);
> >> i.hasNext();) {
> >> System.out.println("Good student: " + i.next());
> >
> > The code sample I provided worked. I suspect you have omitted some
> > lines such as the one that assigned a value for GoodStudent.
> >
> > Dave
> >
> >>
> >> On Sun, Sep 18, 2016 at 1:36 PM, javed khan 
> >> wrote:
> >>
> >>> Thanks a lot Dave, let me try it. I hope it will help.
> >>>
> >>> Regards
> >>>
> >>> On Sun, Sep 18, 2016 at 1:28 PM, Dave Reynolds
> >>> 
> >>> wrote:
> >>>
> >>>> On 18/09/16 21:24, javed khan wrote:
> >>>>
> >>>>> Thanks Lorenz and Dave, I have corrected the
> >>>>> http://www.semanticweb.org#
> >>>>> <http://www.semanticweb.org/#GPA>Student to ?x but it does not
> >>>>> work.Actually it does not save the updated marks/GPA of student
> >>>>> and when
> >>>>> I
> >>>>> remove the Jena rules part, it then updates and save the GPA.
> >>>>> I also try the SPARQL query inside Protege Query tab but it does
> >>>>> not give
> >>>>> me any instance of the GoodStudent class.
> >>>>>
> >>>>
> >>>> The example I showed does work. If you write inf to file or std out
> >>>> you
> >>>> can see the class, if you run your sparql query it lists s1.
> >>>>
> >>>> Dave
> >>>>
> >>>>
> >>>> On Sun, Sep 18, 2016 at 12:40 PM, Lorenz Buehmann <
> >

Re: Jena rules not working

2016-09-21 Thread javed khan
model.getProperty(ns,"GPA"); I think this works for me and store the data
property GPA in the file.

Actually I do not need this: Model::createProperty(String nameSpace, String
localName)
as I have already created the property in my owl file and just needs
getProperty() method.

If I use this : OntModel::getDatatypeProperty( String uri ) which property
(data property) will be returned ? Because the argument only contains the
namespace and not the actual property.

I tried this but it gives me error:

DataProperty property=ontModel::getDatatypeProperty( String uri, "Score )

On Wed, Sep 21, 2016 at 1:21 AM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

> Are you sure that this code compiles?
>
> > Property prop= model.getProperty(ns,"GPA");
>
> ns is a String in your code, the method expects a Resource object is
> first argument. You totally use the wrong method here, as it returns a
> Statement.
>
> Model::createProperty(String nameSpace, String localName)
>
> would be the method to call, or even better as you use an OntModel
>
> OntModel::getDatatypeProperty( String uri )
>
>
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>


Re: Jena rules not working

2016-09-21 Thread javed khan
Hello Andy, I used this:

?x URI#GPA ?score + "greaterThan(?score, 3)

?score will return the scores/GPA of students and if it is greater than 3,
it will assign user to GoodStudent class.

On Wed, Sep 21, 2016 at 2:18 AM, Andy Seaborne  wrote:

> The rules have some syntax problems:
>
> "( ?x  http://www.semanticweb.org#GPA  ?score +   )"
>
> as mentioned earlier in the thread then
>
> "greaterThan(?score, userscore) "
>
> but userscore is a java variable.
>
> Also
>
> inf.listResourcesWithProperty(RDF.type,
> "GoodStudent")
>
> uses a string not a URI so if not going to find anything.
>
> Andy
>
>
> On 21/09/16 09:21, Lorenz B. wrote:
>
>> Are you sure that this code compiles?
>>
>> Property prop= model.getProperty(ns,"GPA");
>>>
>>
>> ns is a String in your code, the method expects a Resource object is
>> first argument. You totally use the wrong method here, as it returns a
>> Statement.
>>
>> Model::createProperty(String nameSpace, String localName)
>>
>> would be the method to call, or even better as you use an OntModel
>>
>> OntModel::getDatatypeProperty( String uri )
>>
>>
>>


Re: Jena rules not working

2016-09-21 Thread javed khan
Hello Andy, shouldn't there be the class name to which we assign new
individuals.?
inf.listResourcesWithProperty(RDF.type,
"GoodStudent")

Dave run this code and it works for him, but I do not know why, it does not
work for me.

On Wed, Sep 21, 2016 at 2:18 AM, Andy Seaborne  wrote:

> The rules have some syntax problems:
>
> "( ?x  http://www.semanticweb.org#GPA  ?score +   )"
>
> as mentioned earlier in the thread then
>
> "greaterThan(?score, userscore) "
>
> but userscore is a java variable.
>
> Also
>
> inf.listResourcesWithProperty(RDF.type,
> "GoodStudent")
>
> uses a string not a URI so if not going to find anything.
>
> Andy
>
>
> On 21/09/16 09:21, Lorenz B. wrote:
>
>> Are you sure that this code compiles?
>>
>> Property prop= model.getProperty(ns,"GPA");
>>>
>>
>> ns is a String in your code, the method expects a Resource object is
>> first argument. You totally use the wrong method here, as it returns a
>> Statement.
>>
>> Model::createProperty(String nameSpace, String localName)
>>
>> would be the method to call, or even better as you use an OntModel
>>
>> OntModel::getDatatypeProperty( String uri )
>>
>>
>>


Jena rules

2016-09-23 Thread javed khan
The first rule here works and save the individual as GoodStudent when marks
is greater than 2 but not assign individual to WorstStudent when marks are
less than 2? Where I am doing mistake here ?



  String rule = "[rule1:(?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.semanticweb.org#Student ) "
+ "( ?x http://www.semanticweb.org#GPA
  ?marks )"
+ "greaterThan(?marks, 2) "
+ " ->  (?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.semanticweb.org#GoodStudent
 )]";


 String rule = "[rule2:(?y http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.semanticweb.org#Student ) "
+ "( ?y http://www.semanticweb.org#GPA
  ?marks )"
+ "lessThan(?marks, 2) "
+ " ->  (?y http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.semanticweb.org#WorstStudent
 )]";

 "SELECT  * " +
" WHERE {  ?x rdf:type std:GoodStudent . ?y rdf:type
std:WorstStudent }";

 Reasoner reasoner2 = new GenericRuleReasoner(Rule.parseRules(rule));
InfModel inf = ModelFactory.createInfModel(reasoner2, model);
 Query query = QueryFactory.create(queryString);

 QueryExecution qe = QueryExecutionFactory.create(query, inf);
 ResultSet results = qe.execSelect();

 ResultSetFormatter.out(System.out, results, query);
 qe.close();

try (FileOutputStream writer = new FileOutputStream("D://std.owl")) {
inf.write(writer, "RDF/XML");
} catch (IOException ex) {
Logger.getLogger(myframe.class.getName()).log(Level.SEVERE,
null, ex);
}


Re: Jena rules

2016-09-24 Thread javed khan
Hello Dave, I am sorry but I think this is the problem of emailer because I
just copied and pasted it. I have used it single time and also in my
Netbeans IDE I used WorstStudent for second rules, not GoodStudent.

The first rule you knows as you have answered it in previous emails and my
second rule is same but used lessThan(?marks,2) instead of
greaterThan(?marks,2) and assign the student to WorstStudent if GPA/marks
less than 2.

I then used SPARQL query:

?x rdf:type std:GoodStudent . ?y rdf:type std:WorstStudent

GoodStudent works and WorstStudent simply doesn't.


On Sat, Sep 24, 2016 at 1:09 AM, Dave Reynolds 
wrote:

> On 23/09/16 13:05, javed khan wrote:
>
>> The first rule here works and save the individual as GoodStudent when
>> marks
>> is greater than 2 but not assign individual to WorstStudent when marks are
>> less than 2? Where I am doing mistake here ?
>>
>
> It's hard to tell without a clean copy of your rules. Your emailer (or
> something) seems to be trying to expand the URIs and there inconsistencies
> ...
>
>   String rule = "[rule1:(?x http://www.w3.org/1999/02/22-r
>> df-syntax-ns#type
>> http://www.semanticweb.org#Student <http://www.semanticweb.org/#Student>)
>> "
>> + "( ?x http://www.semanticweb.org#GPA
>> <http://www.semanticweb.org/#GPA>  ?marks )"
>> + "greaterThan(?marks, 2) "
>> + " ->  (?x http://www.w3.org/1999/02/22-r
>> df-syntax-ns#type
>> http://www.semanticweb.org#GoodStudent
>> <http://www.semanticweb.org/#GoodStudent> )]";
>>
>
> Each URI here is shown twice, e.g.
>
>http://www.semanticweb.org#GPA
><http://www.semanticweb.org/#GPA>
>
> I presume those aren't in your source file and were added by you emailer
> or by whatever you did the cut/paste from/to.
>
>  String rule = "[rule2:(?y http://www.w3.org/1999/02/22-rdf-syntax-ns#type
>> http://www.semanticweb.org#Student <http://www.semanticweb.org/#Student>)
>> "
>> + "( ?y http://www.semanticweb.org#GPA
>> <http://www.semanticweb.org/#GPA>  ?marks )"
>> + "lessThan(?marks, 2) "
>> + " ->  (?y http://www.w3.org/1999/02/22-r
>> df-syntax-ns#type
>> http://www.semanticweb.org#WorstStudent
>> <http://www.semanticweb.org/#GoodStudent> )]";
>>
>
> This is suspicious. Note that the expansion says "GoodStudent" instead of
> WorstStudent.
>
> Dave
>
>


Jena rules

2016-09-24 Thread javed khan
This is the code where the first rules works and the second does not.

String rule = "[rule1:(?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type
 http://www.semanticweb.org/#Student) "
 + "( ?x http://www.semanticweb.org#GPA
   ?marks )"
+ "greaterThan(?marks, 2) "
 + " ->  (?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type
 http://www.semanticweb.org#GoodStudent
  )]";


 * String rule2 = "[rule2:(?y
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
*
*http://www.semanticweb.org#Student  )
"*
* + "( ?y http://www.semanticweb.org#GPA
*
*  ?marks )"*
* + "lessThan(?marks, 2) "*
* + " ->  (?y
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
*
* http://www.semanticweb.org#WorstStudent
*
* )]";*

   "SELECT  * " +
" WHERE {  ?x rdf:type std:GoodStudent . ?y rdf:type
std:WorstStudent }";

Reasoner reasoner2 = new
GenericRuleReasoner(Rule.parseRules(rule));
InfModel inf = ModelFactory.createInfModel(reasoner2, model);
 Query query = QueryFactory.create(queryString);

 QueryExecution qe = QueryExecutionFactory.create(query, inf);
 ResultSet results = qe.execSelect();



 ResultSetFormatter.out(System.out, results, query);
 qe.close();


Jena rules

2016-09-27 Thread javed khan
If we want to get the maximum score student got among three subjects
(Robotics, Semantic Web, Research Methods) using Jena rules.

?x rdf:type std:Student + ?x std:RoboticsScore ?Rscore + ?x
std:SemanticWebScore ?SMscore + ?x ResearchMethodScore ?RMscore
+ max(Rscore,SMscore,RMscore,maximun) THEN 

I have two questions here:

1) Is the max(Rscore,SMscore,RMscore,maximun) calculate max and assign it
to the (fourth)maximum variable?
2) How would the THEN part be? *If these values give me max, then how can I
know that this maximum value belongs to Robotic, Semantic web or Research
methods?*

*I want to determine "Favorite subject" of student so if a student got max
score in a subject, that will be his/her favorite subject.  *


Re: Jena rules

2016-09-27 Thread javed khan
Lorenz, any alternative way? I mean if there is any other rule where we can
accomplish things like this?


On Tue, Sep 27, 2016 at 2:56 AM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

>
>
> > If we want to get the maximum score student got among three subjects
> > (Robotics, Semantic Web, Research Methods) using Jena rules.
> >
> > ?x rdf:type std:Student + ?x std:RoboticsScore ?Rscore + ?x
> > std:SemanticWebScore ?SMscore + ?x ResearchMethodScore ?RMscore
> > + max(Rscore,SMscore,RMscore,maximun) THEN 
> >
> > I have two questions here:
> >
> > 1) Is the max(Rscore,SMscore,RMscore,maximun) calculate max and assign
> it
> > to the (fourth)maximum variable?
> Documentation is here:
> https://jena.apache.org/documentation/inference/#builtin-primitives
>
> max(?a, ?b, ?c) takes two arguments ?a,?b and assigns the value to ?c
> > 2) How would the THEN part be? *If these values give me max, then how
> can I
> > know that this maximum value belongs to Robotic, Semantic web or Research
> > methods?*
> Not possible, as max only assigns the maximum value to the variable as
> you already know.
> > *I want to determine "Favorite subject" of student so if a student got
> max
> > score in a subject, that will be his/her favorite subject.  *
> >
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
>


Re: Jena rules

2016-09-27 Thread javed khan
Thanks Rob, do you really think this will solve my problem.? I have score
values for three subjects stored in owl file.

I need to point out the maximum score plus the subject(Semantic web,
Robots) in which he got maximum score. And finally assign the maximum
scored subject to the object property "favoriteSubject"

Student1 favoriteSubject Semantic web (for example).

Regards


On Tue, Sep 27, 2016 at 6:39 AM, Rob Vesse  wrote:

> Rules are primarily intended for making logical inferences. What are you
> appear to be trying to do is ask questions of the data for which a query
> language like SPARQL is much better suited e.g.
>
> PREFIX std: <http://yourdomain.com/ns#>
> SELECT ?student ?subject ?bestScore
> WHERE
> {
>   {
> SELECT ?student MAX(?score) AS ?bestScore
> WHERE
>  {
>?student a std:Student ;
>   std:hasResult ?result .
>?result std:hasScore ?score
>   } GROUP BY ?student
>   }
>   ?student std:hasResult ?result .
>   ?result std:inSubject ?subject
> }
>
> I would suggest reading a tutorial such as https://www.
> cambridgesemantics.com/semantic-university/sparql-by-example
>
>  This is just one such possible query and it makes assumptions about the
> structure of the data. But you should be  able to create a query that works
> your datamodel.
>
> Failing that you can just use the Model/OntModel APIs directly to extract
> the relevant data and compute the calculation in Java. Sometimes people
> forget that they are working in a programming language and expect a library
> to magically do everything for them when what they actually needed to do is
> write some code for themselves!
>
> Rob
>
> On 27/09/2016 12:22, "javed khan"  wrote:
>
> Lorenz, any alternative way? I mean if there is any other rule where
> we can
> accomplish things like this?
>
>
> On Tue, Sep 27, 2016 at 2:56 AM, Lorenz B. <
> buehm...@informatik.uni-leipzig.de> wrote:
>
> >
> >
> > > If we want to get the maximum score student got among three
> subjects
> > > (Robotics, Semantic Web, Research Methods) using Jena rules.
> > >
> > > ?x rdf:type std:Student + ?x std:RoboticsScore ?Rscore + ?x
> > > std:SemanticWebScore ?SMscore + ?x ResearchMethodScore ?RMscore
> > > + max(Rscore,SMscore,RMscore,maximun) THEN 
> > >
> > > I have two questions here:
> > >
> > > 1) Is the max(Rscore,SMscore,RMscore,maximun) calculate max and
> assign
> > it
> > > to the (fourth)maximum variable?
> > Documentation is here:
> > https://jena.apache.org/documentation/inference/#builtin-primitives
> >
> > max(?a, ?b, ?c) takes two arguments ?a,?b and assigns the value to ?c
> > > 2) How would the THEN part be? *If these values give me max, then
> how
> > can I
> > > know that this maximum value belongs to Robotic, Semantic web or
> Research
> > > methods?*
> > Not possible, as max only assigns the maximum value to the variable
> as
> > you already know.
> > > *I want to determine "Favorite subject" of student so if a student
> got
> > max
> > > score in a subject, that will be his/her favorite subject.  *
> > >
> > --
> > Lorenz Bühmann
> > AKSW group, University of Leipzig
> > Group: http://aksw.org - semantic web research center
> >
> >
>
>
>
>
>
>


Multiple Jena rules

2016-10-03 Thread javed khan
For instance, I have multiple rules, say, 10 rules, can I write them in one
String value. For example,

String myrule= "[rule1.] +
   "[rule2...]+
   "[rule3]  + etc

and at the end, just write

 Reasoner reasoner2 = new GenericRuleReasoner(Rule.parseRules(myrule));

If have read somewhere that we can also write all the rules in a text file
and import it to the project, but in that case how can we run SPARQL
queries against that rules then?

Any suggestions and guidance would be highly appreciated.


Rules

2016-10-13 Thread javed khan
I have Student ontology in which students have three subjects and scores
they have in exams. I want to assign students to a property
"FavioriteSubject" based on their scores. Is this rule Ok to achieve my
goal here?

?x rdf:type std:Student + ?x std:Robotics_Score ?Robotics + ?x
std:Research_Score ?Research + ?x std:AI_Score ?AI +
greaterThan(?Robotics,?Research)^greaterThan(?Robotics, ?AI) -->
?x std:FavioriteSubject std:Robotics.

std:Robotics will be an instance in my ontology.


duplicate values inferred

2016-10-14 Thread javed khan
I have divided Students into ExcellentStudents and AverageStudents based on
some criteria via Jena rules: if student got 75% or more, he/she will be in
"ExcellentStudents" else "AverageStudents".
In first exam, if some one takes 75% and put into  ExcellentStudents but
next time if he scores less than 75%, he will be AverageStudents.

The problem is that when I store it in the file, the previous value does
not overwrite the new one and I see both categories in the owl file like:
John
 AverageStudents
 ExcellentStudents

How can we cope with this issue?

The rules are:

String rule = "[rule1:(?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.semanticweb.org#Student) "
+ "( ?x http://www.semanticweb.org#score  ?marks )"
+ "greaterThan(?marks, 70) "
+ " ->  (?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.semanticweb.org#ExcellentStudents )]"

+ "[rule2:(?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.semanticweb.org#Student) "
+ "( ?x http://www.semanticweb.org#score  ?marks )"
+ "lessThan(?marks, 70) "
+ " ->  (?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.semanticweb.org#AverageStudents )]";


for (Iterator i = inf.listResourcesWithProperty(RDF.type,stutype1 );
i.hasNext();) {
   inf.listStatements(null,RDF.type, "ExcellentStudents");

}
 for (Iterator i = inf.listResourcesWithProperty(RDF.type, stutype2);
i.hasNext();) {
 inf.listStatements(null,RDF.type, "AverageStudents");

}

I also tried with SPARQL but same result.
SELECT  * " +
" WHERE {   ?x rdf:type std:ExcellentStudents . ?x rdf:type
std:AverageStudents}";


Re: [ANNOUNCE] Lorenz Buehmann elected as Committer

2016-11-02 Thread javed khan
Accept warm congratulation from my side also Lorenz.

On Wed, Nov 2, 2016 at 4:28 PM, A. Soroka  wrote:

> Congratulations, Lorenz!
>
> Thank you for all the work you are putting in to help people.
>
> ---
> A. Soroka
> The University of Virginia Library
>
> > On Nov 2, 2016, at 6:19 AM, Rob Vesse  wrote:
> >
> > All
> >
> >
> >
> > The Apache Jena PMC have inivited Lorenz Buehmann to become a committer
> and we are pleased to announce that he has accepted
> >
> >
> >
> > We have recognised Lorenz for sterling work he does in answering user
> questions and participating in discussions on the mailing lists. He is
> always courteous and polite in his responses even when dealing with
> questions that may not warrant that politeness. Answering questions and
> sharing knowledge are an important part of building a healthy community and
> it can often be a time-consuming task so the more people who are willing to
> help out the easier it is to share that load.
> >
> >
> >
> > Being a committer also enables easier contribution to the project since
> there is no need to go via the patch submission process. This should enable
> better productivity.  Lorenz works regularly with Jena in his day job and
> hopes in time to be able to contribute some of that work that is generally
> applicable back to the community.
> >
> >
> >
> > Committer is also an intermediate step to becoming of the project
> management committee who are tasked with managing the project on the half
> of the Apache software foundation. If you would like to learn more please
> see http://apache.org/foundation/how-it-works.html#roles
> >
> >
> >
> > Please join us in welcoming Lorenz as a committer.
> >
> >
> >
> > Regards,
> >
> >
> >
> > Rob Vesse
> >
>
>


Re: duplicate values inferred

2016-11-11 Thread javed khan
The students have to appear multiple time in the exam. When student appears
first time, he scored 80% and got in the category of Excellent Students
list. Second time he appears, he scored 60% and thus appeared in Average
Student.
Now after two exams, the Student in the owl file should be in the Average
Student list but both Excellent and Average Student appears and thus the
first value of first exam also there.

On Sun, Oct 16, 2016 at 9:16 PM, Dave Reynolds 
wrote:

> On 14/10/16 14:53, javed khan wrote:
>
>> I have divided Students into ExcellentStudents and AverageStudents based
>> on
>> some criteria via Jena rules: if student got 75% or more, he/she will be
>> in
>> "ExcellentStudents" else "AverageStudents".
>> In first exam, if some one takes 75% and put into  ExcellentStudents but
>> next time if he scores less than 75%, he will be AverageStudents.
>>
>> The problem is that when I store it in the file, the previous value does
>> not overwrite the new one and I see both categories in the owl file like:
>> John
>>  AverageStudents
>>  ExcellentStudents
>>
>> How can we cope with this issue?
>>
>
>
> If in your data there is only ever one exam result for a given student
> then you it might make sense to have AverageStudents/ExcellentStudent
> classes. However, if you have multiple exam results in the same data then
> naturally some will be average on some and excellent on others.
>
> So you have to decide what your semantics are. Do you want
> ExcellentStudent to mean that the student averages 75% or more across all
> exams?  Or you you want an n-relationship between students, exams and
> classifications?
>
> Once you've decided what you semantics are and how the answers should look
> then you can figure out an implementation.
>
> Dave
>
>
>
>> The rules are:
>>
>> String rule = "[rule1:(?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type
>> http://www.semanticweb.org#Student) "
>> + "( ?x http://www.semanticweb.org#score  ?marks )"
>> + "greaterThan(?marks, 70) "
>> + " ->  (?x http://www.w3.org/1999/02/22-r
>> df-syntax-ns#type
>> http://www.semanticweb.org#ExcellentStudents )]"
>>
>> + "[rule2:(?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type
>> http://www.semanticweb.org#Student) "
>> + "( ?x http://www.semanticweb.org#score  ?marks )"
>> + "lessThan(?marks, 70) "
>> + " ->  (?x http://www.w3.org/1999/02/22-r
>> df-syntax-ns#type
>> http://www.semanticweb.org#AverageStudents )]";
>>
>>
>> for (Iterator i = inf.listResourcesWithProperty(RDF.type,stutype1 );
>> i.hasNext();) {
>>inf.listStatements(null,RDF.type, "ExcellentStudents");
>>
>> }
>>  for (Iterator i = inf.listResourcesWithProperty(RDF.type, stutype2);
>> i.hasNext();) {
>>  inf.listStatements(null,RDF.type, "AverageStudents");
>>
>> }
>>
>> I also tried with SPARQL but same result.
>> SELECT  * " +
>> " WHERE {   ?x rdf:type std:ExcellentStudents . ?x
>> rdf:type
>> std:AverageStudents}";
>>
>>
>


Re: duplicate values inferred

2016-11-12 Thread javed khan
Hello Lorenz, kindly if you can suggest me how to avoid this situation.
Recent data property value can be achieved using Jena but I dont know how
to do it in this case because Student is a class here.

On Sat, Nov 12, 2016 at 4:55 PM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

> And what is the question now?
>
> By the way, those rules do not overwrite any value, the logic is
> supposed to be monotonic, i.e. only additional triples are inferred.
> Replacement has to be done in the application code.
>
> > The students have to appear multiple time in the exam. When student
> appears
> > first time, he scored 80% and got in the category of Excellent Students
> > list. Second time he appears, he scored 60% and thus appeared in Average
> > Student.
> > Now after two exams, the Student in the owl file should be in the Average
> > Student list but both Excellent and Average Student appears and thus the
> > first value of first exam also there.
> >
> > On Sun, Oct 16, 2016 at 9:16 PM, Dave Reynolds <
> dave.e.reyno...@gmail.com>
> > wrote:
> >
> >> On 14/10/16 14:53, javed khan wrote:
> >>
> >>> I have divided Students into ExcellentStudents and AverageStudents
> based
> >>> on
> >>> some criteria via Jena rules: if student got 75% or more, he/she will
> be
> >>> in
> >>> "ExcellentStudents" else "AverageStudents".
> >>> In first exam, if some one takes 75% and put into  ExcellentStudents
> but
> >>> next time if he scores less than 75%, he will be AverageStudents.
> >>>
> >>> The problem is that when I store it in the file, the previous value
> does
> >>> not overwrite the new one and I see both categories in the owl file
> like:
> >>> John
> >>>  AverageStudents
> >>>  ExcellentStudents
> >>>
> >>> How can we cope with this issue?
> >>>
> >>
> >> If in your data there is only ever one exam result for a given student
> >> then you it might make sense to have AverageStudents/ExcellentStudent
> >> classes. However, if you have multiple exam results in the same data
> then
> >> naturally some will be average on some and excellent on others.
> >>
> >> So you have to decide what your semantics are. Do you want
> >> ExcellentStudent to mean that the student averages 75% or more across
> all
> >> exams?  Or you you want an n-relationship between students, exams and
> >> classifications?
> >>
> >> Once you've decided what you semantics are and how the answers should
> look
> >> then you can figure out an implementation.
> >>
> >> Dave
> >>
> >>
> >>
> >>> The rules are:
> >>>
> >>> String rule = "[rule1:(?x http://www.w3.org/1999/02/22-
> rdf-syntax-ns#type
> >>> http://www.semanticweb.org#Student) "
> >>> + "( ?x http://www.semanticweb.org#score  ?marks )"
> >>> + "greaterThan(?marks, 70) "
> >>> + " ->  (?x http://www.w3.org/1999/02/22-r
> >>> df-syntax-ns#type
> >>> http://www.semanticweb.org#ExcellentStudents )]"
> >>>
> >>> + "[rule2:(?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type
> >>> http://www.semanticweb.org#Student) "
> >>> + "( ?x http://www.semanticweb.org#score  ?marks )"
> >>> + "lessThan(?marks, 70) "
> >>> + " ->  (?x http://www.w3.org/1999/02/22-r
> >>> df-syntax-ns#type
> >>> http://www.semanticweb.org#AverageStudents )]";
> >>>
> >>>
> >>> for (Iterator i = inf.listResourcesWithProperty(RDF.type,stutype1 );
> >>> i.hasNext();) {
> >>>inf.listStatements(null,RDF.type, "ExcellentStudents");
> >>>
> >>> }
> >>>  for (Iterator i = inf.listResourcesWithProperty(RDF.type,
> stutype2);
> >>> i.hasNext();) {
> >>>  inf.listStatements(null,RDF.type, "AverageStudents");
> >>>
> >>> }
> >>>
> >>> I also tried with SPARQL but same result.
> >>> SELECT  * " +
> >>> " WHERE {   ?x rdf:type std:ExcellentStudents . ?x
> >>> rdf:type
> >>> std:AverageStudents}";
> >>>
> >>>
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
>


Re: duplicate values inferred

2016-11-14 Thread javed khan
I am sorry but I have no idea about it.


On Sun, Nov 13, 2016 at 4:24 PM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

> You don't know what exactly?
>
> > Hello Lorenz, kindly if you can suggest me how to avoid this situation.
> > Recent data property value can be achieved using Jena but I dont know how
> > to do it in this case because Student is a class here.
> >
> > On Sat, Nov 12, 2016 at 4:55 PM, Lorenz B. <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >> And what is the question now?
> >>
> >> By the way, those rules do not overwrite any value, the logic is
> >> supposed to be monotonic, i.e. only additional triples are inferred.
> >> Replacement has to be done in the application code.
> >>
> >>> The students have to appear multiple time in the exam. When student
> >> appears
> >>> first time, he scored 80% and got in the category of Excellent Students
> >>> list. Second time he appears, he scored 60% and thus appeared in
> Average
> >>> Student.
> >>> Now after two exams, the Student in the owl file should be in the
> Average
> >>> Student list but both Excellent and Average Student appears and thus
> the
> >>> first value of first exam also there.
> >>>
> >>> On Sun, Oct 16, 2016 at 9:16 PM, Dave Reynolds <
> >> dave.e.reyno...@gmail.com>
> >>> wrote:
> >>>
> >>>> On 14/10/16 14:53, javed khan wrote:
> >>>>
> >>>>> I have divided Students into ExcellentStudents and AverageStudents
> >> based
> >>>>> on
> >>>>> some criteria via Jena rules: if student got 75% or more, he/she will
> >> be
> >>>>> in
> >>>>> "ExcellentStudents" else "AverageStudents".
> >>>>> In first exam, if some one takes 75% and put into  ExcellentStudents
> >> but
> >>>>> next time if he scores less than 75%, he will be AverageStudents.
> >>>>>
> >>>>> The problem is that when I store it in the file, the previous value
> >> does
> >>>>> not overwrite the new one and I see both categories in the owl file
> >> like:
> >>>>> John
> >>>>>  AverageStudents
> >>>>>  ExcellentStudents
> >>>>>
> >>>>> How can we cope with this issue?
> >>>>>
> >>>> If in your data there is only ever one exam result for a given student
> >>>> then you it might make sense to have AverageStudents/ExcellentStudent
> >>>> classes. However, if you have multiple exam results in the same data
> >> then
> >>>> naturally some will be average on some and excellent on others.
> >>>>
> >>>> So you have to decide what your semantics are. Do you want
> >>>> ExcellentStudent to mean that the student averages 75% or more across
> >> all
> >>>> exams?  Or you you want an n-relationship between students, exams and
> >>>> classifications?
> >>>>
> >>>> Once you've decided what you semantics are and how the answers should
> >> look
> >>>> then you can figure out an implementation.
> >>>>
> >>>> Dave
> >>>>
> >>>>
> >>>>
> >>>>> The rules are:
> >>>>>
> >>>>> String rule = "[rule1:(?x http://www.w3.org/1999/02/22-
> >> rdf-syntax-ns#type
> >>>>> http://www.semanticweb.org#Student) "
> >>>>> + "( ?x http://www.semanticweb.org#score  ?marks )"
> >>>>> + "greaterThan(?marks, 70) "
> >>>>> + " ->  (?x http://www.w3.org/1999/02/22-r
> >>>>> df-syntax-ns#type
> >>>>> http://www.semanticweb.org#ExcellentStudents )]"
> >>>>>
> >>>>> + "[rule2:(?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type
> >>>>> http://www.semanticweb.org#Student) "
> >>>>> + "( ?x http://www.semanticweb.org#score  ?marks )"
> >>>>> + "lessThan(?marks, 70) "
> >>>>> + " ->  (?x http://www.w3.org/1999/02/22-r
> >>>>> df-syntax-ns#type
> >>>>> http://www.semanticweb.org#AverageStudents )]";
> >>>>>
> >>>>>
> >>>>> for (Iterator i = inf.listResourcesWithProperty(RDF.type,stutype1 );
> >>>>> i.hasNext();) {
> >>>>>inf.listStatements(null,RDF.type, "ExcellentStudents");
> >>>>>
> >>>>> }
> >>>>>  for (Iterator i = inf.listResourcesWithProperty(RDF.type,
> >> stutype2);
> >>>>> i.hasNext();) {
> >>>>>  inf.listStatements(null,RDF.type, "AverageStudents");
> >>>>>
> >>>>> }
> >>>>>
> >>>>> I also tried with SPARQL but same result.
> >>>>> SELECT  * " +
> >>>>> " WHERE {   ?x rdf:type std:ExcellentStudents . ?x
> >>>>> rdf:type
> >>>>> std:AverageStudents}";
> >>>>>
> >>>>>
> >> --
> >> 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
>
>


Implementation of Rules

2016-12-03 Thread javed khan
My question is what are the possible ways to implement the Jena rules?
Is it necessary that we should always execute the SPARQL query to implement
the rules? If not, what are the alternatives?

What if we just write rules in our Java code and do nothing other than:

 Reasoner myreasoner = new GenericRuleReasoner(Rule.parseRules(rule));
 InfModel infmodel = ModelFactory.createInfModel(myreasoner, model);

Thank you


Re: Implementation of Rules

2016-12-03 Thread javed khan
Thank you Dave, I have a class "Expert", which have sub classes Researcher
and Teacher.
I have Jena rule like: If an Expert ResearchPapers more than 10, assign the
individual to Researcher sub class otherwise to Teacher subclass.
After writing the appropriate Jena rule, apart from SPARQL query

Select * Where{ ?ind rdf:type ont:Researcher . ?ind rdf:type ont:Teacher}

What is the alternate way to parse/execute the rule and the result
transfers to our infmodel. ?

On Sat, Dec 3, 2016 at 8:06 PM, Dave Reynolds 
wrote:

> On 03/12/16 16:05, javed khan wrote:
>
>> My question is what are the possible ways to implement the Jena rules?
>> Is it necessary that we should always execute the SPARQL query to
>> implement
>> the rules? If not, what are the alternatives?
>>
>> What if we just write rules in our Java code and do nothing other than:
>>
>>  Reasoner myreasoner = new GenericRuleReasoner(Rule.parseRules(rule));
>>  InfModel infmodel = ModelFactory.createInfModel(myreasoner, model);
>>
>
> Sorry, don't follow the question.
>
> Jena rules are the syntax for the built in Jena generic rules engine which
> can be run as you show above.
>
> You don't "implement the rules" by executing sparql queries you just run
> the rules engine. You could compute the same results through using a
> sequence of SPARQL queries and updates or through java code but that's not
> the same thing as implementing the rules unless you have some sort of
> jena-rules to "sequence of sparql updates" converter.
>
> If you are talking about getting results out after running the rules then
> your choices are SPARQL or the RDF API.
>
> Dave
>
>
>


Re: Implementation of Rules

2016-12-03 Thread javed khan
Thanks Dave again, yes I was asking something like that. You answered what
I want.

Cheers

On Sat, Dec 3, 2016 at 9:24 PM, Dave Reynolds 
wrote:

> On 03/12/16 17:29, javed khan wrote:
>
>> Thank you Dave, I have a class "Expert", which have sub classes Researcher
>> and Teacher.
>> I have Jena rule like: If an Expert ResearchPapers more than 10, assign
>> the
>> individual to Researcher sub class otherwise to Teacher subclass.
>> After writing the appropriate Jena rule, apart from SPARQL query
>>
>> Select * Where{ ?ind rdf:type ont:Researcher . ?ind rdf:type ont:Teacher}
>>
>> What is the alternate way to parse/execute the rule and the result
>> transfers to our infmodel. ?
>>
>
> Sorry, still don't quite understand what you are asking.
>
> There is no alternative way to "parse/execute" the rule other that to pass
> it to a GenericRuleReasoner instance and create an InfModel. At least no
> alternative built into Jena.
>
> To then list all individuals that your rule has classified as a Researcher
> then running a SPARQL query as you are is perfectly fine.
>
> If you want to do that with the RDF API then it would be something like:
>
>   OntClass researcherClass = infModel.getResource(namespace +
> "Researcher");
>   ResIterator i = infModel.listResourcesWithProperty(RDF.type,
> researcherClass);
>   while (i.hasNext()){
> Resource instance = i.next();
> ...
>   }
>
> Dave
>
>
>
>> On Sat, Dec 3, 2016 at 8:06 PM, Dave Reynolds 
>> wrote:
>>
>> On 03/12/16 16:05, javed khan wrote:
>>>
>>> My question is what are the possible ways to implement the Jena rules?
>>>> Is it necessary that we should always execute the SPARQL query to
>>>> implement
>>>> the rules? If not, what are the alternatives?
>>>>
>>>> What if we just write rules in our Java code and do nothing other than:
>>>>
>>>>  Reasoner myreasoner = new GenericRuleReasoner(Rule.parseRules(rule));
>>>>  InfModel infmodel = ModelFactory.createInfModel(myreasoner, model);
>>>>
>>>>
>>> Sorry, don't follow the question.
>>>
>>> Jena rules are the syntax for the built in Jena generic rules engine
>>> which
>>> can be run as you show above.
>>>
>>> You don't "implement the rules" by executing sparql queries you just run
>>> the rules engine. You could compute the same results through using a
>>> sequence of SPARQL queries and updates or through java code but that's
>>> not
>>> the same thing as implementing the rules unless you have some sort of
>>> jena-rules to "sequence of sparql updates" converter.
>>>
>>> If you are talking about getting results out after running the rules then
>>> your choices are SPARQL or the RDF API.
>>>
>>> Dave
>>>
>>>
>>>
>>>
>>
>


Rules

2017-01-03 Thread javed khan
Hello
I have three subjects marks for a student.
 Cryptography, Networking, Software Engineering with different marks for
each student.
I want to calculate in which subject a student got maximum marks using Jena
rule and will set that subject as HighScoreSubject of the student (
HighScoreSubject is data propety) whose values will be one of these three
subjects.

Is this rule correct to get the required result ( I am asking this because
I am not getting the result required)

?x rdf:type std:Student + ?x std:CryptographyScore ?score1 + ?x
std:NetworkingScore ?score2 + ?x std:SEScore ?score3 +
greaterThan(?score1,?score2), greaterThan(?score1, ?score3) -->
?x std:HighScoreSubject std:Cryptography


Re: Rules

2017-01-04 Thread javed khan
Thanks Dave and Lorenz for your response.

What if we have entered the score for a student in Cryptography and
SoftwareEngineering and did not entered for Networking subject and stored
something like this in our owl file:

Student1

 Name: Bob
 CryptographyScore: 60
 SoftwareEngineeringScore: 80
 //NetworkingScore, not mentioned here

Then will the above rule fires?



On Wed, Jan 4, 2017 at 11:35 AM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

> Inline comments:
> > I have three subjects marks for a student.
> >  Cryptography, Networking, Software Engineering with different marks for
> > each student.
> > I want to calculate in which subject a student got maximum marks using
> Jena
> > rule and will set that subject as HighScoreSubject of the student (
> > HighScoreSubject is data propety) whose values will be one of these three
> > subjects.
> >
> > Is this rule correct to get the required result ( I am asking this
> because
> > I am not getting the result required)
> Without seeing the data, it's always difficult to say if something is
> correct or not. Sample data makes things easier.
> And without knowing how you apply the rules (in a correct syntax) it's
> even harder. That means, it's always good to show the relevant code.
> >
> > ?x rdf:type std:Student + ?x std:CryptographyScore ?score1 + ?x
> > std:NetworkingScore ?score2 + ?x std:SEScore ?score3 +
> > greaterThan(?score1,?score2), greaterThan(?score1, ?score3) -->
> > ?x std:HighScoreSubject std:Cryptography
> >
> This rule covers only the case when the score for Cryptography is the
> highest. If your data doesn't contain a student that matches the rule,
> nothing will happen.
>
>
> Cheers,
> Lorenz
>
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
>
>


Re: Rules

2017-01-04 Thread javed khan
Hello Rob,

We are in a group and we discussed it.

We have three data properties , CryptographyScore, SoftwareEngineering
score and NetworkingScore and we need the maximum of these three scores for
a student.

Can we do it like this

SELECT ?student (MAX(?score1, ?score2, ?score3) AS ?topScore)




On Wed, Jan 4, 2017 at 5:05 PM, Rob Vesse  wrote:

> Most likely not
>
> You seem to be running into the XY problem a lot (http://xyproblem.info)
>
> You keep asking how to do things with rules for which rules are not really
> designed. And from some of your responses it sounds like the problems
> you’re trying to solve don’t actually need rules at all.
>
> For example finding the top score for a student would be much more easily
> done with a SPARQL query although from what little I have seen of your data
> model it looks like it would make it even that quite awkward.  But in
> general terms something like the following would work:
>
> PREFIX ex: <http://example.com/ns/>
> SELECT ?student (MAX(?score) AS ?topScore)
> WHERE
> {
>   ?student ex:score ?score .
> }
> GROUP BY ?student
>
> Rob
>
> On 04/01/2017 13:25, "javed khan"  wrote:
>
> Thanks Dave and Lorenz for your response.
>
> What if we have entered the score for a student in Cryptography and
> SoftwareEngineering and did not entered for Networking subject and
> stored
> something like this in our owl file:
>
> Student1
>
>  Name: Bob
>  CryptographyScore: 60
>  SoftwareEngineeringScore: 80
>  //NetworkingScore, not mentioned here
>
> Then will the above rule fires?
>
>
>
> On Wed, Jan 4, 2017 at 11:35 AM, Lorenz B. <
> buehm...@informatik.uni-leipzig.de> wrote:
>
> > Inline comments:
> > > I have three subjects marks for a student.
> > >  Cryptography, Networking, Software Engineering with different
> marks for
> > > each student.
> > > I want to calculate in which subject a student got maximum marks
> using
> > Jena
> > > rule and will set that subject as HighScoreSubject of the student (
> > > HighScoreSubject is data propety) whose values will be one of
> these three
> > > subjects.
> > >
> > > Is this rule correct to get the required result ( I am asking this
> > because
> > > I am not getting the result required)
> > Without seeing the data, it's always difficult to say if something is
> > correct or not. Sample data makes things easier.
> > And without knowing how you apply the rules (in a correct syntax)
> it's
> > even harder. That means, it's always good to show the relevant code.
> > >
> > > ?x rdf:type std:Student + ?x std:CryptographyScore ?score1 + ?x
> > > std:NetworkingScore ?score2 + ?x std:SEScore ?score3 +
> > > greaterThan(?score1,?score2), greaterThan(?score1, ?score3) -->
> > > ?x std:HighScoreSubject std:Cryptography
> > >
> > This rule covers only the case when the score for Cryptography is the
> > highest. If your data doesn't contain a student that matches the
> rule,
> > nothing will happen.
> >
> >
> > Cheers,
> > Lorenz
> >
> > --
> > Lorenz Bühmann
> > AKSW group, University of Leipzig
> > Group: http://aksw.org - semantic web research center
> >
> >
> >
>
>
>
>
>
>


Re: Rules

2017-01-04 Thread javed khan
Let me explain : There are 4 students, having scores of three subjects
(1) Bob:  Cryptographyscore 50, SE score 58, *Networking score 70*
 (2) Jim:  *Cryptographyscore 86*, SEscore 55, Networkingscore 48
(3)  Smith: Cryptographyscore 78, *SEscore 79*, Networkingscore 60
(4) David: Cryptographyscore 50, SEscore 66, Networkingscore 55

I want the highest score of each category any user has scored, like in
cryptography the highest score is 86 scored by Jim, in SE highest score is
79 scored by Smith and so on.

So I want the maximum score in each of the three categories, which are our
data properties in the rdf file and this is why I thought we should use
three variables for Max.

Lorenz still I achieve this with the query you and Rob have suggested?

Thank you


On Wed, Jan 4, 2017 at 6:38 PM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

>
> > Hello Rob,
> >
> > We are in a group and we discussed it.
> >
> > We have three data properties , CryptographyScore, SoftwareEngineering
> > score and NetworkingScore and we need the maximum of these three scores
> for
> > a student.
> >
> > Can we do it like this
> >
> > SELECT ?student (MAX(?score1, ?score2, ?score3) AS ?topScore)
> >
> No, Rob almost showed the solution. It's not allowed and I also don't
> see why you want to use 3 variables in the MAX function.
>
> Again, we assume that you want to get the maximum score among all
> students for a particular subject!
>
> That means, the query would be (for CryptographyScore here only)
>
> PREFIX ex: <http://example.com/ns/>
> SELECT (MAX(?score) AS ?topScore)
> WHERE
> {
>   ?student ex:CryptographyScore ?score .
> }
>
>
>
> You asked the same question on Stackoverflow by the way and I told you
> there to use SPARQL qith aggregate functions. I assume that you're a
> group of CS students, so you should know about SQL which also supports
> GROUP BY + aggregate functions. The principle is the same.
> >
> >
> > On Wed, Jan 4, 2017 at 5:05 PM, Rob Vesse  wrote:
> >
> >> Most likely not
> >>
> >> You seem to be running into the XY problem a lot (http://xyproblem.info
> )
> >>
> >> You keep asking how to do things with rules for which rules are not
> really
> >> designed. And from some of your responses it sounds like the problems
> >> you’re trying to solve don’t actually need rules at all.
> >>
> >> For example finding the top score for a student would be much more
> easily
> >> done with a SPARQL query although from what little I have seen of your
> data
> >> model it looks like it would make it even that quite awkward.  But in
> >> general terms something like the following would work:
> >>
> >> PREFIX ex: <http://example.com/ns/>
> >> SELECT ?student (MAX(?score) AS ?topScore)
> >> WHERE
> >> {
> >>   ?student ex:score ?score .
> >> }
> >> GROUP BY ?student
> >>
> >> Rob
> >>
> >> On 04/01/2017 13:25, "javed khan"  wrote:
> >>
> >> Thanks Dave and Lorenz for your response.
> >>
> >> What if we have entered the score for a student in Cryptography and
> >> SoftwareEngineering and did not entered for Networking subject and
> >> stored
> >> something like this in our owl file:
> >>
> >> Student1
> >>
> >>  Name: Bob
> >>  CryptographyScore: 60
> >>  SoftwareEngineeringScore: 80
> >>  //NetworkingScore, not mentioned here
> >>
> >> Then will the above rule fires?
> >>
> >>
> >>
> >> On Wed, Jan 4, 2017 at 11:35 AM, Lorenz B. <
> >> buehm...@informatik.uni-leipzig.de> wrote:
> >>
> >> > Inline comments:
> >> > > I have three subjects marks for a student.
> >> > >  Cryptography, Networking, Software Engineering with different
> >> marks for
> >> > > each student.
> >> > > I want to calculate in which subject a student got maximum marks
> >> using
> >> > Jena
> >> > > rule and will set that subject as HighScoreSubject of the
> student (
> >> > > HighScoreSubject is data propety) whose values will be one of
> >> these three
> >> > > subjects.
> >> > >
> >> > > Is this rule correct to get the required result ( I am asking
> this
> >> > because
> >> >

Re: Rules

2017-01-05 Thread javed khan
Hello Lorenz, thanks a lot for kind cooperation.

 It means I will have three queries for NetworkingScore,  Cryptographyscore
and SEscore?

On Thu, Jan 5, 2017 at 1:27 PM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

> The query I showed returns the highest value for one subject as I said.
> Executing three SPARQL queries should therefore be rather simple.
>
> PREFIX ex: <http://example.com/ns/>
> SELECT (MAX(?score) AS ?topScore)
> WHERE
> {
>   ?student ex:CryptographyScore ?score .
> }
>
> So what's wrong with this query? If you also want to have the student(s)
> with this score, try
>
> PREFIX ex: <http://example.com/ns/>
> SELECT ?student ?topScore WHERE {
>
> #-- Find the high score in the subject
> {
>
> SELECT (MAX(?score) AS ?topScore) WHERE
> {
>   ?student ex:CryptographyScore ?score .
> }
>
> }
>
> #-- Then find the student(s) that had that high score in the subject
> ?student ex:CryptographyScore ?topScore .
>
> }
>
> Or you can use SPARQL 1.1 aggregate function SAMPLE.
>
> Otherwise you can also use a single SPARQL query and put, but it looks
> like you have to learn SPARQL and we're doing your homework - this is
> obviously the wrong direction when you want to lean something about
> Semantic Web...
>
> By the way, I wouldn't create a data property for each subject but
> attach the subject to the score. But that's how I would do it and out of
> scope here.
>
>
>
>
> > Let me explain : There are 4 students, having scores of three subjects
> > (1) Bob:  Cryptographyscore 50, SE score 58, *Networking score 70*
> >  (2) Jim:  *Cryptographyscore 86*, SEscore 55, Networkingscore 48
> > (3)  Smith: Cryptographyscore 78, *SEscore 79*, Networkingscore 60
> > (4) David: Cryptographyscore 50, SEscore 66, Networkingscore 55
> >
> > I want the highest score of each category any user has scored, like in
> > cryptography the highest score is 86 scored by Jim, in SE highest score
> is
> > 79 scored by Smith and so on.
> >
> > So I want the maximum score in each of the three categories, which are
> our
> > data properties in the rdf file and this is why I thought we should use
> > three variables for Max.
> >
> > Lorenz still I achieve this with the query you and Rob have suggested?
> >
> > Thank you
> >
> >
> > On Wed, Jan 4, 2017 at 6:38 PM, Lorenz Buehmann <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >>> Hello Rob,
> >>>
> >>> We are in a group and we discussed it.
> >>>
> >>> We have three data properties , CryptographyScore, SoftwareEngineering
> >>> score and NetworkingScore and we need the maximum of these three scores
> >> for
> >>> a student.
> >>>
> >>> Can we do it like this
> >>>
> >>> SELECT ?student (MAX(?score1, ?score2, ?score3) AS ?topScore)
> >>>
> >> No, Rob almost showed the solution. It's not allowed and I also don't
> >> see why you want to use 3 variables in the MAX function.
> >>
> >> Again, we assume that you want to get the maximum score among all
> >> students for a particular subject!
> >>
> >> That means, the query would be (for CryptographyScore here only)
> >>
> >> PREFIX ex: <http://example.com/ns/>
> >> SELECT (MAX(?score) AS ?topScore)
> >> WHERE
> >> {
> >>   ?student ex:CryptographyScore ?score .
> >> }
> >>
> >>
> >>
> >> You asked the same question on Stackoverflow by the way and I told you
> >> there to use SPARQL qith aggregate functions. I assume that you're a
> >> group of CS students, so you should know about SQL which also supports
> >> GROUP BY + aggregate functions. The principle is the same.
> >>>
> >>> On Wed, Jan 4, 2017 at 5:05 PM, Rob Vesse 
> wrote:
> >>>
> >>>> Most likely not
> >>>>
> >>>> You seem to be running into the XY problem a lot (
> http://xyproblem.info
> >> )
> >>>> You keep asking how to do things with rules for which rules are not
> >> really
> >>>> designed. And from some of your responses it sounds like the problems
> >>>> you’re trying to solve don’t actually need rules at all.
> >>>>
> >>>> For example finding the top score for a student would be much more
> >> easily
> >>>> done with a SPARQL q

Re: Rules

2017-01-06 Thread javed khan
(for CryptographyScore here only)
> >>>>
> >>>> PREFIX ex: <http://example.com/ns/>
> >>>> SELECT (MAX(?score) AS ?topScore)
> >>>> WHERE
> >>>> {
> >>>>   ?student ex:CryptographyScore ?score .
> >>>> }
> >>>>
> >>>>
> >>>>
> >>>> You asked the same question on Stackoverflow by the way and I told you
> >>>> there to use SPARQL qith aggregate functions. I assume that you're a
> >>>> group of CS students, so you should know about SQL which also supports
> >>>> GROUP BY + aggregate functions. The principle is the same.
> >>>>> On Wed, Jan 4, 2017 at 5:05 PM, Rob Vesse 
> >> wrote:
> >>>>>> Most likely not
> >>>>>>
> >>>>>> You seem to be running into the XY problem a lot (
> >> http://xyproblem.info
> >>>> )
> >>>>>> You keep asking how to do things with rules for which rules are not
> >>>> really
> >>>>>> designed. And from some of your responses it sounds like the
> problems
> >>>>>> you’re trying to solve don’t actually need rules at all.
> >>>>>>
> >>>>>> For example finding the top score for a student would be much more
> >>>> easily
> >>>>>> done with a SPARQL query although from what little I have seen of
> your
> >>>> data
> >>>>>> model it looks like it would make it even that quite awkward.  But
> in
> >>>>>> general terms something like the following would work:
> >>>>>>
> >>>>>> PREFIX ex: <http://example.com/ns/>
> >>>>>> SELECT ?student (MAX(?score) AS ?topScore)
> >>>>>> WHERE
> >>>>>> {
> >>>>>>   ?student ex:score ?score .
> >>>>>> }
> >>>>>> GROUP BY ?student
> >>>>>>
> >>>>>> Rob
> >>>>>>
> >>>>>> On 04/01/2017 13:25, "javed khan"  wrote:
> >>>>>>
> >>>>>> Thanks Dave and Lorenz for your response.
> >>>>>>
> >>>>>> What if we have entered the score for a student in Cryptography
> >> and
> >>>>>> SoftwareEngineering and did not entered for Networking subject
> and
> >>>>>> stored
> >>>>>> something like this in our owl file:
> >>>>>>
> >>>>>> Student1
> >>>>>>
> >>>>>>  Name: Bob
> >>>>>>  CryptographyScore: 60
> >>>>>>  SoftwareEngineeringScore: 80
> >>>>>>  //NetworkingScore, not mentioned here
> >>>>>>
> >>>>>> Then will the above rule fires?
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> On Wed, Jan 4, 2017 at 11:35 AM, Lorenz B. <
> >>>>>> buehm...@informatik.uni-leipzig.de> wrote:
> >>>>>>
> >>>>>> > Inline comments:
> >>>>>> > > I have three subjects marks for a student.
> >>>>>> > >  Cryptography, Networking, Software Engineering with
> different
> >>>>>> marks for
> >>>>>> > > each student.
> >>>>>> > > I want to calculate in which subject a student got maximum
> >> marks
> >>>>>> using
> >>>>>> > Jena
> >>>>>> > > rule and will set that subject as HighScoreSubject of the
> >>>> student (
> >>>>>> > > HighScoreSubject is data propety) whose values will be one
> of
> >>>>>> these three
> >>>>>> > > subjects.
> >>>>>> > >
> >>>>>> > > Is this rule correct to get the required result ( I am
> asking
> >>>> this
> >>>>>> > because
> >>>>>> > > I am not getting the result required)
> >>>>>> > Without seeing the data, it's always difficult to say if
> >>>> something is
> >>>>>> > correct or not. Sample data makes things easier.
> >>>>>> > And without knowing how you apply the rules (in a correct
> >> syntax)
> >>>>>> it's
> >>>>>> > even harder. That means, it's always good to show the relevant
> >>>> code.
> >>>>>> > >
> >>>>>> > > ?x rdf:type std:Student + ?x std:CryptographyScore ?score1 +
> >> ?x
> >>>>>> > > std:NetworkingScore ?score2 + ?x std:SEScore ?score3 +
> >>>>>> > > greaterThan(?score1,?score2), greaterThan(?score1, ?score3)
> >> -->
> >>>>>> > > ?x std:HighScoreSubject std:Cryptography
> >>>>>> > >
> >>>>>> > This rule covers only the case when the score for Cryptography
> >> is
> >>>> the
> >>>>>> > highest. If your data doesn't contain a student that matches
> the
> >>>>>> rule,
> >>>>>> > nothing will happen.
> >>>>>> >
> >>>>>> >
> >>>>>> > Cheers,
> >>>>>> > Lorenz
> >>>>>> >
> >>>>>> > --
> >>>>>> > 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: Rules

2017-01-06 Thread javed khan
This query now display both student and highscore

select ?subject ?student ?highScore where {
{select ?subject (max(?score) as ?highScore) { ?student ont:Englishsscore
?score
 }
group by ?subject
  }
?student ont:Englishscore ?highScore
}

On Fri, Jan 6, 2017 at 4:39 PM, javed khan  wrote:

> Hi Lorenz, I uses this
>
> SELECT  (max(?score) as ?highScore)
> WHERE { ?std ont:Englishscore ?score }
>
> And it gives me the highscore of subject English as 77
>
> When I use this
>
> SELECT ?std (max(?score) as ?highScore)
> WHERE { ?std ont:Englishscore ?score } GROUP BY ?std
>
> It gives me all the students with the scores like:
> Jim 60
> Kane 77
> Smith 57 etc
>
> I want result like *Kane 77*
>
>
>
> On Fri, Jan 6, 2017 at 1:45 PM, Lorenz B.  leipzig.de> wrote:
>
>> Yes, that would be the easiest solution.
>>
>> > Hello Lorenz, thanks a lot for kind cooperation.
>> >
>> >  It means I will have three queries for NetworkingScore,
>> Cryptographyscore
>> > and SEscore?
>> >
>> > On Thu, Jan 5, 2017 at 1:27 PM, Lorenz B. <
>> > buehm...@informatik.uni-leipzig.de> wrote:
>> >
>> >> The query I showed returns the highest value for one subject as I said.
>> >> Executing three SPARQL queries should therefore be rather simple.
>> >>
>> >> PREFIX ex: <http://example.com/ns/>
>> >> SELECT (MAX(?score) AS ?topScore)
>> >> WHERE
>> >> {
>> >>   ?student ex:CryptographyScore ?score .
>> >> }
>> >>
>> >> So what's wrong with this query? If you also want to have the
>> student(s)
>> >> with this score, try
>> >>
>> >> PREFIX ex: <http://example.com/ns/>
>> >> SELECT ?student ?topScore WHERE {
>> >>
>> >> #-- Find the high score in the subject
>> >> {
>> >>
>> >> SELECT (MAX(?score) AS ?topScore) WHERE
>> >> {
>> >>   ?student ex:CryptographyScore ?score .
>> >> }
>> >>
>> >> }
>> >>
>> >> #-- Then find the student(s) that had that high score in the
>> subject
>> >> ?student ex:CryptographyScore ?topScore .
>> >>
>> >> }
>> >>
>> >> Or you can use SPARQL 1.1 aggregate function SAMPLE.
>> >>
>> >> Otherwise you can also use a single SPARQL query and put, but it looks
>> >> like you have to learn SPARQL and we're doing your homework - this is
>> >> obviously the wrong direction when you want to lean something about
>> >> Semantic Web...
>> >>
>> >> By the way, I wouldn't create a data property for each subject but
>> >> attach the subject to the score. But that's how I would do it and out
>> of
>> >> scope here.
>> >>
>> >>
>> >>
>> >>
>> >>> Let me explain : There are 4 students, having scores of three subjects
>> >>> (1) Bob:  Cryptographyscore 50, SE score 58, *Networking score 70*
>> >>>  (2) Jim:  *Cryptographyscore 86*, SEscore 55, Networkingscore 48
>> >>> (3)  Smith: Cryptographyscore 78, *SEscore 79*, Networkingscore 60
>> >>> (4) David: Cryptographyscore 50, SEscore 66, Networkingscore 55
>> >>>
>> >>> I want the highest score of each category any user has scored, like in
>> >>> cryptography the highest score is 86 scored by Jim, in SE highest
>> score
>> >> is
>> >>> 79 scored by Smith and so on.
>> >>>
>> >>> So I want the maximum score in each of the three categories, which are
>> >> our
>> >>> data properties in the rdf file and this is why I thought we should
>> use
>> >>> three variables for Max.
>> >>>
>> >>> Lorenz still I achieve this with the query you and Rob have suggested?
>> >>>
>> >>> Thank you
>> >>>
>> >>>
>> >>> On Wed, Jan 4, 2017 at 6:38 PM, Lorenz Buehmann <
>> >>> buehm...@informatik.uni-leipzig.de> wrote:
>> >>>
>> >>>>> Hello Rob,
>> >>>>>
>> >>>>> We are in a group and we discussed it.
>> >>>>>
>> >>>>> We have three data properties , CryptographyScore,
>> SoftwareEngineering
>> >>>>> score

Re: Rules

2017-01-06 Thread javed khan
Thanks a lot Lorenz, yes the query you provided perfectly works. Kindly one
last cooperation, I have never tried nested queries in Jena code and it
gives me error, so if you provide the correct syntax i-e where to use the
commas and where not?

Thanks again.
Regards

On Fri, Jan 6, 2017 at 5:23 PM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

>
>
> > This query now display both student and highscore
> >
> > select ?subject ?student ?highScore where {
> > {select ?subject (max(?score) as ?highScore) { ?student ont:Englishsscore
> > ?score
> >  }
> > group by ?subject
> >   }
> > ?student ont:Englishscore ?highScore
> > }
> Doesn't make sense. Don't copy answers from Stackoverflow if the data
> doesn't match the suggested solution by Joshua Taylor! You're grouping
> by a variable ?subject that is nowhere assigned in the query.
>
> I already gave you the alternative query yesterday in one of my
> responses. Would be good if you read them carefully and also try to
> understand what's happening there.
> >
> > On Fri, Jan 6, 2017 at 4:39 PM, javed khan 
> wrote:
> >
> >> Hi Lorenz, I uses this
> >>
> >> SELECT  (max(?score) as ?highScore)
> >> WHERE { ?std ont:Englishscore ?score }
> >>
> >> And it gives me the highscore of subject English as 77
> >>
> >> When I use this
> >>
> >> SELECT ?std (max(?score) as ?highScore)
> >> WHERE { ?std ont:Englishscore ?score } GROUP BY ?std
> >>
> >> It gives me all the students with the scores like:
> >> Jim 60
> >> Kane 77
> >> Smith 57 etc
> >>
> >> I want result like *Kane 77*
> >>
> >>
> >>
> >> On Fri, Jan 6, 2017 at 1:45 PM, Lorenz B.  >> leipzig.de> wrote:
> >>
> >>> Yes, that would be the easiest solution.
> >>>
> >>>> Hello Lorenz, thanks a lot for kind cooperation.
> >>>>
> >>>>  It means I will have three queries for NetworkingScore,
> >>> Cryptographyscore
> >>>> and SEscore?
> >>>>
> >>>> On Thu, Jan 5, 2017 at 1:27 PM, Lorenz B. <
> >>>> buehm...@informatik.uni-leipzig.de> wrote:
> >>>>
> >>>>> The query I showed returns the highest value for one subject as I
> said.
> >>>>> Executing three SPARQL queries should therefore be rather simple.
> >>>>>
> >>>>> PREFIX ex: <http://example.com/ns/>
> >>>>> SELECT (MAX(?score) AS ?topScore)
> >>>>> WHERE
> >>>>> {
> >>>>>   ?student ex:CryptographyScore ?score .
> >>>>> }
> >>>>>
> >>>>> So what's wrong with this query? If you also want to have the
> >>> student(s)
> >>>>> with this score, try
> >>>>>
> >>>>> PREFIX ex: <http://example.com/ns/>
> >>>>> SELECT ?student ?topScore WHERE {
> >>>>>
> >>>>> #-- Find the high score in the subject
> >>>>> {
> >>>>>
> >>>>> SELECT (MAX(?score) AS ?topScore) WHERE
> >>>>> {
> >>>>>   ?student ex:CryptographyScore ?score .
> >>>>> }
> >>>>>
> >>>>> }
> >>>>>
> >>>>> #-- Then find the student(s) that had that high score in the
> >>> subject
> >>>>> ?student ex:CryptographyScore ?topScore .
> >>>>>
> >>>>> }
> >>>>>
> >>>>> Or you can use SPARQL 1.1 aggregate function SAMPLE.
> >>>>>
> >>>>> Otherwise you can also use a single SPARQL query and put, but it
> looks
> >>>>> like you have to learn SPARQL and we're doing your homework - this is
> >>>>> obviously the wrong direction when you want to lean something about
> >>>>> Semantic Web...
> >>>>>
> >>>>> By the way, I wouldn't create a data property for each subject but
> >>>>> attach the subject to the score. But that's how I would do it and out
> >>> of
> >>>>> scope here.
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>> Let me explain : There are 4 students, having scores o

Re: Rules

2017-01-07 Thread javed khan
Hi Lorenz, I am asking about the query you provided to be used in Jena
syntax like below I used in Jena

SELECT ?student ?topScore WHERE {
 {SELECT (MAX(?score) AS ?topScore) WHERE
{?student ex:CryptographyScore ?score .
} }
?student ex:CryptographyScore ?topScore .}


___

String queryString= "PREFIX mo:<http://www.semanticweb.org/t/ont#> "+
 "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "+

  "SELECT  ?std " +
" WHERE {   ?std rdf:type std:Student }";

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

> Which query do you mean and which error do you get? There is no need for
> a comma when using a nested query
>
> > Thanks a lot Lorenz, yes the query you provided perfectly works. Kindly
> one
> > last cooperation, I have never tried nested queries in Jena code and it
> > gives me error, so if you provide the correct syntax i-e where to use the
> > commas and where not?
> >
> > Thanks again.
> > Regards
> >
> > On Fri, Jan 6, 2017 at 5:23 PM, Lorenz B. <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >>
> >>> This query now display both student and highscore
> >>>
> >>> select ?subject ?student ?highScore where {
> >>> {select ?subject (max(?score) as ?highScore) { ?student
> ont:Englishsscore
> >>> ?score
> >>>  }
> >>> group by ?subject
> >>>   }
> >>> ?student ont:Englishscore ?highScore
> >>> }
> >> Doesn't make sense. Don't copy answers from Stackoverflow if the data
> >> doesn't match the suggested solution by Joshua Taylor! You're grouping
> >> by a variable ?subject that is nowhere assigned in the query.
> >>
> >> I already gave you the alternative query yesterday in one of my
> >> responses. Would be good if you read them carefully and also try to
> >> understand what's happening there.
> >>> On Fri, Jan 6, 2017 at 4:39 PM, javed khan 
> >> wrote:
> >>>> Hi Lorenz, I uses this
> >>>>
> >>>> SELECT  (max(?score) as ?highScore)
> >>>> WHERE { ?std ont:Englishscore ?score }
> >>>>
> >>>> And it gives me the highscore of subject English as 77
> >>>>
> >>>> When I use this
> >>>>
> >>>> SELECT ?std (max(?score) as ?highScore)
> >>>> WHERE { ?std ont:Englishscore ?score } GROUP BY ?std
> >>>>
> >>>> It gives me all the students with the scores like:
> >>>> Jim 60
> >>>> Kane 77
> >>>> Smith 57 etc
> >>>>
> >>>> I want result like *Kane 77*
> >>>>
> >>>>
> >>>>
> >>>> On Fri, Jan 6, 2017 at 1:45 PM, Lorenz B.  >>>> leipzig.de> wrote:
> >>>>
> >>>>> Yes, that would be the easiest solution.
> >>>>>
> >>>>>> Hello Lorenz, thanks a lot for kind cooperation.
> >>>>>>
> >>>>>>  It means I will have three queries for NetworkingScore,
> >>>>> Cryptographyscore
> >>>>>> and SEscore?
> >>>>>>
> >>>>>> On Thu, Jan 5, 2017 at 1:27 PM, Lorenz B. <
> >>>>>> buehm...@informatik.uni-leipzig.de> wrote:
> >>>>>>
> >>>>>>> The query I showed returns the highest value for one subject as I
> >> said.
> >>>>>>> Executing three SPARQL queries should therefore be rather simple.
> >>>>>>>
> >>>>>>> PREFIX ex: <http://example.com/ns/>
> >>>>>>> SELECT (MAX(?score) AS ?topScore)
> >>>>>>> WHERE
> >>>>>>> {
> >>>>>>>   ?student ex:CryptographyScore ?score .
> >>>>>>> }
> >>>>>>>
> >>>>>>> So what's wrong with this query? If you also want to have the
> >>>>> student(s)
> >>>>>>> with this score, try
> >>>>>>>
> >>>>>>> PREFIX ex: <http://example.com/ns/>
> >>>>>>> SELECT ?student ?topScore WHERE {
> >>>>>>>
> >>>>>>> #-- Find the high score in the subject
> >&g

Re: Rules

2017-01-07 Thread javed khan
Hello Lorenz, usually we use " " signs and + sign inside our query in Jena
syntax

 "SELECT  ?student " +

" WHERE {   ?student rdf:type std:Student}"; //In simple query

 But that query has two select statements and where clause, I am confused
where to put the " " and + signs in the query.

I have tried this but it gives me syntax error,



   *  "SELECT  ?student ?topScore " +*

*   " WHERE {   {select  (max(?score) as ?highScore)" +
 "WHERE  { ?student std:Englishscore ?score + "*

*" }" +*
*"  } " +*
*   "?student std:Englishscore ?highScore"   *

*  "}";*



On Sat, Jan 7, 2017 at 5:30 PM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

> This query is syntactically correct once you add the prefix declaration
> in front of the query. I used ex: here but indeed I don't know the
> namespace and omitted the prefix declaration for brevity. I don't
> understand what you meant with the usage of a comma.
>
> > Hi Lorenz, I am asking about the query you provided to be used in Jena
> > syntax like below I used in Jena
> >
> > SELECT ?student ?topScore WHERE {
> >  {SELECT (MAX(?score) AS ?topScore) WHERE
> > {?student ex:CryptographyScore ?score .
> > } }
> > ?student ex:CryptographyScore ?topScore .}
> >
> >
> > ___
> >
> > String queryString= "PREFIX mo:<http://www.semanticweb.org/t/ont#> "+
> >  "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "+
> >
> >   "SELECT  ?std " +
> > " WHERE {   ?std rdf:type std:Student }";
> >
> > On Sat, Jan 7, 2017 at 3:17 PM, Lorenz B. <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >> Which query do you mean and which error do you get? There is no need for
> >> a comma when using a nested query
> >>
> >>> Thanks a lot Lorenz, yes the query you provided perfectly works. Kindly
> >> one
> >>> last cooperation, I have never tried nested queries in Jena code and it
> >>> gives me error, so if you provide the correct syntax i-e where to use
> the
> >>> commas and where not?
> >>>
> >>> Thanks again.
> >>> Regards
> >>>
> >>> On Fri, Jan 6, 2017 at 5:23 PM, Lorenz B. <
> >>> buehm...@informatik.uni-leipzig.de> wrote:
> >>>
> >>>>> This query now display both student and highscore
> >>>>>
> >>>>> select ?subject ?student ?highScore where {
> >>>>> {select ?subject (max(?score) as ?highScore) { ?student
> >> ont:Englishsscore
> >>>>> ?score
> >>>>>  }
> >>>>> group by ?subject
> >>>>>   }
> >>>>> ?student ont:Englishscore ?highScore
> >>>>> }
> >>>> Doesn't make sense. Don't copy answers from Stackoverflow if the data
> >>>> doesn't match the suggested solution by Joshua Taylor! You're grouping
> >>>> by a variable ?subject that is nowhere assigned in the query.
> >>>>
> >>>> I already gave you the alternative query yesterday in one of my
> >>>> responses. Would be good if you read them carefully and also try to
> >>>> understand what's happening there.
> >>>>> On Fri, Jan 6, 2017 at 4:39 PM, javed khan 
> >>>> wrote:
> >>>>>> Hi Lorenz, I uses this
> >>>>>>
> >>>>>> SELECT  (max(?score) as ?highScore)
> >>>>>> WHERE { ?std ont:Englishscore ?score }
> >>>>>>
> >>>>>> And it gives me the highscore of subject English as 77
> >>>>>>
> >>>>>> When I use this
> >>>>>>
> >>>>>> SELECT ?std (max(?score) as ?highScore)
> >>>>>> WHERE { ?std ont:Englishscore ?score } GROUP BY ?std
> >>>>>>
> >>>>>> It gives me all the students with the scores like:
> >>>>>> Jim 60
> >>>>>> Kane 77
> >>>>>> Smith 57 etc
> >>>>>>
> >>>>>> I want result like *Kane 77*
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> On

Literal Required Exception in SPARQL

2017-01-08 Thread javed khan
This query gives me exception:

Exception in thread "AWT-EventQueue-0"
com.hp.hpl.jena.rdf.model.LiteralRequiredException:
http://www.semanticweb.org/t/ontologies#Smith



  "SELECT  * " +

   " WHERE {" + " {"+ "select  (max(?score) as ?highScore)"
+ " { ?student std:Englishscore ?score" +
" }" +
"  } " +
"?student std:Englishscore ?highScore"   +

  "}";


 Query query2 = QueryFactory.create(queryString2);
QueryExecution qexec = QueryExecutionFactory.create(query2, model) ;
ResultSet results2 = qexec.execSelect() ;

   Literal l2=results2.next().get("student").asLiteral();
Literal l3=results2.next().get("highScore").asLiteral();
String s=l3.toString();
JOptionPane.showMessageDialog(null,"high score is" + s );


Re: Literal Required Exception in SPARQL

2017-01-09 Thread javed khan
Hello Lorenz, yes I need student and highscore.

I just tried this , no exception but it does not display the message in
JOptionPane.showMessageDialog()

 Query query2 = QueryFactory.create(queryString2);
QueryExecution qexec = QueryExecutionFactory.create(query2, model) ;
ResultSet results2 = qexec.execSelect() ;

 RDFNode r;
 while(results2.hasNext()){

QuerySolution sol= results2.nextSolution();
  r=sol.get("student");
   JOptionPane.showMessageDialog(null,"high score is" + r );
 }

On Mon, Jan 9, 2017 at 1:42 PM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

> @ As per the previous discussion, I guess he also wants to have the
> student - and of course the highest score,
>
> As Chris said, you have to distinguish between literals and URIs/blank
> nodes.
>
> Which finally leads me to the suggestion to read an RDF tutorial +
> SPARQL tutorial first. Most questions are really basic.
>
>
> On 09.01.2017 09:38, Chris Dollin wrote:
> >
> >
> > On 08/01/17 18:32, javed khan wrote:
> >> This query gives me exception:
> >>
> >> Exception in thread "AWT-EventQueue-0"
> >> com.hp.hpl.jena.rdf.model.LiteralRequiredException:
> >> http://www.semanticweb.org/t/ontologies#Smith
> >>
> >>   "SELECT  * " +
> >>
> >>" WHERE {" + " {"+ "select  (max(?score) as
> >> ?highScore)"
> >> + " { ?student std:Englishscore ?score" +
> >> " }" +
> >> "  } " +
> >> "?student std:Englishscore ?highScore"   +
> >>
> >>   "}";
> >
> > The variable ?subject will be the subject of a triple.
> > Subjects may be blank nodes or resources with URIs.
> >
> >>  Query query2 = QueryFactory.create(queryString2);
> >> QueryExecution qexec = QueryExecutionFactory.create(query2, model) ;
> >> ResultSet results2 = qexec.execSelect() ;
> >>
> >>Literal l2=results2.next().get("student").asLiteral();
> >
> > get("student") will return the value of "student", which will
> > be a resource or blank node, but NOT a literal. asLiteral
> > expects a Literal.
> >
> > BOOM.
> >
> > My pre-caffeine guess is that you want "highscore" not "student".
> > As others have said, offer complete minimal examples.
> >
> > Chris
> >
>
>


Re: Literal Required Exception in SPARQL

2017-01-09 Thread javed khan
[image: Inline image 1]


It shows the result in Protege: Mac is student name and 6 is highscore of
English category scored by him.

On Mon, Jan 9, 2017 at 4:34 PM, Andy Seaborne  wrote:

> Maybe there are no results.
>
> This is not a complete, minimal example. Unseen details probably matter.
>
> Andy
>
>
> On 09/01/17 13:28, javed khan wrote:
>
>> Hello Lorenz, yes I need student and highscore.
>>
>> I just tried this , no exception but it does not display the message in
>> JOptionPane.showMessageDialog()
>>
>>  Query query2 = QueryFactory.create(queryString2);
>> QueryExecution qexec = QueryExecutionFactory.create(query2, model) ;
>> ResultSet results2 = qexec.execSelect() ;
>>
>>  RDFNode r;
>>  while(results2.hasNext()){
>>
>> QuerySolution sol= results2.nextSolution();
>>   r=sol.get("student");
>>JOptionPane.showMessageDialog(null,"high score is" + r );
>>  }
>>
>> On Mon, Jan 9, 2017 at 1:42 PM, Lorenz Buehmann <
>> buehm...@informatik.uni-leipzig.de> wrote:
>>
>> @ As per the previous discussion, I guess he also wants to have the
>>> student - and of course the highest score,
>>>
>>> As Chris said, you have to distinguish between literals and URIs/blank
>>> nodes.
>>>
>>> Which finally leads me to the suggestion to read an RDF tutorial +
>>> SPARQL tutorial first. Most questions are really basic.
>>>
>>>
>>> On 09.01.2017 09:38, Chris Dollin wrote:
>>>
>>>>
>>>>
>>>> On 08/01/17 18:32, javed khan wrote:
>>>>
>>>>> This query gives me exception:
>>>>>
>>>>> Exception in thread "AWT-EventQueue-0"
>>>>> com.hp.hpl.jena.rdf.model.LiteralRequiredException:
>>>>> http://www.semanticweb.org/t/ontologies#Smith
>>>>>
>>>>>   "SELECT  * " +
>>>>>
>>>>>" WHERE {" + " {"+ "select  (max(?score) as
>>>>> ?highScore)"
>>>>> + " { ?student std:Englishscore ?score" +
>>>>> " }" +
>>>>> "  } " +
>>>>> "?student std:Englishscore ?highScore"   +
>>>>>
>>>>>   "}";
>>>>>
>>>>
>>>> The variable ?subject will be the subject of a triple.
>>>> Subjects may be blank nodes or resources with URIs.
>>>>
>>>>  Query query2 = QueryFactory.create(queryString2);
>>>>> QueryExecution qexec = QueryExecutionFactory.create(query2, model) ;
>>>>> ResultSet results2 = qexec.execSelect() ;
>>>>>
>>>>>Literal l2=results2.next().get("student").asLiteral();
>>>>>
>>>>
>>>> get("student") will return the value of "student", which will
>>>> be a resource or blank node, but NOT a literal. asLiteral
>>>> expects a Literal.
>>>>
>>>> BOOM.
>>>>
>>>> My pre-caffeine guess is that you want "highscore" not "student".
>>>> As others have said, offer complete minimal examples.
>>>>
>>>> Chris
>>>>
>>>>
>>>
>>>
>>


Re: Literal Required Exception in SPARQL

2017-01-09 Thread javed khan
Hello Lorenz, I think the problem is in the query itself inside Jena
code(probably the syntax of the query). Because a very simple query
like *?student
std:EnglishScore ?score*
works.
The querystring is:

prefix std:<http://www.semanticweb.org/ontologies#>PREFIX rdfs:<
http://www.w3.org/2000/01/rdf-schema#> PREFIX rdf:<
http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT  *  WHERE { {select  (max(?score) as ?highScore) { ?student
std:Englishscore ?score }  } ?student std:Englishsscore ?highScore}



On Mon, Jan 9, 2017 at 5:40 PM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

> Inline images are not allowed here, thus we can't see anything. And a
> screenshot of Protege is not really helpful.
>
> Prefixes might be wrong. We neither know the final query, nor your code.
>
> Please show a sample of the data in best case in Turtle format. And the
> final query - please not again as Java concatenated String but as the
> output from System.out.println(query2)
>
>
>
> On 09.01.2017 15:06, javed khan wrote:
> > Inline image 1
> >
> >
> > It shows the result in Protege: Mac is student name and 6 is highscore
> > of English category scored by him.
> >
> > On Mon, Jan 9, 2017 at 4:34 PM, Andy Seaborne  > <mailto:a...@apache.org>> wrote:
> >
> > Maybe there are no results.
> >
> > This is not a complete, minimal example. Unseen details probably
> > matter.
> >
> > Andy
> >
> >
> > On 09/01/17 13:28, javed khan wrote:
> >
> > Hello Lorenz, yes I need student and highscore.
> >
> > I just tried this , no exception but it does not display the
> > message in
> > JOptionPane.showMessageDialog()
> >
> >  Query query2 = QueryFactory.create(queryString2);
> > QueryExecution qexec = QueryExecutionFactory.create(query2,
> > model) ;
> > ResultSet results2 = qexec.execSelect() ;
> >
> >  RDFNode r;
> >  while(results2.hasNext()){
> >
> > QuerySolution sol= results2.nextSolution();
> >   r=sol.get("student");
> >JOptionPane.showMessageDialog(null,"high score is" + r );
> >  }
> >
> > On Mon, Jan 9, 2017 at 1:42 PM, Lorenz Buehmann <
> > buehm...@informatik.uni-leipzig.de
> > <mailto:buehm...@informatik.uni-leipzig.de>> wrote:
> >
> > @ As per the previous discussion, I guess he also wants to
> > have the
> > student - and of course the highest score,
> >
> > As Chris said, you have to distinguish between literals
> > and URIs/blank
> > nodes.
> >
> > Which finally leads me to the suggestion to read an RDF
> > tutorial +
> > SPARQL tutorial first. Most questions are really basic.
> >
> >
> > On 09.01.2017 09:38, Chris Dollin wrote:
> >
> >
> >
> > On 08/01/17 18:32, javed khan wrote:
> >
> > This query gives me exception:
> >
> > Exception in thread "AWT-EventQueue-0"
> > com.hp.hpl.jena.rdf.model.LiteralRequiredException:
> > http://www.semanticweb.org/t/ontologies#Smith
> > <http://www.semanticweb.org/t/ontologies#Smith>
> >
> >   "SELECT  * " +
> >
> >" WHERE {" + " {"+ "select
> > (max(?score) as
> > ?highScore)"
> > + " { ?student std:Englishscore ?score" +
> > " }" +
> > "  } " +
> > "?student std:Englishscore ?highScore"   +
> >
> >   "}";
> >
> >
> > The variable ?subject will be the subject of a triple.
> > Subjects may be blank nodes or resources with URIs.
> >
> >  Query query2 =
> > QueryFactory.create(queryString2);
> > QueryExecution qexec =
> > QueryExecutionFactory.create(query2, model) ;
> > ResultSet results2 = qexec.execSelect() ;
> >
> >Literal
> > l2=results2.next().get("student").asLiteral();
> >
> >
> > get("student") will return the value of "student",
> > which will
> > be a resource or blank node, but NOT a literal. asLiteral
> > expects a Literal.
> >
> > BOOM.
> >
> > My pre-caffeine guess is that you want "highscore" not
> > "student".
> > As others have said, offer complete minimal examples.
> >
> > Chris
> >
> >
> >
> >
> >
>
>


Re: Literal Required Exception in SPARQL

2017-01-09 Thread javed khan
I used std:Englishscore in my query and  is also in my ontology. If I wrote
somewhere EnglishScore, it will be a typo error.

On Mon, Jan 9, 2017 at 6:41 PM, Andy Seaborne  wrote:

>
>
> On 09/01/17 15:05, javed khan wrote:
>
>> Hello Lorenz, I think the problem is in the query itself inside Jena
>> code(probably the syntax of the query). Because a very simple query
>> like *?student
>> std:EnglishScore ?score*
>> works.
>> The querystring is:
>>
>> prefix std:<http://www.semanticweb.org/ontologies#>PREFIX rdfs:<
>> http://www.w3.org/2000/01/rdf-schema#> PREFIX rdf:<
>> http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>> SELECT  *  WHERE { {select  (max(?score) as ?highScore) { ?student
>> std:Englishscore ?score }  } ?student std:Englishsscore ?highScore}
>>
>
> std:Englishscore vs std:Englishsscore
>
> spelt differently.
>
>
>
>>
>>
>> On Mon, Jan 9, 2017 at 5:40 PM, Lorenz Buehmann <
>> buehm...@informatik.uni-leipzig.de> wrote:
>>
>> Inline images are not allowed here, thus we can't see anything. And a
>>> screenshot of Protege is not really helpful.
>>>
>>> Prefixes might be wrong. We neither know the final query, nor your code.
>>>
>>> Please show a sample of the data in best case in Turtle format. And the
>>> final query - please not again as Java concatenated String but as the
>>> output from System.out.println(query2)
>>>
>>>
>>>
>>> On 09.01.2017 15:06, javed khan wrote:
>>>
>>>> Inline image 1
>>>>
>>>>
>>>> It shows the result in Protege: Mac is student name and 6 is highscore
>>>> of English category scored by him.
>>>>
>>>> On Mon, Jan 9, 2017 at 4:34 PM, Andy Seaborne >>> <mailto:a...@apache.org>> wrote:
>>>>
>>>> Maybe there are no results.
>>>>
>>>> This is not a complete, minimal example. Unseen details probably
>>>> matter.
>>>>
>>>> Andy
>>>>
>>>>
>>>> On 09/01/17 13:28, javed khan wrote:
>>>>
>>>> Hello Lorenz, yes I need student and highscore.
>>>>
>>>> I just tried this , no exception but it does not display the
>>>> message in
>>>> JOptionPane.showMessageDialog()
>>>>
>>>>  Query query2 = QueryFactory.create(queryString2);
>>>> QueryExecution qexec = QueryExecutionFactory.create(query2,
>>>> model) ;
>>>> ResultSet results2 = qexec.execSelect() ;
>>>>
>>>>  RDFNode r;
>>>>  while(results2.hasNext()){
>>>>
>>>> QuerySolution sol= results2.nextSolution();
>>>>   r=sol.get("student");
>>>>JOptionPane.showMessageDialog(null,"high score is" + r
>>>> );
>>>>  }
>>>>
>>>> On Mon, Jan 9, 2017 at 1:42 PM, Lorenz Buehmann <
>>>> buehm...@informatik.uni-leipzig.de
>>>> <mailto:buehm...@informatik.uni-leipzig.de>> wrote:
>>>>
>>>> @ As per the previous discussion, I guess he also wants to
>>>> have the
>>>> student - and of course the highest score,
>>>>
>>>> As Chris said, you have to distinguish between literals
>>>> and URIs/blank
>>>> nodes.
>>>>
>>>> Which finally leads me to the suggestion to read an RDF
>>>> tutorial +
>>>> SPARQL tutorial first. Most questions are really basic.
>>>>
>>>>
>>>> On 09.01.2017 09:38, Chris Dollin wrote:
>>>>
>>>>
>>>>
>>>> On 08/01/17 18:32, javed khan wrote:
>>>>
>>>> This query gives me exception:
>>>>
>>>> Exception in thread "AWT-EventQueue-0"
>>>> com.hp.hpl.jena.rdf.model.LiteralRequiredException:
>>>> http://www.semanticweb.org/t/ontologies#Smith
>>>> <http://www.semanticweb.org/t/ontologies#Smith>
>>>>
>>>>   "SELECT  * " +
>>>>
>>&g

Re: Literal Required Exception in SPARQL

2017-01-09 Thread javed khan
I am sorry Andy I did not understand what you mentioned.

The problem still there, though I have made several changes: and the
problem points here

 Literal r= results2.next().get("highScore").asLiteral();
or
RDFNode r2= results2.next().get("student").asResource();

The error message is

*Exception in thread "AWT-EventQueue-0" java.util.NoSuchElementException:
QueryIteratorCloseable*
* at
com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorBase.nextBinding(QueryIteratorBase.java:9*
3

On Mon, Jan 9, 2017 at 6:53 PM, Andy Seaborne  wrote:

> That is not the error in the query I pointed out.  It makes a difference
> in the query.
>
>
> On 09/01/17 15:45, javed khan wrote:
>
>> I used std:Englishscore in my query and  is also in my ontology. If I
>> wrote
>> somewhere EnglishScore, it will be a typo error.
>>
>> On Mon, Jan 9, 2017 at 6:41 PM, Andy Seaborne  wrote:
>>
>>
>>>
>>> On 09/01/17 15:05, javed khan wrote:
>>>
>>> Hello Lorenz, I think the problem is in the query itself inside Jena
>>>> code(probably the syntax of the query). Because a very simple query
>>>> like *?student
>>>> std:EnglishScore ?score*
>>>> works.
>>>> The querystring is:
>>>>
>>>> prefix std:<http://www.semanticweb.org/ontologies#>PREFIX rdfs:<
>>>> http://www.w3.org/2000/01/rdf-schema#> PREFIX rdf:<
>>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>>>> SELECT  *  WHERE { {select  (max(?score) as ?highScore) { ?student
>>>> std:Englishscore ?score }  } ?student std:Englishsscore ?highScore}
>>>>
>>>>
>>> std:Englishscore vs std:Englishsscore
>>>
>>> spelt differently.
>>>
>>>
>>>
>>>
>>>>
>>>> On Mon, Jan 9, 2017 at 5:40 PM, Lorenz Buehmann <
>>>> buehm...@informatik.uni-leipzig.de> wrote:
>>>>
>>>> Inline images are not allowed here, thus we can't see anything. And a
>>>>
>>>>> screenshot of Protege is not really helpful.
>>>>>
>>>>> Prefixes might be wrong. We neither know the final query, nor your
>>>>> code.
>>>>>
>>>>> Please show a sample of the data in best case in Turtle format. And the
>>>>> final query - please not again as Java concatenated String but as the
>>>>> output from System.out.println(query2)
>>>>>
>>>>>
>>>>>
>>>>> On 09.01.2017 15:06, javed khan wrote:
>>>>>
>>>>> Inline image 1
>>>>>>
>>>>>>
>>>>>> It shows the result in Protege: Mac is student name and 6 is highscore
>>>>>> of English category scored by him.
>>>>>>
>>>>>> On Mon, Jan 9, 2017 at 4:34 PM, Andy Seaborne >>>>> <mailto:a...@apache.org>> wrote:
>>>>>>
>>>>>> Maybe there are no results.
>>>>>>
>>>>>> This is not a complete, minimal example. Unseen details probably
>>>>>> matter.
>>>>>>
>>>>>> Andy
>>>>>>
>>>>>>
>>>>>> On 09/01/17 13:28, javed khan wrote:
>>>>>>
>>>>>> Hello Lorenz, yes I need student and highscore.
>>>>>>
>>>>>> I just tried this , no exception but it does not display the
>>>>>> message in
>>>>>> JOptionPane.showMessageDialog()
>>>>>>
>>>>>>  Query query2 = QueryFactory.create(queryString2);
>>>>>> QueryExecution qexec = QueryExecutionFactory.create(query2,
>>>>>> model) ;
>>>>>> ResultSet results2 = qexec.execSelect() ;
>>>>>>
>>>>>>  RDFNode r;
>>>>>>  while(results2.hasNext()){
>>>>>>
>>>>>> QuerySolution sol= results2.nextSolution();
>>>>>>   r=sol.get("student");
>>>>>>JOptionPane.showMessageDialog(null,"high score is" + r
>>>>>> );
>>>>>>  }
>>>>>>
>>>>>> On Mon, Jan 9, 2017 at 1:42 PM, Lorenz Buehmann <
>>>>>> buehm...

Re: Literal Required Exception in SPARQL

2017-01-09 Thread javed khan
This is my query and code.  I have to find just one tripe: Subject
highscore by a student
Like  subject English highscore is 60 by Smith.
When I run query inside Protege, it gives me the result
Smith  60 and it is fine. This result (Smith  60), I cant get inside Jena
code and get exception.

Code is below.

String queryString2=
   "prefix std:<http://www.semanticweb.org/ontologies#>"+

 "SELECT  ?student ?highScore " +


  " WHERE {" + " {"+ "select  (max(?score) as ?highScore)"
+ " { ?student std:Englishscore ?score" +
" }" +
"  } " +
"?student std:Englishsscore ?highScore"   +


  "}";

 System.out.println(queryString2);
 Query query2 = QueryFactory.create(queryString2);
QueryExecution qexec = QueryExecutionFactory.create(query2, model) ;
ResultSet results2 = qexec.execSelect() ;

Literal r= results2.next().get("highScore").asLiteral();
JOptionPane.showMessageDialog(null,r.toString());

On Mon, Jan 9, 2017 at 10:23 PM, Andy Seaborne  wrote:

> Once again you do not provide a complete, minimal example.
> And this is different code to what you showed earlier.
>
>
> std:Englishscore
> std:Englishsscore   <-- if this is wrong
>
> there is no match and next() is NoSuchElementException
>
> Andy
>
> On 09/01/17 17:51, javed khan wrote:
>
>> I am sorry Andy I did not understand what you mentioned.
>>
>> The problem still there, though I have made several changes: and the
>> problem points here
>>
>>  Literal r= results2.next().get("highScore").asLiteral();
>> or
>> RDFNode r2= results2.next().get("student").asResource();
>>
>> The error message is
>>
>> *Exception in thread "AWT-EventQueue-0" java.util.NoSuchElementException:
>> QueryIteratorCloseable*
>> * at
>> com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorBase.nex
>> tBinding(QueryIteratorBase.java:9*
>>
>> 3
>>
>> On Mon, Jan 9, 2017 at 6:53 PM, Andy Seaborne  wrote:
>>
>> That is not the error in the query I pointed out.  It makes a difference
>>> in the query.
>>>
>>>
>>> On 09/01/17 15:45, javed khan wrote:
>>>
>>> I used std:Englishscore in my query and  is also in my ontology. If I
>>>> wrote
>>>> somewhere EnglishScore, it will be a typo error.
>>>>
>>>> On Mon, Jan 9, 2017 at 6:41 PM, Andy Seaborne  wrote:
>>>>
>>>>
>>>>
>>>>> On 09/01/17 15:05, javed khan wrote:
>>>>>
>>>>> Hello Lorenz, I think the problem is in the query itself inside Jena
>>>>>
>>>>>> code(probably the syntax of the query). Because a very simple query
>>>>>> like *?student
>>>>>> std:EnglishScore ?score*
>>>>>> works.
>>>>>> The querystring is:
>>>>>>
>>>>>> prefix std:<http://www.semanticweb.org/ontologies#>PREFIX rdfs:<
>>>>>> http://www.w3.org/2000/01/rdf-schema#> PREFIX rdf:<
>>>>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>>>>>> SELECT  *  WHERE { {select  (max(?score) as ?highScore) { ?student
>>>>>> std:Englishscore ?score }  } ?student std:Englishsscore ?highScore}
>>>>>>
>>>>>>
>>>>>> std:Englishscore vs std:Englishsscore
>>>>>
>>>>> spelt differently.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> On Mon, Jan 9, 2017 at 5:40 PM, Lorenz Buehmann <
>>>>>> buehm...@informatik.uni-leipzig.de> wrote:
>>>>>>
>>>>>> Inline images are not allowed here, thus we can't see anything. And a
>>>>>>
>>>>>> screenshot of Protege is not really helpful.
>>>>>>>
>>>>>>> Prefixes might be wrong. We neither know the final query, nor your
>>>>>>> code.
>>>>>>>
>>>>>>> Please show a sample of the data in best case in Turtle format. And
>>>>>>> the
>>>>>>> final query - please not again as Java concatenated String but as the
>>>>>>> output from System.out.println(query2)
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On 09.01.2

SPARQL query exception

2017-01-26 Thread javed khan
*The following query works *   :

"SELECT  ?student ?highScore " +

   " WHERE {" + " {"+ "select  (max(?score) as ?highScore)"
+ " { ?student dd:Englishscore ?score" +
" }" +
"  } " +
"?student dd:Englishscore ?highScore"   +


  "}";

 Query query2 = QueryFactory.create(queryString2);
QueryExecution qexec = QueryExecutionFactory.create(query2, model2) ;
ResultSet results2 = qexec.execSelect() ;

  Literal r= results2.next().get("highScore").asLiteral();
   String ss= r.getLexicalForm();
   JOptionPane.showMessageDialog(null,"High score of Physics is"+s + "by
Student");

This query now works but when I include also the student name, it gives me
exception again.

 * Resource r2= results2.next().get("student").asResource();*
*   String s=r2.toString();*


Re: SPARQL query exception

2017-01-26 Thread javed khan
I am sorry Rob, I have posted this issue on Stack overflow yesterday, and I
thought I have posted the details here.
Sorry and the problem is solved as I used QuerySolution in while loop.

Thank you

On Thu, Jan 26, 2017 at 5:12 PM, Rob Vesse  wrote:

> Once again you have failed to provide a minimal complete example. This
> means the minimal code needed to reproduce the problem and any extra
> resources needed e.g. your data. Complete means that your code should be
> able to be copied and pasted and run.
>
> http://stackoverflow.com/help/mcve
>
> Note you haven’t actually told us what the problem is i.e. What is the
> specific error message you got. It gets an exception is not a problem
> statement!
>
>  We have been telling you this for weeks, if you are not actually going to
> make an effort then people are going to stop trying to help you
>
> Rob
>
> On 26/01/2017 13:06, "javed khan"  wrote:
>
> *The following query works *   :
>
> "SELECT  ?student ?highScore " +
>
>" WHERE {" + " {"+ "select  (max(?score) as
> ?highScore)"
> + " { ?student dd:Englishscore ?score" +
> " }" +
> "  } " +
> "?student dd:Englishscore ?highScore"   +
>
>
>   "}";
>
>  Query query2 = QueryFactory.create(queryString2);
> QueryExecution qexec = QueryExecutionFactory.create(query2, model2) ;
> ResultSet results2 = qexec.execSelect() ;
>
>   Literal r= results2.next().get("highScore").asLiteral();
>String ss= r.getLexicalForm();
>JOptionPane.showMessageDialog(null,"High score of Physics is"+s +
> "by
> Student");
>
> This query now works but when I include also the student name, it
> gives me
> exception again.
>
>  * Resource r2= results2.next().get("student").asResource();*
> *   String s=r2.toString();*
>
>
>
>
>
>


Re: SPARQL query exception

2017-01-26 Thread javed khan
Hello, this is the query. How can we add high score of another subject like
Mathsscore, I simply add Mathscore after Englishscore, but not working

"SELECT  *  +

   " WHERE {" + " {"+ "select  (max(?score) as ?highScore)"
+ " { ?student dd:Englishscore ?score" +  "  ?student2 dd:Mathsscore
?score2"
" }" +
"  } " +
"?student dd:Englishscore ?highScore"   + " ?student2
dd:Mathsscore ?score2"


  "}";

On Thu, Jan 26, 2017 at 6:13 PM, javed khan  wrote:

> I am sorry Rob, I have posted this issue on Stack overflow yesterday, and
> I thought I have posted the details here.
> Sorry and the problem is solved as I used QuerySolution in while loop.
>
> Thank you
>
> On Thu, Jan 26, 2017 at 5:12 PM, Rob Vesse  wrote:
>
>> Once again you have failed to provide a minimal complete example. This
>> means the minimal code needed to reproduce the problem and any extra
>> resources needed e.g. your data. Complete means that your code should be
>> able to be copied and pasted and run.
>>
>> http://stackoverflow.com/help/mcve
>>
>> Note you haven’t actually told us what the problem is i.e. What is the
>> specific error message you got. It gets an exception is not a problem
>> statement!
>>
>>  We have been telling you this for weeks, if you are not actually going
>> to make an effort then people are going to stop trying to help you
>>
>> Rob
>>
>> On 26/01/2017 13:06, "javed khan"  wrote:
>>
>> *The following query works *   :
>>
>> "SELECT  ?student ?highScore " +
>>
>>" WHERE {" + " {"+ "select  (max(?score) as
>> ?highScore)"
>> + " { ?student dd:Englishscore ?score" +
>> " }" +
>> "  } " +
>> "?student dd:Englishscore ?highScore"   +
>>
>>
>>   "}";
>>
>>  Query query2 = QueryFactory.create(queryString2);
>> QueryExecution qexec = QueryExecutionFactory.create(query2, model2) ;
>> ResultSet results2 = qexec.execSelect() ;
>>
>>   Literal r= results2.next().get("highScore").asLiteral();
>>String ss= r.getLexicalForm();
>>JOptionPane.showMessageDialog(null,"High score of Physics is"+s +
>> "by
>> Student");
>>
>> This query now works but when I include also the student name, it
>> gives me
>> exception again.
>>
>>  * Resource r2= results2.next().get("student").asResource();*
>> *   String s=r2.toString();*
>>
>>
>>
>>
>>
>>
>


Re: SPARQL query exception

2017-01-27 Thread javed khan
Sorry Lorenz I did not check stack overflow as the response there comes
very late. Therefore I prefer Jena mailing list because here the response
comes quickly.

It is the query in plain text: If I want to include another subject high
score and its student, then how can I add it?


SELECT ?student ?topScore WHERE {
  {

SELECT (MAX(?score) AS ?topScore) WHERE
{
  ?student dd:Englishscore ?score .
}

}
?student dd:Englishscore  ?topScore .

}

On Fri, Jan 27, 2017 at 1:04 PM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

> I tried to help you on StackOverflow, but no response from your side and
> you posted something that can't compile in Java.
>
> Moreover, and that's a really sad point, you posted a different query
> there, without the Mathscore triple patterns...
>
> Off-topic: It would be good if you close the question there if you found
> the solution, that's one of the expected behaviors on a platform like
> StackOverflow.
>
>
> More comments, your query asks for the top English score - your message
> tells the user that it's the top Physics score...
>
> And the exception is quite obvious, you called next() twice on a
> resultset which might only return one student with the highest score.
> > Hello, this is the query. How can we add high score of another subject
> like
> > Mathsscore, I simply add Mathscore after Englishscore, but not working
> >
> > "SELECT  *  +
> >
> >" WHERE {" + " {"+ "select  (max(?score) as
> ?highScore)"
> > + " { ?student dd:Englishscore ?score" +  "  ?student2 dd:Mathsscore
> > ?score2"
> > " }" +
> > "  } " +
> > "?student dd:Englishscore ?highScore"   + " ?student2
> > dd:Mathsscore ?score2"
> >
> >
> >   "}";
> >
> > On Thu, Jan 26, 2017 at 6:13 PM, javed khan 
> wrote:
> >
> >> I am sorry Rob, I have posted this issue on Stack overflow yesterday,
> and
> >> I thought I have posted the details here.
> >> Sorry and the problem is solved as I used QuerySolution in while loop.
> >>
> >> Thank you
> >>
> >> On Thu, Jan 26, 2017 at 5:12 PM, Rob Vesse 
> wrote:
> >>
> >>> Once again you have failed to provide a minimal complete example. This
> >>> means the minimal code needed to reproduce the problem and any extra
> >>> resources needed e.g. your data. Complete means that your code should
> be
> >>> able to be copied and pasted and run.
> >>>
> >>> http://stackoverflow.com/help/mcve
> >>>
> >>> Note you haven’t actually told us what the problem is i.e. What is the
> >>> specific error message you got. It gets an exception is not a problem
> >>> statement!
> >>>
> >>>  We have been telling you this for weeks, if you are not actually going
> >>> to make an effort then people are going to stop trying to help you
> >>>
> >>> Rob
> >>>
> >>> On 26/01/2017 13:06, "javed khan"  wrote:
> >>>
> >>> *The following query works *   :
> >>>
> >>> "SELECT  ?student ?highScore " +
> >>>
> >>>" WHERE {" + " {"+ "select  (max(?score) as
> >>> ?highScore)"
> >>> + " { ?student dd:Englishscore ?score" +
> >>> " }" +
> >>> "  } " +
> >>> "?student dd:Englishscore ?highScore"   +
> >>>
> >>>
> >>>   "}";
> >>>
> >>>  Query query2 = QueryFactory.create(queryString2);
> >>> QueryExecution qexec = QueryExecutionFactory.create(query2,
> model2) ;
> >>> ResultSet results2 = qexec.execSelect() ;
> >>>
> >>>   Literal r= results2.next().get("highScore").asLiteral();
> >>>String ss= r.getLexicalForm();
> >>>JOptionPane.showMessageDialog(null,"High score of Physics
> is"+s +
> >>> "by
> >>> Student");
> >>>
> >>> This query now works but when I include also the student name, it
> >>> gives me
> >>> exception again.
> >>>
> >>>  * Resource r2= results2.next().get("student").asResource();*
> >>> *   String s=r2.toString();*
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
>
>


Re: SPARQL query exception

2017-01-27 Thread javed khan
Thank you Lorenz, let me try it. In my situation, the important is high
score so even if is of multiple students, does not matter.

If I run the query for each subject, the QueryExecution and Resultset will
also be  separate or just two queries with same QueryExecution and
Resultset?

On Fri, Jan 27, 2017 at 2:33 PM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

> Don't make it more complicated as necessary. Simply run the query for
> each of your subjects. Otherwise something like
>
> SELECT ?subject ?student ?topScore WHERE {
>   {
>
> SELECT ?subject (MAX(?score) AS ?topScore) WHERE
> {  VALUES ?subject {dd:EnglishScore dd:MathScore}
>?student ?subject ?score .
> } GROUP BY ?subject
>   }
> ?student ?subject  ?topScore .
>
> }
>
> could work - it's untested
>
> Don't forget that there can be more than one student with the highest
> score per subject.
>
> > Sorry Lorenz I did not check stack overflow as the response there comes
> > very late. Therefore I prefer Jena mailing list because here the response
> > comes quickly.
> >
> > It is the query in plain text: If I want to include another subject high
> > score and its student, then how can I add it?
> >
> >
> > SELECT ?student ?topScore WHERE {
> >   {
> >
> > SELECT (MAX(?score) AS ?topScore) WHERE
> > {
> >   ?student dd:Englishscore ?score .
> > }
> >
> > }
> > ?student dd:Englishscore  ?topScore .
> >
> > }
> >
> > On Fri, Jan 27, 2017 at 1:04 PM, Lorenz B. <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >> I tried to help you on StackOverflow, but no response from your side and
> >> you posted something that can't compile in Java.
> >>
> >> Moreover, and that's a really sad point, you posted a different query
> >> there, without the Mathscore triple patterns...
> >>
> >> Off-topic: It would be good if you close the question there if you found
> >> the solution, that's one of the expected behaviors on a platform like
> >> StackOverflow.
> >>
> >>
> >> More comments, your query asks for the top English score - your message
> >> tells the user that it's the top Physics score...
> >>
> >> And the exception is quite obvious, you called next() twice on a
> >> resultset which might only return one student with the highest score.
> >>> Hello, this is the query. How can we add high score of another subject
> >> like
> >>> Mathsscore, I simply add Mathscore after Englishscore, but not working
> >>>
> >>> "SELECT  *  +
> >>>
> >>>" WHERE {" + " {"+ "select  (max(?score) as
> >> ?highScore)"
> >>> + " { ?student dd:Englishscore ?score" +  "  ?student2 dd:Mathsscore
> >>> ?score2"
> >>> " }" +
> >>> "  } " +
> >>> "?student dd:Englishscore ?highScore"   + " ?student2
> >>> dd:Mathsscore ?score2"
> >>>
> >>>
> >>>   "}";
> >>>
> >>> On Thu, Jan 26, 2017 at 6:13 PM, javed khan 
> >> wrote:
> >>>> I am sorry Rob, I have posted this issue on Stack overflow yesterday,
> >> and
> >>>> I thought I have posted the details here.
> >>>> Sorry and the problem is solved as I used QuerySolution in while loop.
> >>>>
> >>>> Thank you
> >>>>
> >>>> On Thu, Jan 26, 2017 at 5:12 PM, Rob Vesse 
> >> wrote:
> >>>>> Once again you have failed to provide a minimal complete example.
> This
> >>>>> means the minimal code needed to reproduce the problem and any extra
> >>>>> resources needed e.g. your data. Complete means that your code should
> >> be
> >>>>> able to be copied and pasted and run.
> >>>>>
> >>>>> http://stackoverflow.com/help/mcve
> >>>>>
> >>>>> Note you haven’t actually told us what the problem is i.e. What is
> the
> >>>>> specific error message you got. It gets an exception is not a problem
> >>>>> statement!
> >>>>>
> >>>>>  We have been telling you this for weeks, if you are not actually
> going
> >>>>> to make an effort then 

Adding data from UI to Protege

2017-01-30 Thread javed khan
Hi

I am not sure if this question is suitable in Jena list but I wonder if it
is possible to edit/add some contents from a Java application's user
interface and that changes/data saves directly in Protege and URIs assigned
to data?
Like we use the UI and saves data to a database. Not sure Jena or some
third party tools allows it or not?

My admin of system is end user which does not know about Protege and
Semantic web and I want him to enter data through some UI.

Regards


Re: Adding data from UI to Protege

2017-01-31 Thread javed khan
Hello Lorenz,
 change the file of the ontology that is loaded into Protege.

What does you mean by changing the ontology file? I want UI l that ask, for
example, Enter Student name and that is saved as data property then. Same
case for classes and instances.

On Tue, Jan 31, 2017 at 10:24 AM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

> The only way is to change the file of the ontology that is loaded into
> Protege. Protege will then recognize this and ask for reloading the
> ontology.
> Everything beyond is only possible if you write a Protege plugin
>
> > Hi
> >
> > I am not sure if this question is suitable in Jena list but I wonder if
> it
> > is possible to edit/add some contents from a Java application's user
> > interface and that changes/data saves directly in Protege and URIs
> assigned
> > to data?
> > Like we use the UI and saves data to a database. Not sure Jena or some
> > third party tools allows it or not?
> >
> > My admin of system is end user which does not know about Protege and
> > Semantic web and I want him to enter data through some UI.
> >
> > Regards
> >
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
>


Re: Adding data from UI to Protege

2017-01-31 Thread javed khan
Ok yes I got this. But how it fits with my requirements of entering data to
owl file using a UI?

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

> Javed,
>
> you're working on an ontology. If you change the data and save it to the
> same file, the file has been changed.
>
> > Hello Lorenz,
> >  change the file of the ontology that is loaded into Protege.
> >
> > What does you mean by changing the ontology file? I want UI l that ask,
> for
> > example, Enter Student name and that is saved as data property then. Same
> > case for classes and instances.
> >
> > On Tue, Jan 31, 2017 at 10:24 AM, Lorenz B. <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >> The only way is to change the file of the ontology that is loaded into
> >> Protege. Protege will then recognize this and ask for reloading the
> >> ontology.
> >> Everything beyond is only possible if you write a Protege plugin
> >>
> >>> Hi
> >>>
> >>> I am not sure if this question is suitable in Jena list but I wonder if
> >> it
> >>> is possible to edit/add some contents from a Java application's user
> >>> interface and that changes/data saves directly in Protege and URIs
> >> assigned
> >>> to data?
> >>> Like we use the UI and saves data to a database. Not sure Jena or some
> >>> third party tools allows it or not?
> >>>
> >>> My admin of system is end user which does not know about Protege and
> >>> Semantic web and I want him to enter data through some UI.
> >>>
> >>> 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
>
>


Re: Adding data from UI to Protege

2017-01-31 Thread javed khan
Hi Lorenz, yes I have Java application and at back-end owl file. Just like
in traditional database applications, an admin make changes to database
through a UI (web form) and that changes are saves in database.
Can we do like this if the admin enter data or edit data in Java UI and it
stores in our owl file?

On Tue, Jan 31, 2017 at 2:40 PM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

> I don't understand the question. A UI has some backend resp. application
> logic in which you change thedata
>
> > Ok yes I got this. But how it fits with my requirements of entering data
> to
> > owl file using a UI?
> >
> > On Tue, Jan 31, 2017 at 1:10 PM, Lorenz B. <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >> Javed,
> >>
> >> you're working on an ontology. If you change the data and save it to the
> >> same file, the file has been changed.
> >>
> >>> Hello Lorenz,
> >>>  change the file of the ontology that is loaded into Protege.
> >>>
> >>> What does you mean by changing the ontology file? I want UI l that ask,
> >> for
> >>> example, Enter Student name and that is saved as data property then.
> Same
> >>> case for classes and instances.
> >>>
> >>> On Tue, Jan 31, 2017 at 10:24 AM, Lorenz B. <
> >>> buehm...@informatik.uni-leipzig.de> wrote:
> >>>
>  The only way is to change the file of the ontology that is loaded into
>  Protege. Protege will then recognize this and ask for reloading the
>  ontology.
>  Everything beyond is only possible if you write a Protege plugin
> 
> > Hi
> >
> > I am not sure if this question is suitable in Jena list but I wonder
> if
>  it
> > is possible to edit/add some contents from a Java application's user
> > interface and that changes/data saves directly in Protege and URIs
>  assigned
> > to data?
> > Like we use the UI and saves data to a database. Not sure Jena or
> some
> > third party tools allows it or not?
> >
> > My admin of system is end user which does not know about Protege and
> > Semantic web and I want him to enter data through some UI.
> >
> > 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: Adding data from UI to Protege

2017-01-31 Thread javed khan
Hi Rob, so it means we have java Swing application and from swing UI we can
edit data into our owl file. Of course we will have Jena to connect our
application with the ontology.
But is there any plugin needed to edit data from UI?

On Tue, Jan 31, 2017 at 5:06 PM, Rob Vesse  wrote:

> Yes you can do this but it is fundamentally an implementation decision
> that has nothing to do with Jena. You are a programmer and you actually
> have to write some code of your own, libraries like Jena will only do so
> much for you.
>
> Jena is not a UI library, of course you can use it behind-the-scenes to
> store and retrieve data but you need to provide an appropriateUI for your
> application
>
> On 31/01/2017 13:59, "javed khan"  wrote:
>
> Hi Lorenz, yes I have Java application and at back-end owl file. Just
> like
> in traditional database applications, an admin make changes to database
> through a UI (web form) and that changes are saves in database.
> Can we do like this if the admin enter data or edit data in Java UI
> and it
> stores in our owl file?
>
> On Tue, Jan 31, 2017 at 2:40 PM, Lorenz B. <
> buehm...@informatik.uni-leipzig.de> wrote:
>
> > I don't understand the question. A UI has some backend resp.
> application
> > logic in which you change thedata
> >
> > > Ok yes I got this. But how it fits with my requirements of
> entering data
> > to
> > > owl file using a UI?
> > >
> > > On Tue, Jan 31, 2017 at 1:10 PM, Lorenz B. <
> > > buehm...@informatik.uni-leipzig.de> wrote:
> > >
> > >> Javed,
> > >>
> > >> you're working on an ontology. If you change the data and save it
> to the
> > >> same file, the file has been changed.
> > >>
> > >>> Hello Lorenz,
> > >>>  change the file of the ontology that is loaded into Protege.
> > >>>
> > >>> What does you mean by changing the ontology file? I want UI l
> that ask,
> > >> for
> > >>> example, Enter Student name and that is saved as data property
> then.
> > Same
> > >>> case for classes and instances.
> > >>>
> > >>> On Tue, Jan 31, 2017 at 10:24 AM, Lorenz B. <
> > >>> buehm...@informatik.uni-leipzig.de> wrote:
> > >>>
> > >>>> The only way is to change the file of the ontology that is
> loaded into
> > >>>> Protege. Protege will then recognize this and ask for reloading
> the
> > >>>> ontology.
> > >>>> Everything beyond is only possible if you write a Protege plugin
> > >>>>
> > >>>>> Hi
> > >>>>>
> > >>>>> I am not sure if this question is suitable in Jena list but I
> wonder
> > if
> > >>>> it
> > >>>>> is possible to edit/add some contents from a Java
> application's user
> > >>>>> interface and that changes/data saves directly in Protege and
> URIs
> > >>>> assigned
> > >>>>> to data?
> > >>>>> Like we use the UI and saves data to a database. Not sure Jena
> or
> > some
> > >>>>> third party tools allows it or not?
> > >>>>>
> > >>>>> My admin of system is end user which does not know about
> Protege and
> > >>>>> Semantic web and I want him to enter data through some UI.
> > >>>>>
> > >>>>> 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: Adding data from UI to Protege

2017-01-31 Thread javed khan
Thank you Lorenz, I got it now, it means it works the same way we store
data in databases from UI.
 Some one told me you have to create or use a plugin for it.

On Tue, Jan 31, 2017 at 5:22 PM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

> Ehm, what is the question now here? You can do anything in a Swing
> application, I mean you simply call any Jena API method or what else do
> you do when a e.g. a button is clicked. I don't understand what's so
> complicated here.
>
>
> On 31.01.2017 15:12, javed khan wrote:
> > Hi Rob, so it means we have java Swing application and from swing UI we
> can
> > edit data into our owl file. Of course we will have Jena to connect our
> > application with the ontology.
> > But is there any plugin needed to edit data from UI?
> >
> > On Tue, Jan 31, 2017 at 5:06 PM, Rob Vesse  wrote:
> >
> >> Yes you can do this but it is fundamentally an implementation decision
> >> that has nothing to do with Jena. You are a programmer and you actually
> >> have to write some code of your own, libraries like Jena will only do so
> >> much for you.
> >>
> >> Jena is not a UI library, of course you can use it behind-the-scenes to
> >> store and retrieve data but you need to provide an appropriateUI for
> your
> >> application
> >>
> >> On 31/01/2017 13:59, "javed khan"  wrote:
> >>
> >> Hi Lorenz, yes I have Java application and at back-end owl file.
> Just
> >> like
> >> in traditional database applications, an admin make changes to
> database
> >> through a UI (web form) and that changes are saves in database.
> >> Can we do like this if the admin enter data or edit data in Java UI
> >> and it
> >> stores in our owl file?
> >>
> >> On Tue, Jan 31, 2017 at 2:40 PM, Lorenz B. <
> >> buehm...@informatik.uni-leipzig.de> wrote:
> >>
> >> > I don't understand the question. A UI has some backend resp.
> >> application
> >> > logic in which you change thedata
> >> >
> >> > > Ok yes I got this. But how it fits with my requirements of
> >> entering data
> >> > to
> >> > > owl file using a UI?
> >> > >
> >> > > On Tue, Jan 31, 2017 at 1:10 PM, Lorenz B. <
> >> > > buehm...@informatik.uni-leipzig.de> wrote:
> >> > >
> >> > >> Javed,
> >> > >>
> >> > >> you're working on an ontology. If you change the data and save
> it
> >> to the
> >> > >> same file, the file has been changed.
> >> > >>
> >> > >>> Hello Lorenz,
> >> > >>>  change the file of the ontology that is loaded into Protege.
> >> > >>>
> >> > >>> What does you mean by changing the ontology file? I want UI l
> >> that ask,
> >> > >> for
> >> > >>> example, Enter Student name and that is saved as data property
> >> then.
> >> > Same
> >> > >>> case for classes and instances.
> >> > >>>
> >> > >>> On Tue, Jan 31, 2017 at 10:24 AM, Lorenz B. <
> >> > >>> buehm...@informatik.uni-leipzig.de> wrote:
> >> > >>>
> >> > >>>> The only way is to change the file of the ontology that is
> >> loaded into
> >> > >>>> Protege. Protege will then recognize this and ask for
> reloading
> >> the
> >> > >>>> ontology.
> >> > >>>> Everything beyond is only possible if you write a Protege
> plugin
> >> > >>>>
> >> > >>>>> Hi
> >> > >>>>>
> >> > >>>>> I am not sure if this question is suitable in Jena list but
> I
> >> wonder
> >> > if
> >> > >>>> it
> >> > >>>>> is possible to edit/add some contents from a Java
> >> application's user
> >> > >>>>> interface and that changes/data saves directly in Protege
> and
> >> URIs
> >> > >>>> assigned
> >> > >>>>> to data?
> >> > >>>>> Like we use the UI and saves data to a database. Not sure
> Jena
> >> or
> >> > some
> >> > >>>>> third party tools allows it or not?
> >> > >>>>>
> >> > >>>>> My admin of system is end user which does not know about
> >> Protege and
> >> > >>>>> Semantic web and I want him to enter data through some UI.
> >> > >>>>>
> >> > >>>>> 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
> >> >
> >> >
> >>
> >>
> >>
> >>
> >>
> >>
>
>


Wiki data

2017-03-02 Thread javed khan
Is Jena support wikidata the same way as it support DBpedia? For example,
we store DBpedia resources in our owl file and then access it from our Jena
code. Any example, if some one provide how to access a wikidata using Jena
code?

Thank you.


Re: Wiki data

2017-03-02 Thread javed khan
Can we add wikidata in Protege like we do in DBpedia. Not sure if Protege
and Jena allow us to use both wikidata and DBpedia in one application.?

On Thu, Mar 2, 2017 at 3:42 PM, Marco Neumann 
wrote:

> since wikidata.org provides canonical RDF dumps the data should behave
> like any other data set. not particularly relevant to this list
> though.
>
> https://www.wikidata.org/wiki/Wikidata:Database_download#RDF_dumps
>
>
>
> On Thu, Mar 2, 2017 at 7:35 AM, javed khan  wrote:
> > Is Jena support wikidata the same way as it support DBpedia? For example,
> > we store DBpedia resources in our owl file and then access it from our
> Jena
> > code. Any example, if some one provide how to access a wikidata using
> Jena
> > code?
> >
> > Thank you.
>
>
>
> --
>
>
> ---
> Marco Neumann
> KONA
>


Re: Wiki data

2017-03-03 Thread javed khan
Thank you Lorenz,

On Fri, Mar 3, 2017 at 10:02 AM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

> The question is strange.
>
> Wikidata provides RDF data, also accessible via SPARQL.
> DBpedia provides RDF data, also accessible via SPARQL.
>
> In addition, both provide schema information via OWL/RDFS axioms, e.g.
> domain , range, subclass hierarchy etc.
>
> Protege can load any such data.
>
> The rest should be clear: It is the same as you did for DBpedia.
>
>
>
> > Can we add wikidata in Protege like we do in DBpedia. Not sure if Protege
> > and Jena allow us to use both wikidata and DBpedia in one application.?
> >
> > On Thu, Mar 2, 2017 at 3:42 PM, Marco Neumann 
> > wrote:
> >
> >> since wikidata.org provides canonical RDF dumps the data should behave
> >> like any other data set. not particularly relevant to this list
> >> though.
> >>
> >> https://www.wikidata.org/wiki/Wikidata:Database_download#RDF_dumps
> >>
> >>
> >>
> >> On Thu, Mar 2, 2017 at 7:35 AM, javed khan 
> wrote:
> >>> Is Jena support wikidata the same way as it support DBpedia? For
> example,
> >>> we store DBpedia resources in our owl file and then access it from our
> >> Jena
> >>> code. Any example, if some one provide how to access a wikidata using
> >> Jena
> >>> code?
> >>>
> >>> Thank you.
> >>
> >>
> >> --
> >>
> >>
> >> ---
> >> Marco Neumann
> >> KONA
> >>
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
>


Why we need Fuseki

2017-04-03 Thread javed khan
Hi

Why we need fuseki server in semantic web applications. We can run SPARQL
queries without it, like we do using Jena syntax.


Re: Why we need Fuseki

2017-04-03 Thread javed khan
Thank you Lorenz, I have read that website but unfortunately did not get
the concept. Let me try to read it again.



On Mon, Apr 3, 2017 at 4:35 PM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

> Javed ...
>
> I'll simply cite the "slogan" from the web page [1] and recommend to
> read [2]
>
> "Fuseki: serving RDF data over HTTP"
>
>
>
> [1] https://jena.apache.org/documentation/serving_data/
>
> [2] https://jena.apache.org/documentation/fuseki2/
>
>
> On 03.04.2017 14:54, javed khan wrote:
> > Hi
> >
> > Why we need fuseki server in semantic web applications. We can run SPARQL
> > queries without it, like we do using Jena syntax.
> >
>
>


RDF API or Jena rule

2017-04-16 Thread javed khan
Is there any advantage of Jena rule (speed etc) over RDF API? For example,
a functionality in our application we achieve using rule and RDF, which way
will be best to follow?

I am asking this because in my application I have used few rules but I
could easily got the same result using RDF API.

Thank you


Re: RDF API or Jena rule

2017-04-16 Thread javed khan
Thank you,

And what is SPIN then? Is it the combination of Jena and SPARQL? If it is,
then it would be better than Jena, for sure? But it is still Jena which are
using in most of semantic web applications.

On Sun, Apr 16, 2017 at 3:06 PM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

> Right. Both are totally different things. And obviously, you can't do
> everything with Java. On the other hand, somebody, e.g. a domain expert
> might be able to declare a rule that infers data without touching any
> Java code.
> > I think you are confused. Rules are for inference, RDF API is for
> > manipulating RDF from Java. They are orthogonal.
> >
> > On Sun, Apr 16, 2017 at 1:01 PM, javed khan 
> wrote:
> >> Is there any advantage of Jena rule (speed etc) over RDF API? For
> example,
> >> a functionality in our application we achieve using rule and RDF, which
> way
> >> will be best to follow?
> >>
> >> I am asking this because in my application I have used few rules but I
> >> could easily got the same result using RDF API.
> >>
> >> Thank you
>
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
>


Materialize query

2017-04-25 Thread javed khan
Hello

What is materialized SPARQL queries and how it differs from other queries?

Regards


Re: Materialize query

2017-04-26 Thread javed khan
Lorenz, I have seen it in a statement like " Materialize queries are used
to reduce the number of necessary joins and processing time".

On Wed, Apr 26, 2017 at 8:52 AM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

> Please understand that the term "materialised SPARQL queries" is not a
> common one, thus, probably nobody will be able to answer your question.
>
> So let me ask you, WHAT is a materialised SPARQL query and WHERE have
> you see this expression?
>
> > Hello
> >
> > What is materialized SPARQL queries and how it differs from other
> queries?
> >
> > Regards
> >
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
>


Access Freebase resources

2017-05-13 Thread javed khan
Hi

How can I access a resource, say "Calgary" in Freebase dataset using Jena
code? Need guidance, like how to make connection with the dataset first and
then access resources?

Thank you


Re: Access Freebase resources

2017-05-15 Thread javed khan
load the dataset and work on that

Lorenz, can we annotate it inside Protege like we do DBpedia and then use
it in Jena?

On Mon, May 15, 2017 at 11:34 AM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

> Given that the dataset is available as RDF:
>
> a) use the SPARQL service if there is any or
> b) load the dataset and work on that
>
> > Hi
> >
> > How can I access a resource, say "Calgary" in Freebase dataset using Jena
> > code? Need guidance, like how to make connection with the dataset first
> and
> > then access resources?
> >
> > Thank you
> >
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
>


Re: Access Freebase resources

2017-05-15 Thread javed khan
Hi Lorenz, I have just given links/URI to the DBpedia resource inside
Protege.

On Mon, May 15, 2017 at 12:12 PM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

> Annotate what?
>
> And how do you use DBpedia in Protege? It's an in-memory ontology editor.
>
> > load the dataset and work on that
> >
> > Lorenz, can we annotate it inside Protege like we do DBpedia and then use
> > it in Jena?
> >
> > On Mon, May 15, 2017 at 11:34 AM, Lorenz B. <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >> Given that the dataset is available as RDF:
> >>
> >> a) use the SPARQL service if there is any or
> >> b) load the dataset and work on that
> >>
> >>> Hi
> >>>
> >>> How can I access a resource, say "Calgary" in Freebase dataset using
> Jena
> >>> code? Need guidance, like how to make connection with the dataset first
> >> and
> >>> then access resources?
> >>>
> >>> Thank you
> >>>
> >> --
> >> 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: Access Freebase resources

2017-05-16 Thread javed khan
Hi Lorenz, since we use in Protege something like:
dbpedia.org/resource/calgary, can we use it for Freebase data source?

On Tue, May 16, 2017 at 8:52 AM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

> I do not understand, sorry. Can you clarify what data you have? And
> also, what you're trying to achieve in general.
>
> > Hi Lorenz, I have just given links/URI to the DBpedia resource inside
> > Protege.
> >
> > On Mon, May 15, 2017 at 12:12 PM, Lorenz B. <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >> Annotate what?
> >>
> >> And how do you use DBpedia in Protege? It's an in-memory ontology
> editor.
> >>
> >>> load the dataset and work on that
> >>>
> >>> Lorenz, can we annotate it inside Protege like we do DBpedia and then
> use
> >>> it in Jena?
> >>>
> >>> On Mon, May 15, 2017 at 11:34 AM, Lorenz B. <
> >>> buehm...@informatik.uni-leipzig.de> wrote:
> >>>
>  Given that the dataset is available as RDF:
> 
>  a) use the SPARQL service if there is any or
>  b) load the dataset and work on that
> 
> > Hi
> >
> > How can I access a resource, say "Calgary" in Freebase dataset using
> >> Jena
> > code? Need guidance, like how to make connection with the dataset
> first
>  and
> > then access resources?
> >
> > Thank you
> >
>  --
>  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: Access Freebase resources

2017-05-16 Thread javed khan
Thank you Lorenz, This is what I was asking.

On Tue, May 16, 2017 at 12:43 PM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

> This is still **not** helpful. What means we use? You refer to this
> DBpedia entity in your local ontology? If yes, I don't see why you
> shouldn't be able to do this with the data in  Freebase as well. You can
> do it with any resource.
>
> > Hi Lorenz, since we use in Protege something like:
> > dbpedia.org/resource/calgary, can we use it for Freebase data source?
> >
> > On Tue, May 16, 2017 at 8:52 AM, Lorenz B. <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >> I do not understand, sorry. Can you clarify what data you have? And
> >> also, what you're trying to achieve in general.
> >>
> >>> Hi Lorenz, I have just given links/URI to the DBpedia resource inside
> >>> Protege.
> >>>
> >>> On Mon, May 15, 2017 at 12:12 PM, Lorenz B. <
> >>> buehm...@informatik.uni-leipzig.de> wrote:
> >>>
>  Annotate what?
> 
>  And how do you use DBpedia in Protege? It's an in-memory ontology
> >> editor.
> > load the dataset and work on that
> >
> > Lorenz, can we annotate it inside Protege like we do DBpedia and then
> >> use
> > it in Jena?
> >
> > On Mon, May 15, 2017 at 11:34 AM, Lorenz B. <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >> Given that the dataset is available as RDF:
> >>
> >> a) use the SPARQL service if there is any or
> >> b) load the dataset and work on that
> >>
> >>> Hi
> >>>
> >>> How can I access a resource, say "Calgary" in Freebase dataset
> using
>  Jena
> >>> code? Need guidance, like how to make connection with the dataset
> >> first
> >> and
> >>> then access resources?
> >>>
> >>> Thank you
> >>>
> >> --
> >> 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
>
>


rules (non monotonic)

2017-07-24 Thread javed khan
If we have a rule which says:

If a player has less than 10 goals, he is average player and if the goals
exceed 10, he is a star player . Player A is first an average player but
later when his goals cross the digit 10, he is a star player but the
problem is it still shows the the player in average class.

I know rules are non monotonic, but is there any way in which we can (in
one way or other) replace the old data with existing when the rule fires?
If there is no way, it means we should not use rules but a simple if/then
rules?

Thank you.


  1   2   >