001    package org.dllearner.test;
002    
003    import java.io.File;
004    import java.net.MalformedURLException;
005    
006    import org.dllearner.algorithms.celoe.CELOE;
007    import org.dllearner.core.ComponentInitException;
008    import org.dllearner.core.ComponentManager;
009    import org.dllearner.core.EvaluatedDescription;
010    import org.dllearner.core.KnowledgeSource;
011    import org.dllearner.core.LearningAlgorithm;
012    import org.dllearner.core.LearningProblem;
013    import org.dllearner.core.LearningProblemUnsupportedException;
014    import org.dllearner.core.ReasonerComponent;
015    import org.dllearner.kb.OWLFile;
016    import org.dllearner.learningproblems.ClassLearningProblem;
017    import org.dllearner.learningproblems.EvaluatedDescriptionPosNeg;
018    import org.dllearner.reasoning.FastInstanceChecker;
019    
020    public class ClassCastExceptionTest {
021    
022            /**
023             * @param args
024             * @throws ComponentInitException 
025             * @throws MalformedURLException 
026             */
027            public static void main(String[] args) throws ComponentInitException, MalformedURLException {
028                    
029                    // get singleton instance of component manager
030                    ComponentManager cm = ComponentManager.getInstance();
031                    
032                    // create knowledge source
033                    KnowledgeSource source = cm.knowledgeSource(OWLFile.class);
034                    String example = "examples/swore/swore.rdf";
035                    cm.applyConfigEntry(source, "url", new File(example).toURI().toURL());
036                    source.init();
037                    
038                    // create OWL API reasoning service with standard settings
039                    ReasonerComponent reasoner = cm.reasoner(FastInstanceChecker.class, source);
040                    reasoner.init();
041                    
042                    // create a learning problem and set positive and negative examples
043    
044                    LearningProblem lp = cm.learningProblem(ClassLearningProblem.class, reasoner);
045                    cm.applyConfigEntry(lp, "classToDescribe", "http://ns.softwiki.de/req/PerformanceRequirement");
046                    cm.applyConfigEntry(lp, "type", "equivalence");
047                    lp.init();
048                    
049                    // create the learning algorithm
050                    LearningAlgorithm la = null;
051                    try {
052                            la = cm.learningAlgorithm(CELOE.class, lp, reasoner);
053                            cm.applyConfigEntry(la, "maxExecutionTimeInSeconds", 2);
054                            la.init();
055                    } catch (LearningProblemUnsupportedException e) {
056                            e.printStackTrace();
057                    }
058            
059                    // start the algorithm and print the best concept found
060                    la.start();
061                    System.out.println(la.getCurrentlyBestEvaluatedDescriptions(10, 0.8, true));
062                    EvaluatedDescription desc = la.getCurrentlyBestEvaluatedDescription();
063                    System.out.println("test: " + ((EvaluatedDescriptionPosNeg)desc).getNotCoveredPositives());
064            }
065    }