owlcs / jfact

JFact repository
13 stars 8 forks source link

Unexpected number format exception on checking ontology consistency in owlapi-jfact 4.0.0 #3

Open rchallen opened 9 years ago

rchallen commented 9 years ago

Caused by: java.lang.NumberFormatException at java.math.BigDecimal.(BigDecimal.java:470) at java.math.BigDecimal.(BigDecimal.java:739) at uk.ac.manchester.cs.jfact.datatypes.DatatypeFactory$RATIONAL_DATATYPE.parseValue(DatatypeFactory.java:1572) at uk.ac.manchester.cs.jfact.datatypes.LiteralImpl.typedValue(LiteralImpl.java:42) at uk.ac.manchester.cs.jfact.datatypes.NumericLiteralImpl.typedValue(NumericLiteralImpl.java:16) at uk.ac.manchester.cs.jfact.datatypes.LiteralImpl.hashCode(LiteralImpl.java:86) at uk.ac.manchester.cs.jfact.datatypes.NumericLiteralImpl.hashCode(NumericLiteralImpl.java:16) at uk.ac.manchester.cs.jfact.datatypes.LiteralEntry.hashCode(LiteralEntry.java:92) at uk.ac.manchester.cs.jfact.kernel.DlSatTester$DataCall.hashCode(DlSatTester.java:1888) at java.util.HashMap.hash(HashMap.java:362) at java.util.HashMap.put(HashMap.java:492) at java.util.HashSet.add(HashSet.java:217) at uk.ac.manchester.cs.jfact.kernel.DlSatTester.hasDataClash(DlSatTester.java:1946) at uk.ac.manchester.cs.jfact.kernel.DlSatTester.setupEdge(DlSatTester.java:3026) at uk.ac.manchester.cs.jfact.kernel.DlSatTester.createNewEdge(DlSatTester.java:2935) at uk.ac.manchester.cs.jfact.kernel.DlSatTester.commonTacticBodySome(DlSatTester.java:2875) at uk.ac.manchester.cs.jfact.kernel.DlSatTester.commonTacticBody(DlSatTester.java:2304) at uk.ac.manchester.cs.jfact.kernel.DlSatTester.commonTactic(DlSatTester.java:2269) at uk.ac.manchester.cs.jfact.kernel.DlSatTester.checkSatisfiability(DlSatTester.java:2033) at uk.ac.manchester.cs.jfact.kernel.DlSatTester.runSat(DlSatTester.java:1970) at uk.ac.manchester.cs.jfact.kernel.NominalReasoner.consistentNominalCloud(NominalReasoner.java:135) at uk.ac.manchester.cs.jfact.kernel.TBox.performConsistencyCheck(TBox.java:1824) at uk.ac.manchester.cs.jfact.kernel.TBox.isConsistent(TBox.java:1075) at uk.ac.manchester.cs.jfact.kernel.ReasoningKernel.processKB(ReasoningKernel.java:2013) at uk.ac.manchester.cs.jfact.kernel.ReasoningKernel.realiseKB(ReasoningKernel.java:848) at uk.ac.manchester.cs.jfact.JFactReasoner.precomputeInferences(JFactReasoner.java:406)

ignazio1977 commented 9 years ago

Thanks for the report. Can you share the ontology that results in this error, or a snippet that reproduces the issue? It's likely to be the value of rational typed literal.

rchallen commented 9 years ago

I'm trying to update my fork of the protege code-generation plugin to OWL API 4. the ontologies I'm using are these:

https://github.com/rchallen/code-generation/tree/master/src/test/resources

not sure which one is causing the issue but they all ran OK with jfact, pellet, and hermit, on owl api 3.5.x. I'm working on a branch that has the updates for the owl api 4 at the moment but I'm not sure how to push that branch to github - will look at that tomorrow.

Rob,

On 3 December 2014 at 16:28, Ignazio Palmisano notifications@github.com wrote:

Thanks for the report. Can you share the ontology that results in this error, or a snippet that reproduces the issue? It's likely to be the value of rational typed literal.

— Reply to this email directly or view it on GitHub https://github.com/owlcs/jfact/issues/3#issuecomment-65439755.

Rob Challen


BMJ advances healthcare worldwide by sharing knowledge and expertise to improve experiences, outcomes and value. This email and any attachments are confidential. If you have received this email in error, please delete it and kindly notify us. If the email contains personal views then BMJ accepts no responsibility for these statements. The recipient should check this email and attachments for viruses because the BMJ accepts no liability for any damage caused by viruses. Emails sent or received by BMJ may be monitored for size, traffic, distribution and content. BMJ Publishing Group Limited trading as BMJ. A private limited company, registered in England and Wales under registration number 03102371. Registered office: BMA House,

Tavistock Square, London WC1H 9JR, UK.

ignazio1977 commented 9 years ago

I've checked out the current master for your project and had a quick go at building it with JFact 4.0.0 and OWLAPI 4.0.1 - the tests ran correctly. Turns out I had my own fork of that code, from last summer (I was trying to port as many Protege plugins as I could to have an idea of how hard it would be to move over to the new API), although at that point I didn't have a JFact release yet - if you can get the code that's failing on GitHub that would be greatly appreciated.

rchallen commented 9 years ago

I've pushed my development branch in the code generation project (imaginatively called owl4) I've added a minimal test case for the reasoner that fails with that NPE on my setup (also imaginatively called org.protege.owl.codegeneration.MinimalReasonerTest). I'm a bit lost in the morass of dependencies, the org.protege.editor.core.application dependency has in turn a dependency on the owlapi v 3.5 which is ommitted in favour of v4.0.1. I imagine this would cause issues if the plugin was to be used within protege. At the moment though I'm running it stand alone so I don;t think it would cause this issue.

rchallen commented 9 years ago

It is the CodeGeneration001.owl file that causes the number format exception It has a individual y in it that has a data property iriQ which has the value "5/8"^^rational Changing that to "0.555"^^rational clears the exception.

I'm not sure whether owl:rationals are supported by JFact going to actually need rationals so I'll change the test ontology and carry on without needing any fixes to JFact. I shall let you decide if you are going to fix - I suppose a

FractionFormat ff = new FractionFormat(); Fraction f = ff.parse("-10 / 21");

is all that is needed instead of what is there.

rchallen commented 9 years ago

There are a couple of other things that are causing issues with this now.

A ReasonerInternalException that is thrown by a transitive property in the pizza ontology (hasIngredient) when I check whether the property can be more than single. You can argue this one. I've caught the exception and handled it but it's different behaviour to Pellet and Hermit which return a false rather than throw the exception.

(see: org.protege.owl.codegeneration.inference.ReasonerBasedInference.isSingleton(OWLClass, OWLDataProperty))

Also there is a test of a data property assertion on an equivalent individual that is not passing - this looks more like a "real" issue.

(see: org.protege.owl.codegeneration.TestInferredPropertyValues.testInferredPropertyValues())

I've put some notes in my owl4 branch where these tests are failing and disabled them, as I think I can make this work anyway for my use case.

ignazio1977 commented 9 years ago

Thanks a lot for your feedback, appreciated.

Matthew is working on a Protege update that should clear some of the dependency tangles away. I'll try and fix the issues you pinpointed.