Duplicate entries produced by SPARQL query
Hi, I have the following RDF: http://www.w3.org/1999/02/22-rdf-syntax-ns#; xmlns:j.0="http://www.somelink.org/ofdf#;> http://www.somelink.org/ofdf#ticket/supplier-123/ticket-12345678;> ABCDEFG1_5#XYZ1 ABCDEFG1_5#20151208 ABCDEFG1_5#2015 ABCDEFG1_5#124.50 ABCDEFG2#20151104 ABCDEFG2#XYZ2 ABCDEFG2#124.50 ABCDEFG2#2015 and the following SPARQL query: String qs1 = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> " + "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> " + "PREFIX ticket: <http://www.lookouster.org/ofdf#> " + "SELECT ?lticket ?type ?bf1 ?cust1 ?tAmount1 ?dtCreation1 ?dtTravel1 ?bf2 ?cust2 ?tAmount2 ?dtCreation2 ?dtTravel2 " + "WHERE { " + "?lticket ticket:creditedToCust ?_cust1 .\n" + "?lticket ticket:creditedToCust ?_cust2 .\n" + "?lticket ticket:creditedFor?_tAmount1.\n" + "?lticket ticket:creditedFor?_tAmount2.\n" + "?lticket ticket:createdOnDate ?_dtCreation1 .\n" + "?lticket ticket:createdOnDate ?_dtCreation2 .\n" + "?lticket ticket:consumedOnDate ?_dtTravel1 .\n" + "?lticket ticket:consumedOnDate ?_dtTravel2 .\n" + "FILTER ( strafter( ?_cust1, '#') != strafter( ?_cust2, '#') ) .\n" + "FILTER ( strbefore( ?_cust1, '#') = strbefore( ?_tAmount1, '#') ) .\n" + "FILTER ( strbefore( ?_cust1, '#') = strbefore( ?_dtCreation1, '#') ) .\n" + "FILTER ( strbefore( ?_cust1, '#') = strbefore( ?_dtTravel1, '#') ) .\n" + "FILTER ( strbefore( ?_cust2, '#') = strbefore( ?_tAmount2, '#') ) .\n" + "FILTER ( strbefore( ?_cust2, '#') = strbefore( ?_dtCreation2, '#') ) .\n" + "FILTER ( strbefore( ?_cust2, '#') = strbefore( ?_dtTravel2, '#') ) .\n" + "FILTER ( strafter( ?_tAmount1, '#' ) = strafter( ?_tAmount2, '#' ) ) .\n" + "bind(strafter( ?_cust1, '#' ) as ?cust1) .\n" + "bind(strafter( ?_cust2, '#' ) as ?cust2) .\n" + "bind(strbefore( ?_cust1, '#' ) as ?bf1) .\n" + "bind(strbefore( ?_cust2, '#' ) as ?bf2) .\n" + "bind(strafter( ?_tAmount1, '#' ) as ?tAmount1) .\n" + "bind(strafter( ?_tAmount2, '#' ) as ?tAmount2) .\n" + "bind(strafter( ?_dtCreation1, '#' ) as ?dtCreation1) .\n" + "bind(strafter( ?_dtCreation2, '#' ) as ?dtCreation2) .\n" + "bind(strafter( ?_dtTravel1, '#' ) as ?dtTravel1) .\n" + "bind(strafter( ?_dtTravel2, '#' ) as ?dtTravel2) .\n" + "values ?type { '2x Credit Notes' } .\n" + "} ORDER BY ?lticket ?dtCreation1 " ; The query ran well, but return the following 2 lines: lticket,type,bf1,cust1,tAmount1,dtCreation1,dtTravel1,bf2,cust2,tAmount2,dtCreation2,dtTravel2 http://www.somelink.org/ofdf#ticket/supplier-123/ticket-12345678,2x Credit Notes,ABCDEFG2,XYZ2,124.50,20151104,2015,ABCDEFG1,XYZ1,124.50,20151208,2015 http://www.somelink.org/ofdf#ticket/supplier-123/ticket-12345678,2x Credit Notes,ABCDEFG1,XYZ1,124.50,20151208,2015,ABCDEFG2,XYZ2,124.50,20151104,2015 How do I manage to only output one line, given that the two lines are just inverted ? Thank you for your help. -- Best Regards Lookman SANNI
Re: Use variable in SPARQL query
Hi Tina, You can have your query stored in a composed java string (e.g. String query = "Select blablabla where { ?emp rdf:type " + someJavaVariable + "}" Hope that helps Le 1 nov. 2016 17:02, "tina sani"a écrit : > Hello. > > How can I use a Java variable in the SPARQL query. > ?emp rdf:type ?SomeVariable > > I want rdf:type of Managers and Technicals while these two values(Managers > and Technicals) are in my Java variable: employee. > > So I need something like: > > ?emp rdf:type "employee" > > Regards >
Re: Convert string to float in a SPARQL query
I am trying to convert some text values to numeric so that I can compare their absolute values. Hopefully it is clearer. Le 16 sept. 2016 00:01, "A. Soroka" <aj...@virginia.edu> a écrit : > https://stackoverflow.com/help/mcve > > What data are you using? What is the complete action you are exercising? > What results do you expect? What results do you get? > > --- > A. Soroka > The University of Virginia Library > > > On Sep 15, 2016, at 5:56 PM, lookman sanni <lookous...@gmail.com> wrote: > > > > Hi all, > > > > I am trying to perform a filter in a SPARQL query, through the below > code: > > > > FILTER ( abs(xsd:float(?tAmount1)) = abs(xsd:float(?tAmount2)) ) > > > > The query is being parsed correctly, but I am not getting the expected > > result. Any clue why this would not convert and compare those amounts > > properly ? The amounts are formatted like this: "+8644,00". > > > > Thanks in advance for the help. > > > > -- > > Best Regards > > > > Lookman SANNI > >
Convert string to float in a SPARQL query
Hi all, I am trying to perform a filter in a SPARQL query, through the below code: FILTER ( abs(xsd:float(?tAmount1)) = abs(xsd:float(?tAmount2)) ) The query is being parsed correctly, but I am not getting the expected result. Any clue why this would not convert and compare those amounts properly ? The amounts are formatted like this: "+8644,00". Thanks in advance for the help. -- Best Regards Lookman SANNI
Re: Writing Jena Model to CSV
Thanks. That is what I did finally...laying the data down as wanted from a ResultSet. Rgds, On Thu, Sep 8, 2016 at 9:27 AM, Nikolaos Beredimas <bere...@gmail.com> wrote: > CSV is not a valid RDF serialization format as mentioned (only as a format > for SPARQL results). > > If you want something similar to CSV for serializing an RDF Model, try > using N-triples. > > On Thu, Sep 8, 2016 at 10:22 AM, Martynas Jusevičius < > marty...@graphity.org> > wrote: > > > I think CSV is for writing ResultSet (SELECT results), not Model > > (CONSTRUCT/DESCRIBE results). > > > > On Wed, 7 Sep 2016 at 23:37, lookman sanni <lookous...@gmail.com> wrote: > > > > > Hi all, > > > > > > I am trying in vain to write a Jena model to a text file using > > > RDFDataMgr.write(outputstream, dataset2, lang). > > > > > > This works well for Lang such as RDFXML, TRIG, TURTLE, NQUADS. However > > for > > > Lang.CSV, it is firing a RiotException of which I have no idea: > > > > > > > > > *Exception in thread "main" org.apache.jena.riot.RiotException: No > graph > > > writer for null* > > > * at > > > org.apache.jena.riot.RDFDataMgr.createGraphWriter$( > > RDFDataMgr.java:1199)* > > > * at org.apache.jena.riot.RDFDataMgr.write$(RDFDataMgr.java:1211)* > > > * at org.apache.jena.riot.RDFDataMgr.write(RDFDataMgr.java:1004)* > > > * at org.apache.jena.riot.RDFDataMgr.write(RDFDataMgr.java:995)* > > > * at org.apache.jena.riot.RDFDataMgr.write(RDFDataMgr.java:936)* > > > * at * > > > > > > Has anyone come across this in the past and has some hints on its > why/how > > > to solve it ? > > > > > > Thanks, Lookman > > > > > > -- > > > Best Regards > > > > > > Lookman SANNI > > > > > > -- Best Regards Lookman SANNI
Writing Jena Model to CSV
Hi all, I am trying in vain to write a Jena model to a text file using RDFDataMgr.write(outputstream, dataset2, lang). This works well for Lang such as RDFXML, TRIG, TURTLE, NQUADS. However for Lang.CSV, it is firing a RiotException of which I have no idea: *Exception in thread "main" org.apache.jena.riot.RiotException: No graph writer for null* * at org.apache.jena.riot.RDFDataMgr.createGraphWriter$(RDFDataMgr.java:1199)* * at org.apache.jena.riot.RDFDataMgr.write$(RDFDataMgr.java:1211)* * at org.apache.jena.riot.RDFDataMgr.write(RDFDataMgr.java:1004)* * at org.apache.jena.riot.RDFDataMgr.write(RDFDataMgr.java:995)* * at org.apache.jena.riot.RDFDataMgr.write(RDFDataMgr.java:936)* * at * Has anyone come across this in the past and has some hints on its why/how to solve it ? Thanks, Lookman -- Best Regards Lookman SANNI
Re: Jena Rules Definition
Ok Dave. Here is a minimal example: *Java Code* String rdfPath = "dataset/rdf/sample.rdf"; String inRuleBase = "rules/sampleRule.txt"; Model model = ModelFactory.createDefaultModel(); FileInputStream fis = new FileInputStream(rdfPath); model.read(fis,"ticket"); Reasoner reasoner = new GenericRuleReasoner( Rule.rulesFromURL(inRuleBase)); InfModel infModel = ModelFactory.createInfModel( reasoner, model ); StmtIterator si = infModel.listStatements(); while ( si.hasNext() ) { Statement stmt = si.nextStatement(); Resource subject = stmt.getSubject(); Property predicate = stmt.getPredicate(); RDFNode object = stmt.getObject(); System.out.println(subject.toString() + " " + predicate.toString() + " " + object.toString()); } *RDF File** (sample.rdf)* http://www.w3.org/1999/02/22-rdf-syntax-ns#; xmlns:aa=" http://www.abcd.org/ofdf#; xmlns:owl="http://www.w3.org/2002/07/owl#; xmlns:html="http://www.w3.org/1999/xhtml; xmlns:rdfs=" http://www.w3.org/2000/01/rdf-schema#;> http://www.abcd.org/ofdf#folder;> http://www.abcd.org/ofdf#file;> http://www.abcd.org/ofdf#folder/001;> MisterX http://www.abcd.org/ofdf#folder"/> http://www.abcd.org/ofdf#file/AAA;> http://www.abcd.org/ofdf#folder/001 http://www.abcd.org/ofdf#file"/> http://www.abcd.org/ofdf#folder/002;> MisterY http://www.abcd.org/ofdf#folder"/> http://www.abcd.org/ofdf#file/AAA;> http://www.abcd.org/ofdf#folder/002 http://www.abcd.org/ofdf#file"/> http://www.abcd.org/ofdf#file/BBB;> http://www.abcd.org/ofdf#folder/002 http://www.abcd.org/ofdf#file"/> *Rule** (**sampleRule.txt)* @prefix aa: <http://www.abcd.org/ofdf#>. @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>. @prefix owl: <http://www.w3.org/2002/07/owl#>. @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>. @prefix owl: <http://www.w3.org/2002/07/owl#>. [ruleX: (?file1 aa:processedIn ?fld1) (?file1 aa:processedIn ?fld2) notEqual(?fld1, ?fld2) (?fld1 aa:createdBy ?auth1) (?fld2 aa:createdBy ?auth2) notEqual(?auth1, ?auth2) -> (?file1 rdf:type aa:fileRequiringConflictCheck) ] [ruleY: (?file1 aa:processedIn ?fld1) (?file1 aa:processedIn ?fld2) notEqual(?fld1, ?fld2) -> (?file1 rdf:type aa:fileInManyFolders) ] RuleY is properly recognized and I can see the following statement added to the Inference model: *http://www.abcd.org/ofdf#file/AAA <http://www.abcd.org/ofdf#file/AAA> http://www.w3.org/1999/02/22-rdf-syntax-ns#type <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> http://www.abcd.org/ofdf#fileInManyFolders <http://www.abcd.org/ofdf#fileInManyFolders>* Nothing however for ruleX and this is what I struggle with. Thanks in advance for the help. On Sun, Aug 21, 2016 at 3:44 PM, Dave Reynolds <dave.e.reyno...@gmail.com> wrote: > On 21/08/16 12:37, lookman sanni wrote: > >> Hi all, >> >> I am struggling with the definition of jena rules. I have an RDF file >> where >> I am defining: >> >>- a "folder" class with a property "createdBy" >>- a "file" class with a property "processedIn" of type "folder" >> >> My RDF file contains resources from the two classes. I am trying to define >> a Jena rule for querying files appearing in more than a folder, having >> different authors. >> >> To that end, I added to my RDF the specification of a class >> "fileRequiringConflictCheck" a subclass of the class "file" and then >> specified the following jena rule: >> >> [ruleX: >> (?file1 aa:processedIn ?fld2) >> (?file1 aa:processedIn ?fld1) >> notEqual(?fld1, ?fld2) >> (?fld1 aa:createdBy ?auth1) >> (?fld2 aa:createdBy ?auth2) >> notEqual(?auth1, ?auth2) >> -> >> (?file1 rdf:type aa:fileRequiringConflictCheck) >> ] >> >> Outcome is that the rule is likely never met whenever expected as per my >> sample dataset. Any idea what I might be missing ? >> > > Looks reasonable, check your namespaces are correct. If you can't get it > working then post a minimal example of the data and someone might be able > to spot the problem. > > Dave > > -- Best Regards Lookman SANNI
Jena Rules Definition
Hi all, I am struggling with the definition of jena rules. I have an RDF file where I am defining: - a "folder" class with a property "createdBy" - a "file" class with a property "processedIn" of type "folder" My RDF file contains resources from the two classes. I am trying to define a Jena rule for querying files appearing in more than a folder, having different authors. To that end, I added to my RDF the specification of a class "fileRequiringConflictCheck" a subclass of the class "file" and then specified the following jena rule: [ruleX: (?file1 aa:processedIn ?fld2) (?file1 aa:processedIn ?fld1) notEqual(?fld1, ?fld2) (?fld1 aa:createdBy ?auth1) (?fld2 aa:createdBy ?auth2) notEqual(?auth1, ?auth2) -> (?file1 rdf:type aa:fileRequiringConflictCheck) ] Outcome is that the rule is likely never met whenever expected as per my sample dataset. Any idea what I might be missing ? Thank you. -- Best Regards Lookman SANNI
Re: Out Of Memory Error at Statement Addition
You got me right Andy, I am trying to read a large RDF/XML into a memory model. I will experiment TDB as well. Thank you. On Thu, Aug 11, 2016 at 2:37 PM, Andy Seaborne <a...@apache.org> wrote: > Hi - the description doesn't say what your doing. Are you reading a large > RDF/XML file into a memory model? > > If so: > > 1/ More RAM. if you are using a memory model, then large data means more > heap needed. > > But parsing RDF/XML is not fast anyway so ... > > 2/ Load into a database such as TDB > > Parse once. Use many times. > > Andy > > > > On 11/08/16 08:34, lookman sanni wrote: > >> Finally works, with a heap size increased to 3072. Any other alternative ? >> >> Thanks. >> >> >> On Wed, Aug 10, 2016 at 11:49 PM, lookman sanni <lookous...@gmail.com> >> wrote: >> >> Hi all, >>> >>> I am trying to add statements to a default model from a self generated >>> RDF >>> file (5.3 million of lines) though a simple: model.read( >>> fileinputstream,base). >>> >>> However, I am getting a Garbage Collector overhead limit exceeded error >>> 'see below). Is it something anyone has come across before ? I have tried >>> adding run arguments to increase heap size, but it does not seem to be >>> effective. >>> >>> Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit >>> exceeded >>> at java.util.Arrays.copyOfRange(Unknown Source) >>> at java.lang.String.(Unknown Source) >>> at org.apache.jena.iri.impl.LexerPath.yytext(LexerPath.java:420) >>> at org.apache.jena.iri.impl.AbsLexer.rule(AbsLexer.java:81) >>> at org.apache.jena.iri.impl.LexerPath.yylex(LexerPath.java:689) >>> at org.apache.jena.iri.impl.AbsLexer.analyse(AbsLexer.java:52) >>> at org.apache.jena.iri.impl.Parser.(Parser.java:108) >>> at org.apache.jena.iri.impl.IRIImpl.(IRIImpl.java:65) >>> at org.apache.jena.iri.impl.AbsIRIFactoryImpl.create( >>> AbsIRIFactoryImpl.java:40) >>> at org.apache.jena.iri.impl.IRIFactoryImpl.create(IRIFactoryImp >>> l.java:264) >>> at org.apache.jena.rdfxml.xmlinput.impl.URIReference. >>> fromQName(URIReference.java:180) >>> at org.apache.jena.rdfxml.xmlinput.states.WantPropertyElement. >>> startElement(WantPropertyElement.java:65) >>> at org.apache.jena.rdfxml.xmlinput.impl.XMLHandler. >>> startElement(XMLHandler.java:111) >>> at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown >>> Source) >>> at org.apache.xerces.impl.XMLNamespaceBinder.handleStartElement(Unknown >>> Source) >>> at org.apache.xerces.impl.XMLNamespaceBinder.startElement(Unknown >>> Source) >>> at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl. >>> scanStartElement(Unknown >>> Source) >>> at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl >>> $FragmentContentDispatcher.dispatch(Unknown Source) >>> at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl. >>> scanDocument(Unknown >>> Source) >>> at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source) >>> at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source) >>> at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) >>> at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) >>> at org.apache.jena.rdfxml.xmlinput.impl.RDFXMLParser. >>> parse(RDFXMLParser.java:150) >>> at org.apache.jena.rdfxml.xmlinput.ARP.load(ARP.java:118) >>> at org.apache.jena.riot.lang.LangRDFXML.parse(LangRDFXML.java:142) >>> at org.apache.jena.riot.RDFParserRegistry$ReaderRIOTLang.read( >>> RDFParserRegistry.java:179) >>> at org.apache.jena.riot.RDFDataMgr.process(RDFDataMgr.java:861) >>> at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:259) >>> at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:245) >>> at org.apache.jena.riot.adapters.RDFReaderRIOT.read(RDFReaderRI >>> OT.java:69) >>> at org.apache.jena.rdf.model.impl.ModelCom.read(ModelCom.java:251) >>> >>> >>> Thanks in advance for any help. >>> >>> -- >>> Best Regards >>> >>> Lookman SANNI >>> >>> >> >> >> > -- Best Regards Lookman SANNI
Re: Out Of Memory Error at Statement Addition
Finally works, with a heap size increased to 3072. Any other alternative ? Thanks. On Wed, Aug 10, 2016 at 11:49 PM, lookman sanni <lookous...@gmail.com> wrote: > Hi all, > > I am trying to add statements to a default model from a self generated RDF > file (5.3 million of lines) though a simple: model.read( > fileinputstream,base). > > However, I am getting a Garbage Collector overhead limit exceeded error > 'see below). Is it something anyone has come across before ? I have tried > adding run arguments to increase heap size, but it does not seem to be > effective. > > Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit > exceeded > at java.util.Arrays.copyOfRange(Unknown Source) > at java.lang.String.(Unknown Source) > at org.apache.jena.iri.impl.LexerPath.yytext(LexerPath.java:420) > at org.apache.jena.iri.impl.AbsLexer.rule(AbsLexer.java:81) > at org.apache.jena.iri.impl.LexerPath.yylex(LexerPath.java:689) > at org.apache.jena.iri.impl.AbsLexer.analyse(AbsLexer.java:52) > at org.apache.jena.iri.impl.Parser.(Parser.java:108) > at org.apache.jena.iri.impl.IRIImpl.(IRIImpl.java:65) > at org.apache.jena.iri.impl.AbsIRIFactoryImpl.create( > AbsIRIFactoryImpl.java:40) > at org.apache.jena.iri.impl.IRIFactoryImpl.create(IRIFactoryImpl.java:264) > at org.apache.jena.rdfxml.xmlinput.impl.URIReference. > fromQName(URIReference.java:180) > at org.apache.jena.rdfxml.xmlinput.states.WantPropertyElement. > startElement(WantPropertyElement.java:65) > at org.apache.jena.rdfxml.xmlinput.impl.XMLHandler. > startElement(XMLHandler.java:111) > at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown > Source) > at org.apache.xerces.impl.XMLNamespaceBinder.handleStartElement(Unknown > Source) > at org.apache.xerces.impl.XMLNamespaceBinder.startElement(Unknown Source) > at > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown > Source) > at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl > $FragmentContentDispatcher.dispatch(Unknown Source) > at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown > Source) > at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source) > at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source) > at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) > at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) > at org.apache.jena.rdfxml.xmlinput.impl.RDFXMLParser. > parse(RDFXMLParser.java:150) > at org.apache.jena.rdfxml.xmlinput.ARP.load(ARP.java:118) > at org.apache.jena.riot.lang.LangRDFXML.parse(LangRDFXML.java:142) > at org.apache.jena.riot.RDFParserRegistry$ReaderRIOTLang.read( > RDFParserRegistry.java:179) > at org.apache.jena.riot.RDFDataMgr.process(RDFDataMgr.java:861) > at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:259) > at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:245) > at org.apache.jena.riot.adapters.RDFReaderRIOT.read(RDFReaderRIOT.java:69) > at org.apache.jena.rdf.model.impl.ModelCom.read(ModelCom.java:251) > > > Thanks in advance for any help. > > -- > Best Regards > > Lookman SANNI > -- Best Regards Lookman SANNI
Out Of Memory Error at Statement Addition
Hi all, I am trying to add statements to a default model from a self generated RDF file (5.3 million of lines) though a simple: model.read(fileinputstream,base). However, I am getting a Garbage Collector overhead limit exceeded error 'see below). Is it something anyone has come across before ? I have tried adding run arguments to increase heap size, but it does not seem to be effective. Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded at java.util.Arrays.copyOfRange(Unknown Source) at java.lang.String.(Unknown Source) at org.apache.jena.iri.impl.LexerPath.yytext(LexerPath.java:420) at org.apache.jena.iri.impl.AbsLexer.rule(AbsLexer.java:81) at org.apache.jena.iri.impl.LexerPath.yylex(LexerPath.java:689) at org.apache.jena.iri.impl.AbsLexer.analyse(AbsLexer.java:52) at org.apache.jena.iri.impl.Parser.(Parser.java:108) at org.apache.jena.iri.impl.IRIImpl.(IRIImpl.java:65) at org.apache.jena.iri.impl.AbsIRIFactoryImpl.create(AbsIRIFactoryImpl.java:40) at org.apache.jena.iri.impl.IRIFactoryImpl.create(IRIFactoryImpl.java:264) at org.apache.jena.rdfxml.xmlinput.impl.URIReference.fromQName(URIReference.java:180) at org.apache.jena.rdfxml.xmlinput.states.WantPropertyElement.startElement(WantPropertyElement.java:65) at org.apache.jena.rdfxml.xmlinput.impl.XMLHandler.startElement(XMLHandler.java:111) at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source) at org.apache.xerces.impl.XMLNamespaceBinder.handleStartElement(Unknown Source) at org.apache.xerces.impl.XMLNamespaceBinder.startElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source) at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at org.apache.jena.rdfxml.xmlinput.impl.RDFXMLParser.parse(RDFXMLParser.java:150) at org.apache.jena.rdfxml.xmlinput.ARP.load(ARP.java:118) at org.apache.jena.riot.lang.LangRDFXML.parse(LangRDFXML.java:142) at org.apache.jena.riot.RDFParserRegistry$ReaderRIOTLang.read(RDFParserRegistry.java:179) at org.apache.jena.riot.RDFDataMgr.process(RDFDataMgr.java:861) at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:259) at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:245) at org.apache.jena.riot.adapters.RDFReaderRIOT.read(RDFReaderRIOT.java:69) at org.apache.jena.rdf.model.impl.ModelCom.read(ModelCom.java:251) Thanks in advance for any help. -- Best Regards Lookman SANNI
Re: Notation 3 Rule specification
Thank you Niels, you made my day with the notEqual() function. The built-in primitives page that you suggested is a gold mine. @Dave: Jena does support N3 rules On Thu, Aug 4, 2016 at 8:06 PM, Niels Andersen <ni...@thinkiq.com> wrote: > Here is how I would do it: > > > > [RuleMotherMutipleBirths: (?person rdf:Type ex:FemalePerson) (?parent > ex:person_Child ?Child1) (?parent ex:person_Child ?Child2) > notEqual(?Child1,?Child2) (?Child1 ex:person_Birthday ?ChildBirthday) > (?Child2 ex:person_ Birthday? ChildBirthday) > > -> (?parent ex:person_ChildrenType ex:HasMultipleBirth) (?Child1 > ex:sameBirth ?Child2) (?Child2 ex: sameBirth ?Child1)] > > > > A couple of things to watch out for here: > > · This rule will cover any multi berth situation (twins, triplets, > etc) > > · The kids must come from the same birth, not just have the same > birthday or age. Therefore the parent must be a female. > > · The rule will not work if the twins are born on two different > days. > > · Not sure the word Birth is the right one, try to find a better > one. > > > > Look at https://jena.apache.org/documentation/inference/# > builtin-primitives for inspiration. > > > > Now you can write a rule that shows that a man has twins. I’ll leave that > for you to try. > > > > Niels > > > > > > -Original Message- > > From: lookman sanni [mailto:lookous...@gmail.com] > > Sent: Wednesday, August 3, 2016 22:55 > > To: users@jena.apache.org > > Subject: RE: Notation 3 Rule specification > > > > Thanks Niels for the reply. > > > > [AgeRule: (?person1 ex:person_Age ?age) (?person2 ex:person_Age ?age) -> > > (?person1 ex:sameAge ?person2)] works fine for the purpose. > > > > Now let's assume that person1 has two properties: sonAge and daughterAge > and I would like to infer a rule like person1 hasTwins. How would I write > it ? > > > > Thanks, Lookman > > Le 4 août 2016 06:42, "Niels Andersen" <ni...@thinkiq.com> a écrit : > > > > > A general recommendation, please make sure that the properties that > > > you choose clearly describes the direction of the relationship. It is > > > not clear if ?f or ?a is the father. > > > > > > There are probably a million opinions about how to do this, my general > > > recommendation is to create properties that show the class to the left > > > and the relationship to the right, so ?a ex:person_Father ?b would > > > mean that ?a's father is ?b. It also makes it clear that the domain of > > > ex:person_Father is ex:Person and the range of ex:person_Father is > > > ex:Father. > > > > > > Not sure if I understand your question, but you could do the following > > > to compare ages > > > [AgeRule: (?person1 ex:person_Age ?age) (?person2 ex:person_Age ?age) > > > -> > > > (?person1 ex:sameAge ?person2)] > > > > > > This rule would only trigger if both ?person1 and ?person2 are the > > > same age. > > > > > > More specifically you could say: > > > > > > [UncleRule: (?person experson_Father ?father) (?father > > > ex:person_Brother > > > ?uncle) -> (?person ex:person_Uncle ?uncle)] > > > [UncleAgeRule: (?person1 ex:person_Uncle ?person2) (?person1 > > > ex:person_Age > > > ?age) (?person2 ex:person_Age ?age) -> (?person1 > > > ex:hasUncleWithSameAge ?person2)] > > > > > > Not sure why you would do that, but it is just an example. > > > > > > Niels > > > > > > > > > -Original Message- > > > From: lookman sanni [mailto:lookous...@gmail.com] > > > Sent: Wednesday, August 3, 2016 20:37 > > > To: users@jena.apache.org > > > Subject: Notation 3 Rule specification > > > > > > Hi all, > > > > > > I am beginning with Jena and I struggle with the specification of a > > > rule that would help infer new statements. > > > > > > More concretely, I would like to know how to compare values of > > > different properties of a same resource in a rule file, following the n3 > syntax. > > > > > > E.g. [rule1: (?f pre:father ?a) (?u pre:brother ?f) -> (?u pre:uncle > > > ?a)] > > > > > > If we assume f and u have a property age and I would like to test > > > whether that property has the same value or not for both, how would I do > it ? > > > > > > Thanks, Lookman > > > > -- Best Regards Lookman SANNI
RE: Notation 3 Rule specification
Thanks Niels for the reply. [AgeRule: (?person1 ex:person_Age ?age) (?person2 ex:person_Age ?age) -> (?person1 ex:sameAge ?person2)] works fine for the purpose. Now let's assume that person1 has two properties: sonAge and daughterAge and I would like to infer a rule like person1 hasTwins. How would I write it ? Thanks, Lookman Le 4 août 2016 06:42, "Niels Andersen" <ni...@thinkiq.com> a écrit : > A general recommendation, please make sure that the properties that you > choose clearly describes the direction of the relationship. It is not clear > if ?f or ?a is the father. > > There are probably a million opinions about how to do this, my general > recommendation is to create properties that show the class to the left and > the relationship to the right, so ?a ex:person_Father ?b would mean that > ?a's father is ?b. It also makes it clear that the domain of > ex:person_Father is ex:Person and the range of ex:person_Father is > ex:Father. > > Not sure if I understand your question, but you could do the following to > compare ages > [AgeRule: (?person1 ex:person_Age ?age) (?person2 ex:person_Age ?age) -> > (?person1 ex:sameAge ?person2)] > > This rule would only trigger if both ?person1 and ?person2 are the same > age. > > More specifically you could say: > > [UncleRule: (?person experson_Father ?father) (?father ex:person_Brother > ?uncle) -> (?person ex:person_Uncle ?uncle)] > [UncleAgeRule: (?person1 ex:person_Uncle ?person2) (?person1 ex:person_Age > ?age) (?person2 ex:person_Age ?age) -> (?person1 ex:hasUncleWithSameAge > ?person2)] > > Not sure why you would do that, but it is just an example. > > Niels > > > -Original Message- > From: lookman sanni [mailto:lookous...@gmail.com] > Sent: Wednesday, August 3, 2016 20:37 > To: users@jena.apache.org > Subject: Notation 3 Rule specification > > Hi all, > > I am beginning with Jena and I struggle with the specification of a rule > that would help infer new statements. > > More concretely, I would like to know how to compare values of different > properties of a same resource in a rule file, following the n3 syntax. > > E.g. [rule1: (?f pre:father ?a) (?u pre:brother ?f) -> (?u pre:uncle ?a)] > > If we assume f and u have a property age and I would like to test whether > that property has the same value or not for both, how would I do it ? > > Thanks, Lookman >
Notation 3 Rule specification
Hi all, I am beginning with Jena and I struggle with the specification of a rule that would help infer new statements. More concretely, I would like to know how to compare values of different properties of a same resource in a rule file, following the n3 syntax. E.g. [rule1: (?f pre:father ?a) (?u pre:brother ?f) -> (?u pre:uncle ?a)] If we assume f and u have a property age and I would like to test whether that property has the same value or not for both, how would I do it ? Thanks, Lookman