You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Benson Margulies <bi...@gmail.com> on 2010/12/10 17:39:42 UTC

sparql versus ^^ types

Protege persuaded me to put types in my Ontology. So (as viewed by
tdbdump), I have quads like:

<urn:basistech.com:analysis#9>
<http://www.basistech.com/ontologies/2010/6/rex.owl#hasOriginalText>
"Fredrick Chopin"^^<http://www.w3.org/2001/XMLSchema#string>
<urn:misc-test> .

should the following sparql match that?

SELECT ?x where { ?x
<http://www.basistech.com/ontologies/2010/6/rex.owl#hasOriginalText>
"Fredrick Chopin" }

Re: sparql versus ^^ types

Posted by Benson Margulies <bi...@gmail.com>.
I'm going to ditch all the types. I don't have any reason for them.

On Fri, Dec 10, 2010 at 11:53 AM, Andy Seaborne
<an...@epimorphics.com> wrote:
>
>
> On 10/12/10 16:39, Benson Margulies wrote:
>>
>> Protege persuaded me to put types in my Ontology. So (as viewed by
>> tdbdump), I have quads like:
>>
>> <urn:basistech.com:analysis#9>
>> <http://www.basistech.com/ontologies/2010/6/rex.owl#hasOriginalText>
>> "Fredrick Chopin"^^<http://www.w3.org/2001/XMLSchema#string>
>> <urn:misc-test>  .
>>
>> should the following sparql match that?
>>
>> SELECT ?x where { ?x
>> <http://www.basistech.com/ontologies/2010/6/rex.owl#hasOriginalText>
>> "Fredrick Chopin" }
>
> Not in TDB.  Simple literals (plain literals without language tag) do not
> match xsd:string.
>
> SELECT ?x where { ?x
>   <http://www.basistech.com/ontologies/2010/6/rex.owl#hasOriginalText>
>   "Fredrick Chopin"^^xsd:string
> }
>
> TDB could canonicalise the input to make "" and ""^^xsd:string the same.
>
>        Andy
>

Re: sparql versus ^^ types

Posted by Benson Margulies <bi...@gmail.com>.
The e.g. is a line of output from tdbdump.  How's this for a proposal
... I'll turn this code into a self-contained example, with an
ontology, a run of schemagen, producing an instance, loading it into
tdb, and querying it.



On Fri, Dec 10, 2010 at 2:43 PM, Ian Dickinson <ia...@epimorphics.com> wrote:
> Hi Benson,
>
> On 10/12/10 19:30, Benson Margulies wrote:
>>
>> OK, the RDF/XML and the tdbdump output both look rational. But I still
>> don't get anything when I query.
>
> Providing a complete example or test case would make it much easier to give
> further suggestions.
>
>> Would you all like this morphed into a sample when it finally works?
>> I'll hang it off of a JIRA.
>
> We've talked briefly about the need for a general documentation overhall,
> possibly migrating the current offline documentation into a wiki. Having
> extra material for that process in Jira certainly wouldn't hurt.
>
>> (e.g.)
>> <urn:basistech.com:analysis#4>
>> <http://www.basistech.com/ontologies/2010/6/rex.owl#hasOriginalText>
>> "Mark Twain"<urn:misc-test>  .
>
> I'm not sure what this is an e.g. of
>
> Ian
>
> --
> ____________________________________________________________
> Ian Dickinson                   Epimorphics Ltd, Bristol, UK
> mailto:ian@epimorphics.com        http://www.epimorphics.com
> cell: +44-7786-850536              landline: +44-1275-399069
> ------------------------------------------------------------
> Epimorphics Ltd.  is a limited company registered in England
> (no. 7016688). Registered address: Court Lodge, 105 High St,
>              Portishead, Bristol BS20 6PT, UK
>
>

Re: sparql versus ^^ types

Posted by Ian Dickinson <ia...@epimorphics.com>.
Hi Benson,

On 10/12/10 19:30, Benson Margulies wrote:
> OK, the RDF/XML and the tdbdump output both look rational. But I still
> don't get anything when I query.
Providing a complete example or test case would make it much easier to 
give further suggestions.

> Would you all like this morphed into a sample when it finally works?
> I'll hang it off of a JIRA.
We've talked briefly about the need for a general documentation 
overhall, possibly migrating the current offline documentation into a 
wiki. Having extra material for that process in Jira certainly wouldn't 
hurt.

> (e.g.)
> <urn:basistech.com:analysis#4>
> <http://www.basistech.com/ontologies/2010/6/rex.owl#hasOriginalText>
> "Mark Twain"<urn:misc-test>  .
I'm not sure what this is an e.g. of

Ian

-- 
____________________________________________________________
Ian Dickinson                   Epimorphics Ltd, Bristol, UK
mailto:ian@epimorphics.com        http://www.epimorphics.com
cell: +44-7786-850536              landline: +44-1275-399069
------------------------------------------------------------
Epimorphics Ltd.  is a limited company registered in England
(no. 7016688). Registered address: Court Lodge, 105 High St,
               Portishead, Bristol BS20 6PT, UK


Re: sparql versus ^^ types

Posted by Benson Margulies <bi...@gmail.com>.
OK, the RDF/XML and the tdbdump output both look rational. But I still
don't get anything when I query.

Would you all like this morphed into a sample when it finally works?
I'll hang it off of a JIRA.

(e.g.)


<urn:basistech.com:analysis#4>
<http://www.basistech.com/ontologies/2010/6/rex.owl#hasOriginalText>
"Mark Twain" <urn:misc-test> .



On Fri, Dec 10, 2010 at 2:22 PM, Ian Dickinson <ia...@epimorphics.com> wrote:
> On 10/12/10 19:09, Benson Margulies wrote:
>>
>> I'm having trouble putting my hands on createPlainLiteral. I see it in
>> ResourceFactory, but not model. Do I just call it from there.
>
> Sorry, it's Model.createLiteral()
>
> In Days of Yore, when Jena was first created, there were only plain
> literals. Later, when we added support for typed literals, and hence
> Model.createTypedLiteral(), we didn't change the name of createLiteral() to
> facilitate backwards compatibility.
>
> Ian
>
>
> --
> ____________________________________________________________
> Ian Dickinson                   Epimorphics Ltd, Bristol, UK
> mailto:ian@epimorphics.com        http://www.epimorphics.com
> cell: +44-7786-850536              landline: +44-1275-399069
> ------------------------------------------------------------
> Epimorphics Ltd.  is a limited company registered in England
> (no. 7016688). Registered address: Court Lodge, 105 High St,
>              Portishead, Bristol BS20 6PT, UK
>
>

Re: sparql versus ^^ types

Posted by Ian Dickinson <ia...@epimorphics.com>.
On 10/12/10 19:09, Benson Margulies wrote:
> I'm having trouble putting my hands on createPlainLiteral. I see it in
> ResourceFactory, but not model. Do I just call it from there.
Sorry, it's Model.createLiteral()

In Days of Yore, when Jena was first created, there were only plain 
literals. Later, when we added support for typed literals, and hence 
Model.createTypedLiteral(), we didn't change the name of createLiteral() 
to facilitate backwards compatibility.

Ian


-- 
____________________________________________________________
Ian Dickinson                   Epimorphics Ltd, Bristol, UK
mailto:ian@epimorphics.com        http://www.epimorphics.com
cell: +44-7786-850536              landline: +44-1275-399069
------------------------------------------------------------
Epimorphics Ltd.  is a limited company registered in England
(no. 7016688). Registered address: Court Lodge, 105 High St,
               Portishead, Bristol BS20 6PT, UK


Re: sparql versus ^^ types

Posted by Benson Margulies <bi...@gmail.com>.
I answered the below for myself in the affirmative.

On Fri, Dec 10, 2010 at 2:09 PM, Benson Margulies <bi...@gmail.com> wrote:
> I'm having trouble putting my hands on createPlainLiteral. I see it in
> ResourceFactory, but not model. Do I just call it from there.

Re: sparql versus ^^ types

Posted by Benson Margulies <bi...@gmail.com>.
I'm having trouble putting my hands on createPlainLiteral. I see it in
ResourceFactory, but not model. Do I just call it from there.

On Fri, Dec 10, 2010 at 1:38 PM, Ian Dickinson <ia...@epimorphics.com> wrote:
> Hi Benson,
>
> On 10/12/10 18:18, Benson Margulies wrote:
>>
>> To be clearer, the resulting OWL RDF has
>> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
>>  attributes, and then tdbdump shows ^^ suffixes.
>>
>> On Fri, Dec 10, 2010 at 12:20 PM, Benson Margulies
>> <bi...@gmail.com>  wrote:
>>>
>>> Andy,
>>>
>>> I'm having trouble getting rid of all my ^^ noise.
>>>
>>> I run Jena schemagen against an Ontology that has no type annotations,
>>> I don't see any in the output of schemagen, but calls to
>>>
>>>  entityRef = model.createIndividual(entityUri, oclass);
>>>            entityRef.addLiteral(Rex.hasEntityDetectionSource, source);
>>>            entityRef.addLiteral(Rex.hasNormalizedText, normalizedText);
>>>            entityRef.addLiteral(Rex.hasOriginalText, rawText);
>>>
>>> end up adding the ^^ and the string data type.
>
> If you look at the Javadoc for Resource.addLiteral, there's no overloaded
> type signature for addLiteral( Property, String ). Which means that you're
> actually invoking this method:
>
> http://openjena.org/javadoc/com/hp/hpl/jena/rdf/model/Resource.html#addLiteral(com.hp.hpl.jena.rdf.model.Property,%20java.lang.Object)
>
> which says:
>
> """
> Add the property p with the typed-literal value o to this resource, ie add
> (this, p, typed(o)) to this's model. Answer this resource. The typed literal
> is equal to one constructed by using this.getModel().createTypedLiteral(o).
> """
>
> You want either:
>
> entityRef.addProperty(Rex.hasEntityDetectionSource, source);
>
> or
>
> entityRef.addLiteral(Rex.hasEntityDetectionSource, model.createPlainLiteral(
> source ));
>
> Ian
>

Re: sparql versus ^^ types

Posted by Ian Dickinson <ia...@epimorphics.com>.
Hi Benson,

On 10/12/10 18:18, Benson Margulies wrote:
> To be clearer, the resulting OWL RDF has
> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
>   attributes, and then tdbdump shows ^^ suffixes.
>
> On Fri, Dec 10, 2010 at 12:20 PM, Benson Margulies
> <bi...@gmail.com>  wrote:
>> Andy,
>>
>> I'm having trouble getting rid of all my ^^ noise.
>>
>> I run Jena schemagen against an Ontology that has no type annotations,
>> I don't see any in the output of schemagen, but calls to
>>
>>   entityRef = model.createIndividual(entityUri, oclass);
>>             entityRef.addLiteral(Rex.hasEntityDetectionSource, source);
>>             entityRef.addLiteral(Rex.hasNormalizedText, normalizedText);
>>             entityRef.addLiteral(Rex.hasOriginalText, rawText);
>>
>> end up adding the ^^ and the string data type.
If you look at the Javadoc for Resource.addLiteral, there's no 
overloaded type signature for addLiteral( Property, String ). Which 
means that you're actually invoking this method:

http://openjena.org/javadoc/com/hp/hpl/jena/rdf/model/Resource.html#addLiteral(com.hp.hpl.jena.rdf.model.Property,%20java.lang.Object)

which says:

"""
Add the property p with the typed-literal value o to this resource, ie 
add (this, p, typed(o)) to this's model. Answer this resource. The typed 
literal is equal to one constructed by using 
this.getModel().createTypedLiteral(o).
"""

You want either:

entityRef.addProperty(Rex.hasEntityDetectionSource, source);

or

entityRef.addLiteral(Rex.hasEntityDetectionSource, 
model.createPlainLiteral( source ));

Ian

Re: sparql versus ^^ types

Posted by Benson Margulies <bi...@gmail.com>.
To be clearer, the resulting OWL RDF has
rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
 attributes, and then tdbdump shows ^^ suffixes.

On Fri, Dec 10, 2010 at 12:20 PM, Benson Margulies
<bi...@gmail.com> wrote:
> Andy,
>
> I'm having trouble getting rid of all my ^^ noise.
>
> I run Jena schemagen against an Ontology that has no type annotations,
> I don't see any in the output of schemagen, but calls to
>
>  entityRef = model.createIndividual(entityUri, oclass);
>            entityRef.addLiteral(Rex.hasEntityDetectionSource, source);
>            entityRef.addLiteral(Rex.hasNormalizedText, normalizedText);
>            entityRef.addLiteral(Rex.hasOriginalText, rawText);
>
> end up adding the ^^ and the string data type.
>
> I suppose I'm missing something stupid?
>
>
> On Fri, Dec 10, 2010 at 11:53 AM, Andy Seaborne
> <an...@epimorphics.com> wrote:
>>
>>
>> On 10/12/10 16:39, Benson Margulies wrote:
>>>
>>> Protege persuaded me to put types in my Ontology. So (as viewed by
>>> tdbdump), I have quads like:
>>>
>>> <urn:basistech.com:analysis#9>
>>> <http://www.basistech.com/ontologies/2010/6/rex.owl#hasOriginalText>
>>> "Fredrick Chopin"^^<http://www.w3.org/2001/XMLSchema#string>
>>> <urn:misc-test>  .
>>>
>>> should the following sparql match that?
>>>
>>> SELECT ?x where { ?x
>>> <http://www.basistech.com/ontologies/2010/6/rex.owl#hasOriginalText>
>>> "Fredrick Chopin" }
>>
>> Not in TDB.  Simple literals (plain literals without language tag) do not
>> match xsd:string.
>>
>> SELECT ?x where { ?x
>>   <http://www.basistech.com/ontologies/2010/6/rex.owl#hasOriginalText>
>>   "Fredrick Chopin"^^xsd:string
>> }
>>
>> TDB could canonicalise the input to make "" and ""^^xsd:string the same.
>>
>>        Andy
>>
>

Re: sparql versus ^^ types

Posted by Benson Margulies <bi...@gmail.com>.
Andy,

I'm having trouble getting rid of all my ^^ noise.

I run Jena schemagen against an Ontology that has no type annotations,
I don't see any in the output of schemagen, but calls to

 entityRef = model.createIndividual(entityUri, oclass);
            entityRef.addLiteral(Rex.hasEntityDetectionSource, source);
            entityRef.addLiteral(Rex.hasNormalizedText, normalizedText);
            entityRef.addLiteral(Rex.hasOriginalText, rawText);

end up adding the ^^ and the string data type.

I suppose I'm missing something stupid?


On Fri, Dec 10, 2010 at 11:53 AM, Andy Seaborne
<an...@epimorphics.com> wrote:
>
>
> On 10/12/10 16:39, Benson Margulies wrote:
>>
>> Protege persuaded me to put types in my Ontology. So (as viewed by
>> tdbdump), I have quads like:
>>
>> <urn:basistech.com:analysis#9>
>> <http://www.basistech.com/ontologies/2010/6/rex.owl#hasOriginalText>
>> "Fredrick Chopin"^^<http://www.w3.org/2001/XMLSchema#string>
>> <urn:misc-test>  .
>>
>> should the following sparql match that?
>>
>> SELECT ?x where { ?x
>> <http://www.basistech.com/ontologies/2010/6/rex.owl#hasOriginalText>
>> "Fredrick Chopin" }
>
> Not in TDB.  Simple literals (plain literals without language tag) do not
> match xsd:string.
>
> SELECT ?x where { ?x
>   <http://www.basistech.com/ontologies/2010/6/rex.owl#hasOriginalText>
>   "Fredrick Chopin"^^xsd:string
> }
>
> TDB could canonicalise the input to make "" and ""^^xsd:string the same.
>
>        Andy
>

Re: sparql versus ^^ types

Posted by Andy Seaborne <an...@epimorphics.com>.

On 10/12/10 16:39, Benson Margulies wrote:
> Protege persuaded me to put types in my Ontology. So (as viewed by
> tdbdump), I have quads like:
>
> <urn:basistech.com:analysis#9>
> <http://www.basistech.com/ontologies/2010/6/rex.owl#hasOriginalText>
> "Fredrick Chopin"^^<http://www.w3.org/2001/XMLSchema#string>
> <urn:misc-test>  .
>
> should the following sparql match that?
>
> SELECT ?x where { ?x
> <http://www.basistech.com/ontologies/2010/6/rex.owl#hasOriginalText>
> "Fredrick Chopin" }

Not in TDB.  Simple literals (plain literals without language tag) do 
not match xsd:string.

SELECT ?x where { ?x
    <http://www.basistech.com/ontologies/2010/6/rex.owl#hasOriginalText>
    "Fredrick Chopin"^^xsd:string
}

TDB could canonicalise the input to make "" and ""^^xsd:string the same.

	Andy