You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Martynas Jusevicius <ma...@gmail.com> on 2011/04/28 12:08:49 UTC
ConversionException in TDB-backed OntModel
Hey list,
I switched from in-memory OntModel
OntModel model = ModelFactory.createOntologyModel();
to TDB-backed persistent OntModel
OntModel model =
ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM,
TDBFactory.createNamedModel(ONT_MODEL_URI,
getContext().getRealPath("/WEB-INF/tdb/ontologies")));
And I can see that behavior changed, since I get this exception on
model.listIndividuals() which wasn't there before:
com.hp.hpl.jena.ontology.ConversionException: Cannot convert node
"http://l-userpic.livejournal.com/83083903/3100850"@en to OntResource
Is OntModelSpec.OWL_MEM not the default model spec used in
createOntologyModel()?
More to the point - I can see that my FOAF data is broken - there is a
literal object where foaf:image expects a resource:
<foaf:image>http://l-userpic.livejournal.com/67781107/4730072</foaf:image>
but I can't do much about it since it is the kind of raw data I want
to accept from users.
I do not need inference right now but might use it in the future - so
how do I deal with ConversionException on broken data like this?
Thanks,
Martynas
semantic-web.dk
Re: ConversionException in TDB-backed OntModel
Posted by Ian Dickinson <ia...@epimorphics.com>.
Hi Martynas,
On 28/04/11 11:08, Martynas Jusevicius wrote:
> I switched from in-memory OntModel
>
> OntModel model = ModelFactory.createOntologyModel();
>
> to TDB-backed persistent OntModel
>
> OntModel model =
> ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM,
> TDBFactory.createNamedModel(ONT_MODEL_URI,
> getContext().getRealPath("/WEB-INF/tdb/ontologies")));
>
> And I can see that behavior changed, since I get this exception on
> model.listIndividuals() which wasn't there before:
>
> com.hp.hpl.jena.ontology.ConversionException: Cannot convert node
> "http://l-userpic.livejournal.com/83083903/3100850"@en to OntResource
>
> Is OntModelSpec.OWL_MEM not the default model spec used in
> createOntologyModel()?
No, it's not. The default is OWL_MEM_RDFS_INF, for backwards
compatibility with Jena 1. Possibly a mistake in hindsight, but hard to
change now without breaking user code.
> More to the point - I can see that my FOAF data is broken - there is a
> literal object where foaf:image expects a resource:
>
> <foaf:image>http://l-userpic.livejournal.com/67781107/4730072</foaf:image>
>
> but I can't do much about it since it is the kind of raw data I want
> to accept from users.
>
> I do not need inference right now but might use it in the future - so
> how do I deal with ConversionException on broken data like this?
If you're anticipating broken data, you could always turn off strict
mode, so that .as() will always succeed no matter what's in the model:
http://jena.sourceforge.net/javadoc/com/hp/hpl/jena/ontology/OntModel.html#setStrictMode%28boolean%29
Whether this is helpful or not is application defined :)
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