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: 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
> >
>
>


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: 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
>>>>
>>>>
>>>>
>>


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
>>
>>


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: 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 <a...@apache.org> 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
>


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 <aj...@apache.org> 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 <javedbtk...@gmail.com> 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:

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 <javedbtk...@gmail.com>
> >>  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
> >>
> >>
> >>
> >>
>
>


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: Repetition of Subject in SPARQL query

2018-05-10 Thread javed khan
If you can see the image, the output is shown as:

The STUDY 1: used SVM, Partly, RQ7
 used SVM, Partly, RQ6
 used SVM, Partly, RQ5

For different RQs the SVM and Partly is also repeated.

The SPARQL query I used is as:

*SELECT * *

*  WHERE { ?x mo:hasRQ ?rq.*

*   ?x mo:hasTitle ?t.   ?x mo:Q.Assess ?ass. ?x mo:hasML ?ml.*

*  ?x mo:hasDataset ?ds. ?x mo:hasAccuracyMeasure ?acc*

*   FILTER (rejex(str(?t),'+title+', 'i' )) .*

variabe title in last line is a java variable.




On Tue, May 8, 2018 at 5:16 PM, ajs6f <aj...@apache.org> wrote:

> SPARQL normally produces tabular results. What you are showing doesn't fit
> into any obvious SPARQL results form.
>
> Please show data, code, expected result and actual result.
>
> https://stackoverflow.com/help/mcve
>
> ajs6f
>
> > On May 8, 2018, at 8:24 AM, javed khan <javedbtk...@gmail.com> wrote:
> >
> > Hello
> >
> > I have a SPARQL query which results a particular study (article) uses
> > Decision Tree model and NASA, Maxwell, COCOMO datasets.The answer it
> shows
> > like for Study 1:
> >
> > Decision TreeNASA
> > Decision TreeMaxwell
> > Decision TreeCOCOMO
> >
> > While I need like this:
> >
> > Decision Tree  NASA
> >Maxwell
> >COCOMO
> >
> >
> > The subject should not be repeated,kindly if some one could guide?
> >
> > Regards
>
>


Repetition of Subject in SPARQL query

2018-05-08 Thread javed khan
Hello

I have a SPARQL query which results a particular study (article) uses
Decision Tree model and NASA, Maxwell, COCOMO datasets.The answer it shows
like for Study 1:

Decision TreeNASA
Decision TreeMaxwell
Decision TreeCOCOMO

While I need like this:

Decision Tree  NASA
Maxwell
COCOMO


The subject should not be repeated,kindly if some one could guide?

Regards


Re: How to show String value without Datatype

2018-04-15 Thread javed khan
Thanks a lot ajs6f

I used  Literal::getLexicalForm and it works.

Regards

On Sun, Apr 15, 2018 at 6:44 PM, ajs6f <aj...@apache.org> wrote:

> Please show your code and some data. It's not clear from what you wrote
> below what your data is or how you are manipulating it.
>
> https://stackoverflow.com/help/mcve
>
> Both the API type Literal and the SPI type Node have methods for
> retrieving the lexical form of a literal, Literal::getLexicalForm and
> Node::getLiteralLexicalForm.
>
>
> ajs6f
>
> > On Apr 15, 2018, at 11:33 AM, javed khan <javedbtk...@gmail.com> wrote:
> >
> > I want to extract two string values but without datatype. My result need
> to
> > be
> >
> > S2  ML Model: SVM
> >
> > Currently I am getting like below output.
> >
> > S2^^http://www.w3.org/2001/XMLSchema#string ML Model:   SVM^^
> > http://www.w3.org/2001/XMLSchema#string
> https://stackoverflow.com/help/mcve


How to show String value without Datatype

2018-04-15 Thread javed khan
I want to extract two string values but without datatype. My result need to
be

S2  ML Model: SVM

Currently I am getting like below output.

S2^^http://www.w3.org/2001/XMLSchema#string ML Model:   SVM^^
http://www.w3.org/2001/XMLSchema#string


Re: Rules and machine learning

2018-01-23 Thread javed khan
Thank you Lorenz.

And sorry for the off-topic query.



<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail_term=icon>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail_term=link>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Tue, Jan 23, 2018 at 10:59 AM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

> > The
> > following is a paper which used "inconsistency detection" but not used
> ML.
> I know the authors and the paper. Your statement is not correct, in fact
> they used machine learning to find new schema axioms to be added the
> DBpedia ontology, in particular disjointness axioms which are quite
> often a "good" source for inconsistency.
>
> There are also other groups that already used machine learning to
> "replace" standard reasoning procedures.
>
> But again, it's too much off-topic here.
>
>
> On 22.01.2018 17:56, javed khan wrote:
> > Martin, thanks a lot. Its very useful for me..
> >
> > I think it will be possible also to predict inconsistencies in ontologies
> > (via machine learning). It could be my research project which is about to
> > start but the problem is I cant find anything related on the web. The
> > following is a paper which used "inconsistency detection" but not used
> ML.
> >
> > [1]
> > https://hpi.de/fileadmin/user_upload/fachgebiete/meinel/
> papers/Web_3.0/2012_Toepper_ISEM.pdf
> >
> >
> >
> > <https://www.avast.com/sig-email?utm_medium=email_
> source=link_campaign=sig-email_content=webmail_term=icon>
> > Virus-free.
> > www.avast.com
> > <https://www.avast.com/sig-email?utm_medium=email_
> source=link_campaign=sig-email_content=webmail_term=link>
> > <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> >
> > On Mon, Jan 22, 2018 at 6:52 PM, Martin Vachovski <
> > martin.vachov...@skytek.com> wrote:
> >
> >> Hi all,
> >>
> >> I have seen some papers on "ontology matching"
> >> which is to say- apply a ML algorithm in order to "map"
> >> the semantics of two different ontologies which apply to the same object
> >>
> >> https://homes.cs.washington.edu/~pedrod/papers/hois.pdf
> >> http://disi.unitn.it/~p2p/RelatedWork/Matching/0411csit10.pdf
> >>
> >> While the examples are not exactly the ones seek by the question, they
> >> show that the idea of combining of ML and semantic data storage is not
> new
> >> Hope that points towards the right direction
> >>
> >> Cheers
> >> Martin
> >>
> >>
> >> 
> >> From: javed khan <javedbtk...@gmail.com>
> >> Sent: Monday, January 22, 2018 3:12 PM
> >> To: users@jena.apache.org
> >> Subject: Re: Rules and machine learning
> >>
> >> Thank you Lorenz.. Yes rules can not be consider machine learning as
> its a
> >> kind of hard coding and machine will not learn by itself..
> >>
> >>
> >>
> >> <https://www.avast.com/sig-email?utm_medium=email_
> >> source=link_campaign=sig-email_content=webmail_term=icon>
> >> Virus-free.
> >> www.avast.com
> >> <https://www.avast.com/sig-email?utm_medium=email_
> >> source=link_campaign=sig-email_content=webmail_term=link>
> >> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> >>
> >> On Mon, Jan 22, 2018 at 7:35 AM, Lorenz Buehmann <
> >> buehm...@informatik.uni-leipzig.de> wrote:
> >>
> >>> I've just some very minimal experience in machine learning and rule
> >>> processing...
> >>>
> >>> The important keywords here are "machine" and "learning" - if you
> >>> provide a set of rules, then there was no learning. Except by the human
> >>> who used his/her knowledge to make the rules - if it's done by a
> >>> "machine", then you can call this machine learning of such rules (e.g.
> >>> rule induction) and use the rules to "infer" data - not predict. The
> >>> rules are just a (human-readable) way to encode the machine learning
> >> model.
> >>> But, it's off-topic for sure, thus, I will not go further into details.
> >>>
> >>>
> >>> Lorenz
> >>>
> >>>
> >>> On 21.01.2018 14:50, javed khan wrote:
> >>>> Hello
> >>>>
> >

Re: Rules and machine learning

2018-01-22 Thread javed khan
Martin, thanks a lot. Its very useful for me..

I think it will be possible also to predict inconsistencies in ontologies
(via machine learning). It could be my research project which is about to
start but the problem is I cant find anything related on the web. The
following is a paper which used "inconsistency detection" but not used ML.

[1]
https://hpi.de/fileadmin/user_upload/fachgebiete/meinel/papers/Web_3.0/2012_Toepper_ISEM.pdf



<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail_term=icon>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail_term=link>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Mon, Jan 22, 2018 at 6:52 PM, Martin Vachovski <
martin.vachov...@skytek.com> wrote:

> Hi all,
>
> I have seen some papers on "ontology matching"
> which is to say- apply a ML algorithm in order to "map"
> the semantics of two different ontologies which apply to the same object
>
> https://homes.cs.washington.edu/~pedrod/papers/hois.pdf
> http://disi.unitn.it/~p2p/RelatedWork/Matching/0411csit10.pdf
>
> While the examples are not exactly the ones seek by the question, they
> show that the idea of combining of ML and semantic data storage is not new
> Hope that points towards the right direction
>
> Cheers
> Martin
>
>
> 
> From: javed khan <javedbtk...@gmail.com>
> Sent: Monday, January 22, 2018 3:12 PM
> To: users@jena.apache.org
> Subject: Re: Rules and machine learning
>
> Thank you Lorenz.. Yes rules can not be consider machine learning as its a
> kind of hard coding and machine will not learn by itself..
>
>
>
> <https://www.avast.com/sig-email?utm_medium=email_
> source=link_campaign=sig-email_content=webmail_term=icon>
> Virus-free.
> www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email_
> source=link_campaign=sig-email_content=webmail_term=link>
> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> On Mon, Jan 22, 2018 at 7:35 AM, Lorenz Buehmann <
> buehm...@informatik.uni-leipzig.de> wrote:
>
> > I've just some very minimal experience in machine learning and rule
> > processing...
> >
> > The important keywords here are "machine" and "learning" - if you
> > provide a set of rules, then there was no learning. Except by the human
> > who used his/her knowledge to make the rules - if it's done by a
> > "machine", then you can call this machine learning of such rules (e.g.
> > rule induction) and use the rules to "infer" data - not predict. The
> > rules are just a (human-readable) way to encode the machine learning
> model.
> >
> > But, it's off-topic for sure, thus, I will not go further into details.
> >
> >
> > Lorenz
> >
> >
> > On 21.01.2018 14:50, javed khan wrote:
> > > Hello
> > >
> > > I am not sure if the question is related to the jena group but I will
> > > appreciate the answer.
> > >
> > > I want to ask is it possible we take the functionality of machine
> > learning
> > > techniques (bayes algorithm, decision tree etc) using semantic web
> > rules. I
> > > dont know much about machine learning but I know it makes prediction
> > based
> > > on past experience/past data.
> > >
> > > Like we provide set of rules based on past data (if this, then that)
> and
> > > make predictions/optimizations. For instance, we want to make bug
> > > predictions in a software using Semantic rules, so is it possible??
> > >
> > > Thank you
> > >
> > > <https://www.avast.com/sig-email?utm_medium=email_
> > source=link_campaign=sig-email_content=webmail_term=icon>
> > > Virus-free.
> > > www.avast.com
> > > <https://www.avast.com/sig-email?utm_medium=email_
> > source=link_campaign=sig-email_content=webmail_term=link>
> > > <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> > >
> >
> >
> >
>


Inconsistency in Ontologies

2018-01-22 Thread javed khan
Hello

What are the possible examples (chances) of inconsistencies in ontologies?
Like one I know is if we take same instance of classes that are disjoint.

Also what (chances of) inconsistencies arises when data is extracted from
Wikipedia infoboxes via Dbpedia?

Thank you


Virus-free.
www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>


Re: Rules and machine learning

2018-01-22 Thread javed khan
Thank you Lorenz.. Yes rules can not be consider machine learning as its a
kind of hard coding and machine will not learn by itself..



<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail_term=icon>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail_term=link>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Mon, Jan 22, 2018 at 7:35 AM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

> I've just some very minimal experience in machine learning and rule
> processing...
>
> The important keywords here are "machine" and "learning" - if you
> provide a set of rules, then there was no learning. Except by the human
> who used his/her knowledge to make the rules - if it's done by a
> "machine", then you can call this machine learning of such rules (e.g.
> rule induction) and use the rules to "infer" data - not predict. The
> rules are just a (human-readable) way to encode the machine learning model.
>
> But, it's off-topic for sure, thus, I will not go further into details.
>
>
> Lorenz
>
>
> On 21.01.2018 14:50, javed khan wrote:
> > Hello
> >
> > I am not sure if the question is related to the jena group but I will
> > appreciate the answer.
> >
> > I want to ask is it possible we take the functionality of machine
> learning
> > techniques (bayes algorithm, decision tree etc) using semantic web
> rules. I
> > dont know much about machine learning but I know it makes prediction
> based
> > on past experience/past data.
> >
> > Like we provide set of rules based on past data (if this, then that) and
> > make predictions/optimizations. For instance, we want to make bug
> > predictions in a software using Semantic rules, so is it possible??
> >
> > Thank you
> >
> > <https://www.avast.com/sig-email?utm_medium=email_
> source=link_campaign=sig-email_content=webmail_term=icon>
> > Virus-free.
> > www.avast.com
> > <https://www.avast.com/sig-email?utm_medium=email_
> source=link_campaign=sig-email_content=webmail_term=link>
> > <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> >
>
>
>


Rules and machine learning

2018-01-21 Thread javed khan
Hello

I am not sure if the question is related to the jena group but I will
appreciate the answer.

I want to ask is it possible we take the functionality of machine learning
techniques (bayes algorithm, decision tree etc) using semantic web rules. I
dont know much about machine learning but I know it makes prediction based
on past experience/past data.

Like we provide set of rules based on past data (if this, then that) and
make predictions/optimizations. For instance, we want to make bug
predictions in a software using Semantic rules, so is it possible??

Thank you


Virus-free.
www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>


Re: How to to access Dbpedia resource using variable

2017-10-19 Thread javed khan
Thank you Lorenz

I am done with the quiz project but I am just working on its second
version.

Regards

<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail_term=icon>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail_term=link>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Thu, Oct 19, 2017 at 2:29 PM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

>
>
> On 19.10.2017 11:34, javed khan wrote:
> > Hello Lorenz, I knew I will not be able to explain my point.
> >
> > I have one class: Question  (What is capital city of Germany)
> > Another class : Answer (Berlin)
> > and similar question/answers instances.
> Are you still working on the quiz project? Have you seen that there is
> already related work?
> >
> > I want to show rdfs:comment of answers like Berlin,Madrid and it works
> >
> > So when I mentioned ?x  rdfs:comment  ?comment, the ?x contains Answers
> > like Berlin, Madrid
> >
> > After this query if I want to show the rdfs:abstract of Answers (Berlin
> > etc) from Dbpedia endpoint directly, is it possible?
> To repeat myself, the property rdfs:abstract does **not** exist! There
> is a DBpedia property called http://dbpedia.org/ontology/abstract
>
> And why should it not be possible? Send the query with the correct URIs
> of the cities to the DBpedia SPARQL endpoint to get the abstracts.
>
> One comment, your URIs do **not** match the URIs of DBpedia!
> * you have http://dbpedia.org/resource#London.
> * the correct DBpedia URI would be http://dbpedia.org/resource/London
> >
> > The instances data could be the following in my ontology:
> >
> > I have one suggestion: Is it possible we are allowed to paste a screen
> shot
> > of our ontology or something else in this group like we do in Protege
> > group?
> I think it's not possible by the mailing list system - but I'm not an
> admin. You could add links that refer image upload services  - as you
> should know.
> >
> > ___
> >
> >
> >
> >
> > 
> >
> > http://xmlns.com/
> foaf/0.1/depiction#Q1">
> > What is the capital city of Germany?
> > 
> > 
> >
> >
> >
> > 
> >
> > http://xmlns.com/
> foaf/0.1/depiction#Q2">
> > What is the biggest city of Europe?
> > 
> >
> >
> >
> > 
> >
> > http://xmlns.com/
> foaf/0.1/depiction#Q3">
> > What is capital city of Spain?
> > 
> >
> >
> >
> > 
> >
> > http://xmlns.com/
> foaf/0.1/depiction#Q4
> > "/>
> >
> >
> >
> > 
> >
> > 
> > Berlin, Germany’s capital, dates to the 13th
> > century. Reminders of the citys turbulent 20th-century history
> > include its Holocaust memorial and the Berlin Walls graffitied
> > remains. Divided during the Cold War, its 18th-century Brandenburg Gate
> has
> > become a symbol of reunification
> > 
> >
> >
> >
> > 
> >
> > 
> >
> >
> >
> > 
> >
> > 
> > Madrid, Spains central capital, is a city of
> > elegant boulevards and expansive, manicured parks such as the Buen
> Retiro.
> > It’s renowned for its rich repositories of European art, including the
> > Prado Museum’s works by Goya, Velázquez and other Spanish
> > masters.
> > 
> > 
> >
> >
> > <https://www.avast.com/sig-email?utm_medium=email_
> source=link_campaign=sig-email_content=webmail_term=icon>
> > Virus-free.
> > www.avast.com
> > <https://www.avast.com/sig-email?utm_medium=email_
> source=link_campaign=sig-email_content=webmail_term=link>
> > <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> >
> > On Thu, Oct 19, 2017 at 11:37 AM, Lorenz Buehmann <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >> This is one of the most confusing question I ever read here...
> >>
> >> What is in your ontology? Sample data please! (in Turtle or N-Triples
> >> syntax)
> >>
> >> More comments inline:
> >>
> >>
> >> On 18.10.2017 20:10, javed khan wrote:
> >>> Good day
> >>>
> >>> I want to ask is it possible we access Dbpedia resource  with a
> variable
> >>> name.
> >> Have you tried it?
> >>> For exa

Re: How to to access Dbpedia resource using variable

2017-10-19 Thread javed khan
Hello Lorenz, I knew I will not be able to explain my point.

I have one class: Question  (What is capital city of Germany)
Another class : Answer (Berlin)
and similar question/answers instances.

I want to show rdfs:comment of answers like Berlin,Madrid and it works

So when I mentioned ?x  rdfs:comment  ?comment, the ?x contains Answers
like Berlin, Madrid

After this query if I want to show the rdfs:abstract of Answers (Berlin
etc) from Dbpedia endpoint directly, is it possible?

The instances data could be the following in my ontology:

I have one suggestion: Is it possible we are allowed to paste a screen shot
of our ontology or something else in this group like we do in Protege
group?

___






http://xmlns.com/foaf/0.1/depiction#Q1;>
What is the capital city of Germany?







http://xmlns.com/foaf/0.1/depiction#Q2;>
What is the biggest city of Europe?






http://xmlns.com/foaf/0.1/depiction#Q3;>
What is capital city of Spain?






http://xmlns.com/foaf/0.1/depiction#Q4
"/>






Berlin, Germany’s capital, dates to the 13th
century. Reminders of the citys turbulent 20th-century history
include its Holocaust memorial and the Berlin Walls graffitied
remains. Divided during the Cold War, its 18th-century Brandenburg Gate has
become a symbol of reunification













Madrid, Spains central capital, is a city of
elegant boulevards and expansive, manicured parks such as the Buen Retiro.
It’s renowned for its rich repositories of European art, including the
Prado Museum’s works by Goya, Velázquez and other Spanish
masters.




<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail_term=icon>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail_term=link>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Thu, Oct 19, 2017 at 11:37 AM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

> This is one of the most confusing question I ever read here...
>
> What is in your ontology? Sample data please! (in Turtle or N-Triples
> syntax)
>
> More comments inline:
>
>
> On 18.10.2017 20:10, javed khan wrote:
> > Good day
> >
> > I want to ask is it possible we access Dbpedia resource  with a variable
> > name.
> Have you tried it?
> > For example, we have ontology which include rdfs:comment about different
> > cities and cities name are in our ontology and store in x variable
> >
> > ?x rdfs:comment ?y  //This query works for me
> It works locally on your ontology - this is not a surprise as long as
> the query matches some data.
> >
> > Now we want to directly access Dbpedia server (not using ontologiy) for
> > these cities and this time we want to access rdfs:abstract, so can we use
> There is no property rdfs:abstract in the RDFS vocabulary. Dbpedia has
> its own ontology, a property that you might mean is
> http://dbpedia.org/ontology/abstract
> >
> > ?x rdfs:abstract ?sbstract
> Typo in variable name...
> >
> > If not , how can we access then rdfs:abstract of different cities stored
> in
> > x
> Again, why can't you try it out? Is somebody/something preventing you
> from sending a SPARQL query to the DBpedia SPARQL endpoint?
> The expression "cities stored in x" doesn't make sense - or what is x
> for you? the dataset?
>
> If you have cities in your ontology, then you have to use those URIs as
> binding for variable ?x - and this only works if the URIs are the same.
> But again, we don't know your data. Alternative would be to match on the
> city name, but this is indeed bad practice as city names are ambiguous
>
>


How to to access Dbpedia resource using variable

2017-10-18 Thread javed khan
Good day

I want to ask is it possible we access Dbpedia resource  with a variable
name.
For example, we have ontology which include rdfs:comment about different
cities and cities name are in our ontology and store in x variable

?x rdfs:comment ?y  //This query works for me

Now we want to directly access Dbpedia server (not using ontologiy) for
these cities and this time we want to access rdfs:abstract, so can we use

?x rdfs:abstract ?sbstract

If not , how can we access then rdfs:abstract of different cities stored in
x

Thank you


Re: Construct query for Rules

2017-09-14 Thread javed khan
Thank you Lorenz for your help.



On Thu, Sep 14, 2017 at 8:30 AM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

>
>
> On 14.09.2017 15:15, javed khan wrote:
> > Hello Lorenz, I have class Student which have sub classes "Researcher (if
> > publication>10), Assistant (if publications >7) and Junior Student. The
> > instances of these classes are assigned using Construct query as shown in
> > my previous email.
> >
> > I want to store it also in file as other data of students name,
> department
> > etc are already in the file. Earlier I used Jena rules and it was stored
> in
> > the file.
> >
> > **If you want to have the additional triples in the same file, you
> > have to add the triples to the original model and write this model back
> > to file.
> >
> > It means Lorenz, I have to add the "results" model Of Construct query to
> > the other model which have all other data and then store/write it to the
> > file?
> >
> > model.add(results)
> Yes, this should be quite obvious: you have a model A which is basically
> a set of triples and based on this model you compute a new model B
> containing another, possibly new set of triples. Indeed, you want to
> have the union of both, thus, add B to A.
> An alternative would be directly modify model A by means of a SPARQL
> update query, but it wouldn't change the overall result.
> >
> > On Thu, Sep 14, 2017 at 3:07 PM, Lorenz Buehmann <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >>
> >> On 12.09.2017 22:01, javed khan wrote:
> >>> Andy, Dave, Lorenz thanks a lot for your help. I removed the comma and
> it
> >>> works.
> >>>
> >>> But to write it to the file, we have the OntModel (model1) as:
> >>>
> >>> try (FileOutputStream writer = new FileOutputStream("F://exp.owl")) {
> >>>   model1.write(writer, "RDF/XML");
> >>>
> >>> But after we run the Construct query, we will have another model like:
> >>>
> >>> Model results= qexec.execConstruct() ;
> >>> results.write(System.out, "TURTLE");
> >> That model contains only the new triples, not the old ones.
> >>> So we should write it separate to the file? I tried this but it did not
> >>> work. In fact, it over-write the already data in the file.
> >> I don't get it as I don't understand what you want to achieve in the
> >> end. If you want to have the additional triples in the same file, you
> >> have to add the triples to the original model and write this model back
> >> to file.
> >>
> >>> //The query work fine if we write to console.
> >>>
> >>> On Tue, Sep 12, 2017 at 1:45 PM, Lorenz Buehmann <
> >>> buehm...@informatik.uni-leipzig.de> wrote:
> >>>
> >>>>> "FILTER ( ?score > '10' ). "   // is this right syntax in Jena?
> >>>> That has nothing to do with Jena - It's SPARQL syntax and as Dave
> >>>> already pointed out,
> >>>> '10' is a string literal - either use "10"^^xsd:integer or the
> shortcut
> >>>> 10 . See the Turtle syntax for RDF and look into the SPARQL specs.
> >>>>> On Mon, Sep 11, 2017 at 3:17 PM, Lorenz Buehmann <
> >>>>> buehm...@informatik.uni-leipzig.de> wrote:
> >>>>>
> >>>>>> Show code + data, otherwise nobody can help you ...
> >>>>>>
> >>>>>> That's the simplest way, a SPARQL query for each rule - don't make
> it
> >>>>>> more complicated as necessary.
> >>>>>>
> >>>>>> Don't forget (Dave and me already told you that): if you have
> multiple
> >>>>>> rules that depend on each other, you have to perform the SPARQL
> >> queries
> >>>>>> as long as no new data has been generated ("fix-point iteration") -
> >> with
> >>>>>> rules you get this for free by the rule engine.
> >>>>>>
> >>>>>>
> >>>>>> On 11.09.2017 13:09, javed khan wrote:
> >>>>>>> Hello Lorenz yes it did not work for me. İ have about sixteen
> similar
> >>>>>> types
> >>>>>>> of rules and not sure if İ need a separate SPARQL Construct query
> for
> >>>>>> each
> >>>>>>> rule.
> >>>&

Re: Construct query for Rules

2017-09-14 Thread javed khan
Hello Lorenz, I have class Student which have sub classes "Researcher (if
publication>10), Assistant (if publications >7) and Junior Student. The
instances of these classes are assigned using Construct query as shown in
my previous email.

I want to store it also in file as other data of students name, department
etc are already in the file. Earlier I used Jena rules and it was stored in
the file.

**If you want to have the additional triples in the same file, you
have to add the triples to the original model and write this model back
to file.

It means Lorenz, I have to add the "results" model Of Construct query to
the other model which have all other data and then store/write it to the
file?

model.add(results)

On Thu, Sep 14, 2017 at 3:07 PM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

>
>
> On 12.09.2017 22:01, javed khan wrote:
> > Andy, Dave, Lorenz thanks a lot for your help. I removed the comma and it
> > works.
> >
> > But to write it to the file, we have the OntModel (model1) as:
> >
> > try (FileOutputStream writer = new FileOutputStream("F://exp.owl")) {
> >   model1.write(writer, "RDF/XML");
> >
> > But after we run the Construct query, we will have another model like:
> >
> > Model results= qexec.execConstruct() ;
> > results.write(System.out, "TURTLE");
> That model contains only the new triples, not the old ones.
> >
> > So we should write it separate to the file? I tried this but it did not
> > work. In fact, it over-write the already data in the file.
> I don't get it as I don't understand what you want to achieve in the
> end. If you want to have the additional triples in the same file, you
> have to add the triples to the original model and write this model back
> to file.
>
> >
> > //The query work fine if we write to console.
> >
> > On Tue, Sep 12, 2017 at 1:45 PM, Lorenz Buehmann <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >>> "FILTER ( ?score > '10' ). "   // is this right syntax in Jena?
> >> That has nothing to do with Jena - It's SPARQL syntax and as Dave
> >> already pointed out,
> >> '10' is a string literal - either use "10"^^xsd:integer or the shortcut
> >> 10 . See the Turtle syntax for RDF and look into the SPARQL specs.
> >>> On Mon, Sep 11, 2017 at 3:17 PM, Lorenz Buehmann <
> >>> buehm...@informatik.uni-leipzig.de> wrote:
> >>>
> >>>> Show code + data, otherwise nobody can help you ...
> >>>>
> >>>> That's the simplest way, a SPARQL query for each rule - don't make it
> >>>> more complicated as necessary.
> >>>>
> >>>> Don't forget (Dave and me already told you that): if you have multiple
> >>>> rules that depend on each other, you have to perform the SPARQL
> queries
> >>>> as long as no new data has been generated ("fix-point iteration") -
> with
> >>>> rules you get this for free by the rule engine.
> >>>>
> >>>>
> >>>> On 11.09.2017 13:09, javed khan wrote:
> >>>>> Hello Lorenz yes it did not work for me. İ have about sixteen similar
> >>>> types
> >>>>> of rules and not sure if İ need a separate SPARQL Construct query for
> >>>> each
> >>>>> rule.
> >>>>> For example another such type of rule is if a person experience is
> more
> >>>>> than some value, then person is Experience employee and other rules
> >> like
> >>>>> that.
> >>>>>
> >>>>> On Mon, Sep 11, 2017 at 11:18 AM, Lorenz Buehmann <
> >>>>> buehm...@informatik.uni-leipzig.de> wrote:
> >>>>>
> >>>>>> I thought Dave explained this already. Of course you can use a
> SPARQL
> >>>>>> CONSTRUCT query to get the same result as a single Jena rule.
> >>>>>>
> >>>>>> The answer is, yes. Your query should do the same as your rule.
> >>>>>>
> >>>>>> And I'm wondering why you can't try it out on your data? Does
> >> something
> >>>>>> not work as expected?
> >>>>>>
> >>>>>>
> >>>>>> On 10.09.2017 22:15, javed khan wrote:
> >>>>>>> I am wondering if the following Construct query could lead to the
> >>>>>> alternate
> >>>>>>> result of the Jena rule (given below)?
> >>>>>>>
> >>>>>>> Rule: (?x rdf:type :Student) + (?x exp:NoOfPublications ?No)
> >>>> +greaterThan
> >>>>>>> (?No, 10)-> (?x rdf:type :Researcher)
> >>>>>>>
> >>>>>>> Construct Query:
> >>>>>>>
> >>>>>>> Construct {?x rdf:type :Researcher}
> >>>>>>>
> >>>>>>> Where{ ?x rdf:type :Student . ?x exp: NoOfPublications ?No . Filter
> >>>>>>> (?No>10) }
> >>>>>>>
> >>
>
>


Re: Construct query for Rules

2017-09-12 Thread javed khan
Andy, Dave, Lorenz thanks a lot for your help. I removed the comma and it
works.

But to write it to the file, we have the OntModel (model1) as:

try (FileOutputStream writer = new FileOutputStream("F://exp.owl")) {
  model1.write(writer, "RDF/XML");

But after we run the Construct query, we will have another model like:

Model results= qexec.execConstruct() ;
results.write(System.out, "TURTLE");

So we should write it separate to the file? I tried this but it did not
work. In fact, it over-write the already data in the file.

//The query work fine if we write to console.

On Tue, Sep 12, 2017 at 1:45 PM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

>
> > "FILTER ( ?score > '10' ). "   // is this right syntax in Jena?
> That has nothing to do with Jena - It's SPARQL syntax and as Dave
> already pointed out,
> '10' is a string literal - either use "10"^^xsd:integer or the shortcut
> 10 . See the Turtle syntax for RDF and look into the SPARQL specs.
> >
> > On Mon, Sep 11, 2017 at 3:17 PM, Lorenz Buehmann <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >> Show code + data, otherwise nobody can help you ...
> >>
> >> That's the simplest way, a SPARQL query for each rule - don't make it
> >> more complicated as necessary.
> >>
> >> Don't forget (Dave and me already told you that): if you have multiple
> >> rules that depend on each other, you have to perform the SPARQL queries
> >> as long as no new data has been generated ("fix-point iteration") - with
> >> rules you get this for free by the rule engine.
> >>
> >>
> >> On 11.09.2017 13:09, javed khan wrote:
> >>> Hello Lorenz yes it did not work for me. İ have about sixteen similar
> >> types
> >>> of rules and not sure if İ need a separate SPARQL Construct query for
> >> each
> >>> rule.
> >>> For example another such type of rule is if a person experience is more
> >>> than some value, then person is Experience employee and other rules
> like
> >>> that.
> >>>
> >>> On Mon, Sep 11, 2017 at 11:18 AM, Lorenz Buehmann <
> >>> buehm...@informatik.uni-leipzig.de> wrote:
> >>>
> >>>> I thought Dave explained this already. Of course you can use a SPARQL
> >>>> CONSTRUCT query to get the same result as a single Jena rule.
> >>>>
> >>>> The answer is, yes. Your query should do the same as your rule.
> >>>>
> >>>> And I'm wondering why you can't try it out on your data? Does
> something
> >>>> not work as expected?
> >>>>
> >>>>
> >>>> On 10.09.2017 22:15, javed khan wrote:
> >>>>> I am wondering if the following Construct query could lead to the
> >>>> alternate
> >>>>> result of the Jena rule (given below)?
> >>>>>
> >>>>> Rule: (?x rdf:type :Student) + (?x exp:NoOfPublications ?No)
> >> +greaterThan
> >>>>> (?No, 10)-> (?x rdf:type :Researcher)
> >>>>>
> >>>>> Construct Query:
> >>>>>
> >>>>> Construct {?x rdf:type :Researcher}
> >>>>>
> >>>>> Where{ ?x rdf:type :Student . ?x exp: NoOfPublications ?No . Filter
> >>>>> (?No>10) }
> >>>>>
> >>
>
>


Re: Construct query for Rules

2017-09-11 Thread javed khan
Hello Martynas and Lorenz thank you

I have issue about it.  When I use the filter keyword, the query does not
show the result. When I remove the filter, it writes in console that x is
type of researcher (regardless of any number of publications as there is no
filter) So the problem is in Filter syntax in Jena code. I use Filter as

"FILTER ( ?score > '10' ). "   // is this right syntax in Jena?



On Mon, Sep 11, 2017 at 3:17 PM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

> Show code + data, otherwise nobody can help you ...
>
> That's the simplest way, a SPARQL query for each rule - don't make it
> more complicated as necessary.
>
> Don't forget (Dave and me already told you that): if you have multiple
> rules that depend on each other, you have to perform the SPARQL queries
> as long as no new data has been generated ("fix-point iteration") - with
> rules you get this for free by the rule engine.
>
>
> On 11.09.2017 13:09, javed khan wrote:
> > Hello Lorenz yes it did not work for me. İ have about sixteen similar
> types
> > of rules and not sure if İ need a separate SPARQL Construct query for
> each
> > rule.
> > For example another such type of rule is if a person experience is more
> > than some value, then person is Experience employee and other rules like
> > that.
> >
> > On Mon, Sep 11, 2017 at 11:18 AM, Lorenz Buehmann <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >> I thought Dave explained this already. Of course you can use a SPARQL
> >> CONSTRUCT query to get the same result as a single Jena rule.
> >>
> >> The answer is, yes. Your query should do the same as your rule.
> >>
> >> And I'm wondering why you can't try it out on your data? Does something
> >> not work as expected?
> >>
> >>
> >> On 10.09.2017 22:15, javed khan wrote:
> >>> I am wondering if the following Construct query could lead to the
> >> alternate
> >>> result of the Jena rule (given below)?
> >>>
> >>> Rule: (?x rdf:type :Student) + (?x exp:NoOfPublications ?No)
> +greaterThan
> >>> (?No, 10)-> (?x rdf:type :Researcher)
> >>>
> >>> Construct Query:
> >>>
> >>> Construct {?x rdf:type :Researcher}
> >>>
> >>> Where{ ?x rdf:type :Student . ?x exp: NoOfPublications ?No . Filter
> >>> (?No>10) }
> >>>
> >>
>
>


Re: Construct query for Rules

2017-09-11 Thread javed khan
Hello Lorenz yes it did not work for me. İ have about sixteen similar types
of rules and not sure if İ need a separate SPARQL Construct query for each
rule.
For example another such type of rule is if a person experience is more
than some value, then person is Experience employee and other rules like
that.

On Mon, Sep 11, 2017 at 11:18 AM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

> I thought Dave explained this already. Of course you can use a SPARQL
> CONSTRUCT query to get the same result as a single Jena rule.
>
> The answer is, yes. Your query should do the same as your rule.
>
> And I'm wondering why you can't try it out on your data? Does something
> not work as expected?
>
>
> On 10.09.2017 22:15, javed khan wrote:
> > I am wondering if the following Construct query could lead to the
> alternate
> > result of the Jena rule (given below)?
> >
> > Rule: (?x rdf:type :Student) + (?x exp:NoOfPublications ?No) +greaterThan
> > (?No, 10)-> (?x rdf:type :Researcher)
> >
> > Construct Query:
> >
> > Construct {?x rdf:type :Researcher}
> >
> > Where{ ?x rdf:type :Student . ?x exp: NoOfPublications ?No . Filter
> > (?No>10) }
> >
>
>


Construct query for Rules

2017-09-10 Thread javed khan
I am wondering if the following Construct query could lead to the alternate
result of the Jena rule (given below)?

Rule: (?x rdf:type :Student) + (?x exp:NoOfPublications ?No) +greaterThan
(?No, 10)-> (?x rdf:type :Researcher)

Construct Query:

Construct {?x rdf:type :Researcher}

Where{ ?x rdf:type :Student . ?x exp: NoOfPublications ?No . Filter
(?No>10) }


Re: Error in query

2017-08-24 Thread javed khan
Thank you Martynas, I got it...  It confused me slightly because it was my
first time I executed CONSTRUCT using Jena code.


On Fri, Aug 25, 2017 at 12:00 AM, Martynas Jusevičius <
marty...@atomgraph.com> wrote:

> Because there are 2 forms of SPARQL queries:
> - ASK and SELECT return ResultSet (table of variable bindings)
> - CONSTRUCT and DESCRIBE return Model (RDF graph = triples)
>
> On Thu, Aug 24, 2017 at 10:58 PM, javed khan <javedbtk...@gmail.com>
> wrote:
>
> > Hello Martynas, it finally showed the result.
> >
> > But I did not understand the code. Why we assign the result to a Model?
> Why
> > not resultset.
> >
> > Model results =  qexec.execConstruct() ;
> >
> > On Thu, Aug 24, 2017 at 11:44 PM, Martynas Jusevičius <
> > marty...@atomgraph.com> wrote:
> >
> > > This means your query hasn't matched anything.
> > >
> > > Show us your data.
> > >
> > > On Thu, Aug 24, 2017 at 10:42 PM, javed khan <javedbtk...@gmail.com>
> > > wrote:
> > >
> > > > In response to my question earlier, I replace this
> > > >
> > > > ResultSet results = (ResultSet) qexec.execConstruct() ;
> > > >
> > > > with
> > > >
> > > > Model results =  qexec.execConstruct() ;
> > > > results.write(System.out, "TURTLE");
> > > >
> > > > But how can I get the require result i.e value of ?z and ?y
> > > >
> > > > I expect the following result:
> > > >
> > > > Bob  hasUncle  Lincoln
> > > >
> > > > But currently, it just display the prefixes.
> > > >
> > > >
> > > >
> > > >
> > > > On Thu, Aug 24, 2017 at 9:20 PM, javed khan <javedbtk...@gmail.com>
> > > wrote:
> > > >
> > > > > Hello
> > > > >
> > > > > What is the problem in this query: 'Male' is string literal here.
> > (The
> > > > > query works inside Protege)
> > > > >
> > > > > CONSTRUCT   { ?x mo:hasUncle ?y } WHERE { ?x  mo:hasParents ?z .?z
> > > > > mo:Gender  'Male' . ?z mo:hasBrother ?y}
> > > > >
> > > > > Query query = QueryFactory.create(str);
> > > > > QueryExecution qexec = QueryExecutionFactory.create(query, model)
> ;
> > > > > ResultSet results = (ResultSet) qexec.execConstruct() ;
> > > > > while (results.hasNext())
> > > > > {
> > > > > QuerySolution binding = results.nextSolution();
> > > > > Literal lit =  binding.get("z").asLiteral();
> > > > >
> > > > >
> > > > >
> > > >
> > >
> >
>


Re: Error in query

2017-08-24 Thread javed khan
Hello Martynas, it finally showed the result.

But I did not understand the code. Why we assign the result to a Model? Why
not resultset.

Model results =  qexec.execConstruct() ;

On Thu, Aug 24, 2017 at 11:44 PM, Martynas Jusevičius <
marty...@atomgraph.com> wrote:

> This means your query hasn't matched anything.
>
> Show us your data.
>
> On Thu, Aug 24, 2017 at 10:42 PM, javed khan <javedbtk...@gmail.com>
> wrote:
>
> > In response to my question earlier, I replace this
> >
> > ResultSet results = (ResultSet) qexec.execConstruct() ;
> >
> > with
> >
> > Model results =  qexec.execConstruct() ;
> > results.write(System.out, "TURTLE");
> >
> > But how can I get the require result i.e value of ?z and ?y
> >
> > I expect the following result:
> >
> > Bob  hasUncle  Lincoln
> >
> > But currently, it just display the prefixes.
> >
> >
> >
> >
> > On Thu, Aug 24, 2017 at 9:20 PM, javed khan <javedbtk...@gmail.com>
> wrote:
> >
> > > Hello
> > >
> > > What is the problem in this query: 'Male' is string literal here. (The
> > > query works inside Protege)
> > >
> > > CONSTRUCT   { ?x mo:hasUncle ?y } WHERE { ?x  mo:hasParents ?z .?z
> > > mo:Gender  'Male' . ?z mo:hasBrother ?y}
> > >
> > > Query query = QueryFactory.create(str);
> > > QueryExecution qexec = QueryExecutionFactory.create(query, model) ;
> > > ResultSet results = (ResultSet) qexec.execConstruct() ;
> > > while (results.hasNext())
> > > {
> > > QuerySolution binding = results.nextSolution();
> > > Literal lit =  binding.get("z").asLiteral();
> > >
> > >
> > >
> >
>


Re: Error in query

2017-08-24 Thread javed khan
In response to my question earlier, I replace this

ResultSet results = (ResultSet) qexec.execConstruct() ;

with

Model results =  qexec.execConstruct() ;
results.write(System.out, "TURTLE");

But how can I get the require result i.e value of ?z and ?y

I expect the following result:

Bob  hasUncle  Lincoln

But currently, it just display the prefixes.




On Thu, Aug 24, 2017 at 9:20 PM, javed khan <javedbtk...@gmail.com> wrote:

> Hello
>
> What is the problem in this query: 'Male' is string literal here. (The
> query works inside Protege)
>
> CONSTRUCT   { ?x mo:hasUncle ?y } WHERE { ?x  mo:hasParents ?z .?z
> mo:Gender  'Male' . ?z mo:hasBrother ?y}
>
> Query query = QueryFactory.create(str);
> QueryExecution qexec = QueryExecutionFactory.create(query, model) ;
> ResultSet results = (ResultSet) qexec.execConstruct() ;
> while (results.hasNext())
> {
> QuerySolution binding = results.nextSolution();
> Literal lit =  binding.get("z").asLiteral();
>
>
>


Error in query

2017-08-24 Thread javed khan
Hello

What is the problem in this query: 'Male' is string literal here. (The
query works inside Protege)

CONSTRUCT   { ?x mo:hasUncle ?y } WHERE { ?x  mo:hasParents ?z .?z
mo:Gender  'Male' . ?z mo:hasBrother ?y}

Query query = QueryFactory.create(str);
QueryExecution qexec = QueryExecutionFactory.create(query, model) ;
ResultSet results = (ResultSet) qexec.execConstruct() ;
while (results.hasNext())
{
QuerySolution binding = results.nextSolution();
Literal lit =  binding.get("z").asLiteral();


Jena Bean

2017-08-11 Thread javed khan
What is JenaBean advantages? Is it simplify our code and bring the bridge
between our Java code and rdf Api?


Re: Data or Object properties as String value

2017-08-07 Thread javed khan
Ok thanks a lot Lorenz.

<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail_term=icon>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail_term=link>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Mon, Aug 7, 2017 at 10:59 AM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

>
>
> On 06.08.2017 13:14, javed khan wrote:
> > **The better way would be to add labels for the resources and search in
> > the labels instead.**
> >
> > By label you mean rdfs:label?  In that case, how it can be searched then
> > when user provide their inputs via UI i-e a text field in my case.?
> Ehm, simply using the FILTER on the label value?!
> >
> > <https://www.avast.com/sig-email?utm_medium=email_
> source=link_campaign=sig-email_content=webmail_term=icon>
> > Virus-free.
> > www.avast.com
> > <https://www.avast.com/sig-email?utm_medium=email_
> source=link_campaign=sig-email_content=webmail_term=link>
> > <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> >
> > On Sun, Aug 6, 2017 at 1:23 PM, Lorenz B. <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >> Then you have to use a REGEX (or CONTAINS - not sure how you want to
> >> match) in the FILTER and search in the String of the URI
> >>
> >> FILTER(REGEX(STR(?var), "TOKEN"))
> >>
> >>
> >> But in general that's bad practice for sure.
> >>
> >> The better way would be to add labels for the resources and search in
> >> the labels instead.
> >>
> >>> Lorenz yes I know object properties connect resources of two classes
> and
> >> it
> >>> must be URIs..
> >>>
> >>> In our ontology we have object property "hasPublications" which has
> >> domain
> >>> Person and range Publication class (Publication instances can be a
> Book,
> >>> Paper or Article) . Users need to type a person publication by typing
> its
> >>> name in a text box "Cloud computing security"  and we have to find it.
> >>>
> >>> So in that case in order to use it as Filter in query, we need to use
> >> both
> >>> object property and data property like
> >>>
> >>>  Person hasPublications somepublication   and then data property as
> >> string
> >>>  publicationName "String value"
> >>>
> >>> On Sat, Aug 5, 2017 at 10:49 AM, Lorenz B. <
> >>> buehm...@informatik.uni-leipzig.de> wrote:
> >>>
> >>>>> For example, if we have to use filter keyword with a java variable
> >>>> (filter
> >>>>> ?var='javaVariable) in our semantic web application, is it mandatory
> to
> >>>> use
> >>>>> it as "data property" in our ontology and use it as String type?
> >>>> Obviously, but it depends on the content of javaVariable ... you can
> >>>> also compare other datatypes like int, double, etc. and for some you
> >>>> have to provide the datatype explcitely, i.e. "VALUE"^^
> >>>> But yes, if it would be an object property you have to use a URI - I
> >>>> hope this is clear, this is very basic Semantic Web knowledge, you
> >>>> should already know that object properties "connect" resources which
> are
> >>>> denoted by URIs.
> >>>>> Like, name as data property in the ontology and then we use in our
> >>>> (SPARQL
> >>>>> Filter) query when a user enter the name in a text box.
> >>>>>
> >>>>> Some time we need some object properties (as string) to use it as
> >> filter
> >>>> in
> >>>>> our queries.
> >>>>>
> >>>>>
> >>>>> <https://www.avast.com/sig-email?utm_medium=email_
> >>>> source=link_campaign=sig-email_content=webmail_term=icon>
> >>>>> Virus-free.
> >>>>> www.avast.com
> >>>>> <https://www.avast.com/sig-email?utm_medium=email_
> >>>> source=link_campaign=sig-email_content=webmail_term=link>
> >>>>> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> >>>>>
> >>>> --
> >>>> 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: Data or Object properties as String value

2017-08-05 Thread javed khan
Lorenz yes I know object properties connect resources of two classes and it
must be URIs..

In our ontology we have object property "hasPublications" which has domain
Person and range Publication class (Publication instances can be a Book,
Paper or Article) . Users need to type a person publication by typing its
name in a text box "Cloud computing security"  and we have to find it.

So in that case in order to use it as Filter in query, we need to use both
object property and data property like

 Person hasPublications somepublication   and then data property as string
 publicationName "String value"

On Sat, Aug 5, 2017 at 10:49 AM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

>
>
> > For example, if we have to use filter keyword with a java variable
> (filter
> > ?var='javaVariable) in our semantic web application, is it mandatory to
> use
> > it as "data property" in our ontology and use it as String type?
> Obviously, but it depends on the content of javaVariable ... you can
> also compare other datatypes like int, double, etc. and for some you
> have to provide the datatype explcitely, i.e. "VALUE"^^
> But yes, if it would be an object property you have to use a URI - I
> hope this is clear, this is very basic Semantic Web knowledge, you
> should already know that object properties "connect" resources which are
> denoted by URIs.
> >
> > Like, name as data property in the ontology and then we use in our
> (SPARQL
> > Filter) query when a user enter the name in a text box.
> >
> > Some time we need some object properties (as string) to use it as filter
> in
> > our queries.
> >
> >
> >  source=link_campaign=sig-email_content=webmail_term=icon>
> > Virus-free.
> > www.avast.com
> >  source=link_campaign=sig-email_content=webmail_term=link>
> > <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> >
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
>


Data or Object properties as String value

2017-08-04 Thread javed khan
For example, if we have to use filter keyword with a java variable (filter
?var='javaVariable) in our semantic web application, is it mandatory to use
it as "data property" in our ontology and use it as String type?

Like, name as data property in the ontology and then we use in our (SPARQL
Filter) query when a user enter the name in a text box.

Some time we need some object properties (as string) to use it as filter in
our queries.



Virus-free.
www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>


Re: rules (non monotonic)

2017-07-26 Thread javed khan
Thank you Lorenz.

On Wed, Jul 26, 2017 at 3:24 PM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

> SPARQL 1.1 Update is straightforward ...
>
> General structure for making update queries aka. delete + insert:
>
>
> DELETE {
>
> }
>
> INSERT {
>
> }
>
> WHERE {
>
> }
>
>
> On 26.07.2017 14:04, javed khan wrote:
> > Thank you Dave, Ok I am going to read about the UPDATE statements and how
> > it works to update our owl file.
> >
> >
> >
> > On Wed, Jul 26, 2017 at 2:51 PM, Dave Reynolds <
> dave.e.reyno...@gmail.com>
> > wrote:
> >
> >> On 26/07/17 12:07, javed khan wrote:
> >>
> >>> Hello Dave, for instance, if we want to assign players to different
> >>> classes
> >>> i-e Star player or Average player based their goals like if player
> NoGoals
> >>>
> >>>> 10 then ?player rdf:type StarPlayer.
> >>>>
> >>> Can we do it using SPARQL Update?
> >>>
> >> Yes, we've already said that.
> >>
> >> If yes, how?
> >> I think there's some misunderstanding here. We're not going to write
> your
> >> code or rules or queries for you. As volunteers we try to help with
> aspects
> >> of Jena as best we can but the basics of learning Sparql are up to you.
> As
> >> is the design of your data flow, how updates will work and how you
> handle
> >> change.
> >>
> >> Dave
> >>
> >>
> >>
> >>> On Wed, Jul 26, 2017 at 10:26 AM, Dave Reynolds <
> >>> dave.e.reyno...@gmail.com>
> >>> wrote:
> >>>
> >>>
> >>>> On 25/07/17 11:57, javed khan wrote:
> >>>>
> >>>> Dave, the "Goal" here is a data property which has integer values. Is
> it
> >>>>> monotonic in this case?
> >>>>>
> >>>>>
> >>>> Presumably that means that when the number of goals change you remove
> the
> >>>> statement with the old data property value and add a replacement
> >>>> statement
> >>>> with a different number. If so then that's the situation I've already
> >>>> described that will work with rules just fine.
> >>>>
> >>>> Try it and see.
> >>>>
> >>>> Lorenz, from past post I have seen some where that if you put the
> >>>> inferred
> >>>>
> >>>>> data into another model, then it may solve the problem. Is this the
> case
> >>>>> or
> >>>>> I have just misinterpret the meaning?
> >>>>>
> >>>>>
> >>>> You have to think through (and if you want help, then describe to us)
> >>>> exactly what the data flow is that you are after. Think of rules as
> just
> >>>> a
> >>>> building block - how you present data to the rules, what you do with
> the
> >>>> resulting inferences and how you handle data changes all depend on the
> >>>> specific problem you are dealing with. Taking the results of inference
> >>>> (the
> >>>> deduction model in the case of forward rules) and copying them
> somewhere
> >>>> else may or may not be helpful depending on exactly what you are
> doing in
> >>>> your overall system.
> >>>>
> >>>> Dave
> >>>>
> >>>>
> >>>> On Tue, Jul 25, 2017 at 10:53 AM, Lorenz Buehmann <
> >>>>
> >>>>> buehm...@informatik.uni-leipzig.de> wrote:
> >>>>>
> >>>>>
> >>>>> I know rules are non monotonic,
> >>>>>>> No, that's exactly not the case for Jena rules - the computation is
> >>>>>> monotonic.
> >>>>>>
> >>>>>> We had this discussion here several times, either it was you or some
> >>>>>> other people  (e.g. tina sani, kumar rohit etc.) doing the same
> >>>>>> project/exercise/homework whatever
> >>>>>> The answer is, you have to implement it by yourself in the client
> code
> >>>>>> -
> >>>>>> which means you have to remove the data that doesn't hold anymore.
> Or
> >>>>>> you always refer to only the data that will be inferred by the rules
> >>>>>> ad-hoc and don't write it back to the raw data. Indeed this might be
> >>>>>> expensive but we don't know anything about your project. This are
> >>>>>> typical design decision that YOU have to make based on YOUR
> >>>>>> requirements.
> >>>>>>
> >>>>>>
> >>>>>>
>
>


Re: rules (non monotonic)

2017-07-26 Thread javed khan
Thank you Dave, Ok I am going to read about the UPDATE statements and how
it works to update our owl file.



On Wed, Jul 26, 2017 at 2:51 PM, Dave Reynolds <dave.e.reyno...@gmail.com>
wrote:

>
> On 26/07/17 12:07, javed khan wrote:
>
>> Hello Dave, for instance, if we want to assign players to different
>> classes
>> i-e Star player or Average player based their goals like if player NoGoals
>>
>>> 10 then ?player rdf:type StarPlayer.
>>>
>>
>> Can we do it using SPARQL Update?
>>
>
> Yes, we've already said that.
>
> If yes, how?
>>
>
> I think there's some misunderstanding here. We're not going to write your
> code or rules or queries for you. As volunteers we try to help with aspects
> of Jena as best we can but the basics of learning Sparql are up to you. As
> is the design of your data flow, how updates will work and how you handle
> change.
>
> Dave
>
>
>
>> On Wed, Jul 26, 2017 at 10:26 AM, Dave Reynolds <
>> dave.e.reyno...@gmail.com>
>> wrote:
>>
>>
>>> On 25/07/17 11:57, javed khan wrote:
>>>
>>> Dave, the "Goal" here is a data property which has integer values. Is it
>>>> monotonic in this case?
>>>>
>>>>
>>> Presumably that means that when the number of goals change you remove the
>>> statement with the old data property value and add a replacement
>>> statement
>>> with a different number. If so then that's the situation I've already
>>> described that will work with rules just fine.
>>>
>>> Try it and see.
>>>
>>> Lorenz, from past post I have seen some where that if you put the
>>> inferred
>>>
>>>> data into another model, then it may solve the problem. Is this the case
>>>> or
>>>> I have just misinterpret the meaning?
>>>>
>>>>
>>> You have to think through (and if you want help, then describe to us)
>>> exactly what the data flow is that you are after. Think of rules as just
>>> a
>>> building block - how you present data to the rules, what you do with the
>>> resulting inferences and how you handle data changes all depend on the
>>> specific problem you are dealing with. Taking the results of inference
>>> (the
>>> deduction model in the case of forward rules) and copying them somewhere
>>> else may or may not be helpful depending on exactly what you are doing in
>>> your overall system.
>>>
>>> Dave
>>>
>>>
>>> On Tue, Jul 25, 2017 at 10:53 AM, Lorenz Buehmann <
>>>
>>>> buehm...@informatik.uni-leipzig.de> wrote:
>>>>
>>>>
>>>> I know rules are non monotonic,
>>>>>
>>>>>>
>>>>>> No, that's exactly not the case for Jena rules - the computation is
>>>>> monotonic.
>>>>>
>>>>> We had this discussion here several times, either it was you or some
>>>>> other people  (e.g. tina sani, kumar rohit etc.) doing the same
>>>>> project/exercise/homework whatever
>>>>> The answer is, you have to implement it by yourself in the client code
>>>>> -
>>>>> which means you have to remove the data that doesn't hold anymore. Or
>>>>> you always refer to only the data that will be inferred by the rules
>>>>> ad-hoc and don't write it back to the raw data. Indeed this might be
>>>>> expensive but we don't know anything about your project. This are
>>>>> typical design decision that YOU have to make based on YOUR
>>>>> requirements.
>>>>>
>>>>>
>>>>>
>>>>
>>


Re: rules (non monotonic)

2017-07-26 Thread javed khan
Hello Dave, for instance, if we want to assign players to different classes
i-e Star player or Average player based their goals like if player NoGoals
>10 then ?player rdf:type StarPlayer.

Can we do it using SPARQL Update? If yes, how?

With warm regards

On Wed, Jul 26, 2017 at 10:26 AM, Dave Reynolds <dave.e.reyno...@gmail.com>
wrote:

>
> On 25/07/17 11:57, javed khan wrote:
>
>> Dave, the "Goal" here is a data property which has integer values. Is it
>> monotonic in this case?
>>
>
> Presumably that means that when the number of goals change you remove the
> statement with the old data property value and add a replacement statement
> with a different number. If so then that's the situation I've already
> described that will work with rules just fine.
>
> Try it and see.
>
> Lorenz, from past post I have seen some where that if you put the inferred
>> data into another model, then it may solve the problem. Is this the case
>> or
>> I have just misinterpret the meaning?
>>
>
> You have to think through (and if you want help, then describe to us)
> exactly what the data flow is that you are after. Think of rules as just a
> building block - how you present data to the rules, what you do with the
> resulting inferences and how you handle data changes all depend on the
> specific problem you are dealing with. Taking the results of inference (the
> deduction model in the case of forward rules) and copying them somewhere
> else may or may not be helpful depending on exactly what you are doing in
> your overall system.
>
> Dave
>
>
> On Tue, Jul 25, 2017 at 10:53 AM, Lorenz Buehmann <
>> buehm...@informatik.uni-leipzig.de> wrote:
>>
>>
>>> I know rules are non monotonic,
>>>>
>>> No, that's exactly not the case for Jena rules - the computation is
>>> monotonic.
>>>
>>> We had this discussion here several times, either it was you or some
>>> other people  (e.g. tina sani, kumar rohit etc.) doing the same
>>> project/exercise/homework whatever
>>> The answer is, you have to implement it by yourself in the client code -
>>> which means you have to remove the data that doesn't hold anymore. Or
>>> you always refer to only the data that will be inferred by the rules
>>> ad-hoc and don't write it back to the raw data. Indeed this might be
>>> expensive but we don't know anything about your project. This are
>>> typical design decision that YOU have to make based on YOUR requirements.
>>>
>>>
>>


Re: rules (non monotonic)

2017-07-25 Thread javed khan
Dave, the "Goal" here is a data property which has integer values. Is it
monotonic in this case?

Lorenz, from past post I have seen some where that if you put the inferred
data into another model, then it may solve the problem. Is this the case or
I have just misinterpret the meaning?

Thank you

On Tue, Jul 25, 2017 at 10:53 AM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

>
> > I know rules are non monotonic,
> No, that's exactly not the case for Jena rules - the computation is
> monotonic.
>
> We had this discussion here several times, either it was you or some
> other people  (e.g. tina sani, kumar rohit etc.) doing the same
> project/exercise/homework whatever
> The answer is, you have to implement it by yourself in the client code -
> which means you have to remove the data that doesn't hold anymore. Or
> you always refer to only the data that will be inferred by the rules
> ad-hoc and don't write it back to the raw data. Indeed this might be
> expensive but we don't know anything about your project. This are
> typical design decision that YOU have to make based on YOUR requirements.
>


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.


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
>
>


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-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-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: 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
>
>


Materialize query

2017-04-25 Thread javed khan
Hello

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

Regards


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 <javedbtk...@gmail.com>
> 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
>
>


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: 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.
> >
>
>


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: 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 <marco.neum...@gmail.com>
> > 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 <javedbtk...@gmail.com>
> 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
>
>


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 <marco.neum...@gmail.com>
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 <javedbtk...@gmail.com> 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
>


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: 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 <rve...@dotnetrdf.org> 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" <javedbtk...@gmail.com> 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
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 <rve...@dotnetrdf.org> 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" <javedbtk...@gmail.com> 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
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
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
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
>
>


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: 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 <javedbtk...@gmail.com>
> >> 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 <rve...@dotnetrdf.org>
> >> 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 effor

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 <javedbtk...@gmail.com>
> 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 <rve...@dotnetrdf.org>
> 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" <javedbtk...@gmail.com> 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: 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 <a...@apache.org> 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 <a...@apache.org> 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 <a...@apache.org> 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)
>>>>>>>
>>>>>>>
>>>>>>>

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 <a...@apache.org> 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 <a...@apache.org> 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 <a...@apache.org
>>>>>> <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 <
>>>>>&

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 <a...@apache.org
> > <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
[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 <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> 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, 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
> >
>
>


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: 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 <javedbtk...@gmail.com>
> >> 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. <buehm...@informatik.uni-
> >>>> 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 

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 <javedbtk...@gmail.com> 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. <buehm...@informatik.uni-
> 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,
>>

Re: Rules

2017-01-06 Thread javed khan
ly)
> >>>>
> >>>> 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 <rve...@dotnetrdf.org>
> >> 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" <javedbtk...@gmail.com> 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-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 <rve...@dotnetrdf.org>
> 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 althou

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 <rve...@dotnetrdf.org> 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" <javedbtk...@gmail.com> 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
> >> > 

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 <rve...@dotnetrdf.org> 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" <javedbtk...@gmail.com> 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
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
>
>
>


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: 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 <dave.e.reyno...@gmail.com>
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 <dave.e.reyno...@gmail.com>
>> 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
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 <dave.e.reyno...@gmail.com>
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
>
>
>


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: 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
>
>


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-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 <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}";
>>
>>
>


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
> >
>
>


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}";


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.


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.


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 <rve...@dotnetrdf.org> 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" <javedbtk...@gmail.com> 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
> >
> >
>
>
>
>
>
>


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
>
>


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();


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 <dave.e.reyno...@gmail.com>
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-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 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 )
>>
>>
>>


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
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-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 <javedbtk...@gmail.com>
> >> 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
> >>> <dave.e.reyno...@gmail.com>
> >>> 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, Se

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 <javedbtk...@gmail.com> 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 <javedbtk...@gmail.com> 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 <dave.e.reyno...@gmail.com
>> > 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 <javedbtk...@gmail.com> 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 <dave.e.reyno...@gmail.com>
> 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-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 <dave.e.reyno...@gmail.com>
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-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");
> >
> > }
> >
>
>


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");

}


  1   2   >