-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add simple test for manchester parser
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
interfaces/src/test/java/org/dllearner/test/junit/LearningProblemTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.dllearner.test.junit; | ||
|
||
import org.dllearner.algorithms.ocel.OCEL; | ||
import org.dllearner.cli.CLI; | ||
import org.dllearner.core.AbstractCELA; | ||
import org.dllearner.core.AbstractClassExpressionLearningProblem; | ||
import org.dllearner.core.AbstractReasonerComponent; | ||
import org.dllearner.core.StringRenderer; | ||
import org.dllearner.utilities.OWLAPIUtils; | ||
import org.dllearner.utilities.owl.OWLClassExpressionLengthMetric; | ||
import org.dllearner.utilities.owl.OWLClassExpressionUtils; | ||
import org.junit.Test; | ||
import org.semanticweb.owlapi.model.OWLClassExpression; | ||
import org.semanticweb.owlapi.model.OWLDataFactory; | ||
import uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
/** | ||
* Created by ailin on 16-2-5. | ||
*/ | ||
public class LearningProblemTest { | ||
@Test | ||
public void problemQualityTest() { | ||
try { | ||
StringRenderer.setRenderer(StringRenderer.Rendering.MANCHESTER_SYNTAX); | ||
CLI cli = new CLI(new File("../examples/carcinogenesis/validate.conf")); | ||
cli.init(); | ||
AbstractReasonerComponent reasoner = cli.getReasonerComponent(); | ||
OWLDataFactory df = new OWLDataFactoryImpl(); | ||
AbstractCELA la = cli.getLearningAlgorithm(); | ||
AbstractClassExpressionLearningProblem lp = cli.getLearningProblem(); | ||
OWLClassExpressionLengthMetric metric; | ||
if (la instanceof OCEL) { | ||
metric = ((OCEL)la).getLengthMetric(); | ||
} else { | ||
metric = OWLClassExpressionLengthMetric.getDefaultMetric().getDefaultMetric(); | ||
} | ||
|
||
OWLClassExpression concept = OWLAPIUtils.fromManchester("Compound and hasAtom only (not Nitrogen-35) and ((amesTestPositive some {true}) or hasStructure some Ar_halide)", reasoner, df, true); | ||
|
||
System.out.println("concept: " + concept + " {" + OWLClassExpressionUtils.getLength(concept, metric) + "}"); | ||
|
||
double acc = lp.getAccuracyOrTooWeak(concept); | ||
|
||
assertTrue("accuracy was only " + acc, acc > 0.69); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |