From: <lor...@us...> - 2010-05-31 13:36:13
|
Revision: 2157 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2157&view=rev Author: lorenz_b Date: 2010-05-31 13:36:06 +0000 (Mon, 31 May 2010) Log Message: ----------- Removed more compiler warnings. Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/ore/ui/AddRoundButton.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/ClassesTable.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/ExtractFromSparqlDialog.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/MarkableClassExpressionsTableModel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/ResultTableModel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/StatusBar2.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/ManualLearnPanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/AutoLearnPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/ClassChoosePanel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/InconsistencyExplanationPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/UnsatisfiableExplanationPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/UnsatisfiableExplanationPanel2.java trunk/src/dl-learner/org/dllearner/utilities/examples/AutomaticPositiveExampleFinderSPARQL.java trunk/src/dl-learner/org/dllearner/utilities/experiments/ExMakerCrossFolds.java trunk/src/dl-learner/org/dllearner/utilities/owl/DLLearnerDescriptionConvertVisitor.java trunk/src/dl-learner/org/dllearner/utilities/owl/OWLAPIDescriptionConvertVisitor.java trunk/src/dl-learner/org/dllearner/utilities/owl/OWLAPIRenderers.java Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/AddRoundButton.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/AddRoundButton.java 2010-05-31 13:19:41 UTC (rev 2156) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/AddRoundButton.java 2010-05-31 13:36:06 UTC (rev 2157) @@ -17,7 +17,10 @@ public class AddRoundButton extends JButton { - private Color c; + /** + * + */ + private static final long serialVersionUID = 4728674196569042965L; public AddRoundButton(String label) { super(label); Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/ClassesTable.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/ClassesTable.java 2010-05-31 13:19:41 UTC (rev 2156) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/ClassesTable.java 2010-05-31 13:36:06 UTC (rev 2157) @@ -7,7 +7,6 @@ import javax.swing.ListSelectionModel; import org.dllearner.core.owl.NamedClass; -import org.dllearner.tools.ore.ui.rendering.ManchesterSyntaxTableCellRenderer; import org.jdesktop.swingx.JXTable; import org.jdesktop.swingx.decorator.HighlighterFactory; Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/ExtractFromSparqlDialog.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/ExtractFromSparqlDialog.java 2010-05-31 13:19:41 UTC (rev 2156) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/ExtractFromSparqlDialog.java 2010-05-31 13:36:06 UTC (rev 2157) @@ -277,6 +277,7 @@ getContentPane().add(panel, BorderLayout.CENTER); } + @SuppressWarnings("unused") private void addPredefinedEndpoints(){ endpointToDefaultGraph = new HashMap<URI, List<String>>(); for(SparqlEndpoint endpoint : SparqlEndpoint.listEndpoints()){ @@ -395,6 +396,7 @@ } + @SuppressWarnings("unused") private boolean URLExists(){ try { HttpURLConnection.setFollowRedirects(false); Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/MarkableClassExpressionsTableModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/MarkableClassExpressionsTableModel.java 2010-05-31 13:19:41 UTC (rev 2156) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/MarkableClassExpressionsTableModel.java 2010-05-31 13:36:06 UTC (rev 2157) @@ -77,6 +77,7 @@ } public void setSelectedDescription(int rowIndex){ + @SuppressWarnings("unused") int oldRowIndex = selectedRowIndex; selectedRowIndex = rowIndex; fireTableDataChanged(); Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/ResultTableModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/ResultTableModel.java 2010-05-31 13:19:41 UTC (rev 2156) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/ResultTableModel.java 2010-05-31 13:36:06 UTC (rev 2157) @@ -1,6 +1,5 @@ package org.dllearner.tools.ore.ui; -import java.text.DecimalFormat; import java.util.ArrayList; import java.util.List; @@ -17,12 +16,10 @@ private static final long serialVersionUID = -6920806148989403795L; private List<EvaluatedDescriptionClass> resultList; - private DecimalFormat df; public ResultTableModel(){ super(); resultList = new ArrayList<EvaluatedDescriptionClass>(); - df = new DecimalFormat("00%"); } public ResultTableModel(List<EvaluatedDescriptionClass> resultList){ @@ -42,7 +39,7 @@ @Override public Object getValueAt(int rowIndex, int columnIndex) { if(columnIndex == 0){ - return (int)(resultList.get(rowIndex).getAccuracy() *100);//df.format(resultList.get(rowIndex).getAccuracy()); + return (int)(resultList.get(rowIndex).getAccuracy() *100); } else { return resultList.get(rowIndex).getDescription(); } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/StatusBar2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/StatusBar2.java 2010-05-31 13:19:41 UTC (rev 2156) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/StatusBar2.java 2010-05-31 13:36:06 UTC (rev 2157) @@ -184,11 +184,6 @@ SwingUtilities.invokeLater(new Runnable() { public void run() { progressBar.setValue((int) progress); - double percentDone = (progress * 100.0) / progressBar.getMaximum(); - // if(percentDone / 100.0 == 0) { - // label.setText("Classifying ontology " + ((int) percentDone) + - // " %"); - // } } }); Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/ManualLearnPanelDescriptor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/ManualLearnPanelDescriptor.java 2010-05-31 13:19:41 UTC (rev 2156) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/ManualLearnPanelDescriptor.java 2010-05-31 13:36:06 UTC (rev 2157) @@ -178,6 +178,7 @@ } + @SuppressWarnings("unused") private void fillTable(final List<EvaluatedDescriptionClass> result){ Runnable r = new Runnable() { @Override Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/AutoLearnPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/AutoLearnPanel.java 2010-05-31 13:19:41 UTC (rev 2156) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/AutoLearnPanel.java 2010-05-31 13:36:06 UTC (rev 2157) @@ -21,7 +21,6 @@ import org.dllearner.core.owl.NamedClass; import org.dllearner.learningproblems.EvaluatedDescriptionClass; -import org.dllearner.tools.ore.LearningManager; import org.dllearner.tools.ore.OREManager; import org.dllearner.tools.ore.ui.GraphicalCoveragePanel; import org.dllearner.tools.ore.ui.MarkableClassesTable; Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/ClassChoosePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/ClassChoosePanel.java 2010-05-31 13:19:41 UTC (rev 2156) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/ClassChoosePanel.java 2010-05-31 13:36:06 UTC (rev 2157) @@ -41,7 +41,6 @@ import javax.swing.event.ListSelectionListener; import org.dllearner.tools.ore.LearningManager; -import org.dllearner.tools.ore.OREManager; import org.dllearner.tools.ore.LearningManager.LearningMode; import org.dllearner.tools.ore.ui.ClassesTable; import org.dllearner.tools.ore.ui.HelpablePanel; Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/InconsistencyExplanationPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/InconsistencyExplanationPanel.java 2010-05-31 13:19:41 UTC (rev 2156) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/InconsistencyExplanationPanel.java 2010-05-31 13:36:06 UTC (rev 2157) @@ -38,6 +38,7 @@ private JScrollPane explanationsScrollPane; private JComponent explanationsPanel; + @SuppressWarnings("unused") private JPanel buttonExplanationsPanel; private ButtonGroup explanationType; Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/UnsatisfiableExplanationPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/UnsatisfiableExplanationPanel.java 2010-05-31 13:19:41 UTC (rev 2156) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/UnsatisfiableExplanationPanel.java 2010-05-31 13:36:06 UTC (rev 2157) @@ -75,6 +75,7 @@ private JSpinner maxExplanationsSelector; private JCheckBox strikeOutBox; + @SuppressWarnings("unused") private Set<ExplanationTablePanel> explanationPanels; private Set<ExplanationTable> explanationTables; Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/UnsatisfiableExplanationPanel2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/UnsatisfiableExplanationPanel2.java 2010-05-31 13:19:41 UTC (rev 2156) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/UnsatisfiableExplanationPanel2.java 2010-05-31 13:36:06 UTC (rev 2157) @@ -70,6 +70,7 @@ private JSpinner maxExplanationsSelector; private JCheckBox strikeOutBox; + @SuppressWarnings("unused") private Set<ExplanationTablePanel> explanationPanels; private Set<ExplanationTable> explanationTables; Modified: trunk/src/dl-learner/org/dllearner/utilities/examples/AutomaticPositiveExampleFinderSPARQL.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/examples/AutomaticPositiveExampleFinderSPARQL.java 2010-05-31 13:19:41 UTC (rev 2156) +++ trunk/src/dl-learner/org/dllearner/utilities/examples/AutomaticPositiveExampleFinderSPARQL.java 2010-05-31 13:36:06 UTC (rev 2157) @@ -47,14 +47,12 @@ logger.debug("pos Example size: "+posExamples.size()); } - @SuppressWarnings("unused") public void makePositiveExamplesFromDomain(String role, int resultLimit){ logger.debug("making Positive Examples from Domain of : "+role); this.posExamples.addAll(sparqltasks.getDomainInstances(role, resultLimit)); logger.debug("pos Example size: "+posExamples.size()); } - @SuppressWarnings("unused") public void makePositiveExamplesFromRange(String role, int resultLimit){ logger.debug("making Positive Examples from Range of : "+role); this.posExamples.addAll(sparqltasks.getRangeInstances(role, resultLimit)); Modified: trunk/src/dl-learner/org/dllearner/utilities/experiments/ExMakerCrossFolds.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/experiments/ExMakerCrossFolds.java 2010-05-31 13:19:41 UTC (rev 2156) +++ trunk/src/dl-learner/org/dllearner/utilities/experiments/ExMakerCrossFolds.java 2010-05-31 13:36:06 UTC (rev 2157) @@ -9,7 +9,6 @@ import org.apache.log4j.Logger; public class ExMakerCrossFolds { - @SuppressWarnings("unused") private static Logger logger = Logger.getLogger(ExMakerCrossFolds.class); private final Examples examples; Modified: trunk/src/dl-learner/org/dllearner/utilities/owl/DLLearnerDescriptionConvertVisitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/owl/DLLearnerDescriptionConvertVisitor.java 2010-05-31 13:19:41 UTC (rev 2156) +++ trunk/src/dl-learner/org/dllearner/utilities/owl/DLLearnerDescriptionConvertVisitor.java 2010-05-31 13:36:06 UTC (rev 2157) @@ -2,7 +2,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.Set; import java.util.Stack; import org.dllearner.core.owl.DataRange; @@ -36,7 +35,6 @@ import org.semanticweb.owlapi.model.OWLDataMaxCardinality; import org.semanticweb.owlapi.model.OWLDataMinCardinality; import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; -import org.semanticweb.owlapi.model.OWLNamedIndividual; import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; import org.semanticweb.owlapi.model.OWLObjectComplementOf; import org.semanticweb.owlapi.model.OWLObjectExactCardinality; Modified: trunk/src/dl-learner/org/dllearner/utilities/owl/OWLAPIDescriptionConvertVisitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/owl/OWLAPIDescriptionConvertVisitor.java 2010-05-31 13:19:41 UTC (rev 2156) +++ trunk/src/dl-learner/org/dllearner/utilities/owl/OWLAPIDescriptionConvertVisitor.java 2010-05-31 13:36:06 UTC (rev 2157) @@ -19,7 +19,6 @@ */ package org.dllearner.utilities.owl; -import java.net.URI; import java.util.HashSet; import java.util.Set; import java.util.Stack; Modified: trunk/src/dl-learner/org/dllearner/utilities/owl/OWLAPIRenderers.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/owl/OWLAPIRenderers.java 2010-05-31 13:19:41 UTC (rev 2156) +++ trunk/src/dl-learner/org/dllearner/utilities/owl/OWLAPIRenderers.java 2010-05-31 13:36:06 UTC (rev 2157) @@ -21,8 +21,6 @@ import java.io.StringWriter; -import org.coode.owlapi.owlxml.renderer.OWLXMLObjectRenderer; -import org.coode.owlapi.owlxml.renderer.OWLXMLWriter; import org.coode.xml.XMLWriterNamespaceManager; import org.semanticweb.owlapi.apibinding.OWLManager; import org.semanticweb.owlapi.model.IRI; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2010-06-02 12:39:02
|
Revision: 2158 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2158&view=rev Author: jenslehmann Date: 2010-06-02 12:38:54 +0000 (Wed, 02 Jun 2010) Log Message: ----------- resolved compiler warnings Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/gp/ADC.java trunk/src/dl-learner/org/dllearner/algorithms/isle/LuceneIndexer.java trunk/src/dl-learner/org/dllearner/algorithms/isle/LuceneSearcher.java trunk/src/dl-learner/org/dllearner/algorithms/isle/Relevances.java trunk/src/dl-learner/org/dllearner/core/options/StringSetConfigOption.java trunk/src/dl-learner/org/dllearner/core/options/StringTupleListConfigOption.java trunk/src/dl-learner/org/dllearner/examples/KRK.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLPStandard.java trunk/src/dl-learner/org/dllearner/reasoning/PelletReasoner.java trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java trunk/src/dl-learner/org/dllearner/tools/evaluationplugin/RadioButtonEditor.java trunk/src/dl-learner/org/dllearner/tools/ore/cache/LRUMap.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/AddRoundButton.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/ChangesTable.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/ExplanationTable.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/ExtractFromSparqlDialog.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/ImpactTable.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/LinkLabel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/MetricsTableModel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/RepairTable.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/RolloverButton.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/StatusBar.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/editor/ExpressionEditor.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/editor/OWLAutoCompleter.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/rendering/ManchesterOWLSyntaxOWLObjectRendererImpl.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/Wizard.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/UnsatisfiableExplanationPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/UnsatisfiableExplanationPanel2.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/gp/ADC.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/gp/ADC.java 2010-05-31 13:36:06 UTC (rev 2157) +++ trunk/src/dl-learner/org/dllearner/algorithms/gp/ADC.java 2010-06-02 12:38:54 UTC (rev 2158) @@ -27,6 +27,8 @@ } */ + private static final long serialVersionUID = -3820156025424386445L; + public int getLength() { // ein ADC-Knoten hat Laenge 1, da effektiv nur ein Knoten benoetigt wird // um die Gesamtlaenge des gelernten Konzepts zu haben, muss man natuerlich Modified: trunk/src/dl-learner/org/dllearner/algorithms/isle/LuceneIndexer.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/isle/LuceneIndexer.java 2010-05-31 13:36:06 UTC (rev 2157) +++ trunk/src/dl-learner/org/dllearner/algorithms/isle/LuceneIndexer.java 2010-06-02 12:38:54 UTC (rev 2158) @@ -22,14 +22,16 @@ System.out.println("<delete index!>"); System.exit(1); } - final File docDir = new File( args[0] ); - LuceneIndexer indexer = new LuceneIndexer( docDir ); +// final File docDir = new File( args[0] ); +// LuceneIndexer indexer = new LuceneIndexer( docDir ); } + @SuppressWarnings("deprecation") public LuceneIndexer( File docDir ){ System.out.println( "LuceneIndex: "+ docDir ); Date start = new Date(); try { + IndexWriter writer = new IndexWriter( FSDirectory.open( INDEX ), new StandardAnalyzer( Version.LUCENE_CURRENT ), true, IndexWriter.MaxFieldLength.LIMITED ); System.out.println( "Creating index ..." ); Modified: trunk/src/dl-learner/org/dllearner/algorithms/isle/LuceneSearcher.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/isle/LuceneSearcher.java 2010-05-31 13:36:06 UTC (rev 2157) +++ trunk/src/dl-learner/org/dllearner/algorithms/isle/LuceneSearcher.java 2010-06-02 12:38:54 UTC (rev 2158) @@ -43,12 +43,13 @@ System.out.println( "\nquery='"+ sQuery +"' all="+ searcher.indexSize() +" hits="+ docs.size() ); for( Document doc : docs ) { - String sDoc = doc.toString(); +// String sDoc = doc.toString(); float score = searcher.getScore( doc ); System.out.println( "score="+ score +" doc="+ doc ); } } + @SuppressWarnings("deprecation") public LuceneSearcher() throws Exception { m_reader = IndexReader.open( FSDirectory.open( new File( INDEX ) ), true ); m_searcher = new IndexSearcher( m_reader ); @@ -89,6 +90,7 @@ else if( s1 < s2 ) return 1; return 0; } + @Override public boolean equals( Object obj ){ return false; } @@ -101,22 +103,27 @@ } private void search( Query query ) throws IOException { + @SuppressWarnings("unused") Collector collector = new Collector() { private Scorer scorer; private int docBase; private Map<Document,Float> results = new HashMap<Document,Float>(); + @Override public void collect(int doc) throws IOException { // System.out.println("doc=" + doc + docBase + " score=" + scorer.score()); m_results.put( m_searcher.doc( doc ), scorer.score() ); } + @Override public boolean acceptsDocsOutOfOrder() { return true; } + @Override public void setNextReader( IndexReader reader, int docBase ) throws IOException { this.docBase = docBase; } + @Override public void setScorer(Scorer scorer) throws IOException { this.scorer = scorer; } Modified: trunk/src/dl-learner/org/dllearner/algorithms/isle/Relevances.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/isle/Relevances.java 2010-05-31 13:36:06 UTC (rev 2157) +++ trunk/src/dl-learner/org/dllearner/algorithms/isle/Relevances.java 2010-06-02 12:38:54 UTC (rev 2158) @@ -94,7 +94,7 @@ String sEntity = getLabel(e); int iEntity = m_searcher.count( sEntity ); int iEntityClass = m_searcher.count( sClass +" AND "+ sEntity ); - double dPEntity = (double)iEntity / (double)iAll; +// double dPEntity = (double)iEntity / (double)iAll; double dPClassEntity = (double) iEntityClass / (double)iEntity; double dPMI = Math.log( dPClassEntity / dPClass ); if( !Double.isNaN( dPMI ) && !Double.isInfinite( dPMI ) ){ Modified: trunk/src/dl-learner/org/dllearner/core/options/StringSetConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/options/StringSetConfigOption.java 2010-05-31 13:36:06 UTC (rev 2157) +++ trunk/src/dl-learner/org/dllearner/core/options/StringSetConfigOption.java 2010-06-02 12:38:54 UTC (rev 2158) @@ -81,7 +81,7 @@ */ @Override public boolean checkType(Object object) { - if (!(object instanceof Set)) + if (!(object instanceof Set<?>)) return false; Set<?> set = (Set<?>) object; Modified: trunk/src/dl-learner/org/dllearner/core/options/StringTupleListConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/options/StringTupleListConfigOption.java 2010-05-31 13:36:06 UTC (rev 2157) +++ trunk/src/dl-learner/org/dllearner/core/options/StringTupleListConfigOption.java 2010-06-02 12:38:54 UTC (rev 2158) @@ -75,7 +75,7 @@ */ @Override public boolean checkType(Object object) { - if (!(object instanceof List)) + if (!(object instanceof List<?>)) return false; List<?> set = (List<?>) object; Modified: trunk/src/dl-learner/org/dllearner/examples/KRK.java =================================================================== --- trunk/src/dl-learner/org/dllearner/examples/KRK.java 2010-05-31 13:36:06 UTC (rev 2157) +++ trunk/src/dl-learner/org/dllearner/examples/KRK.java 2010-06-02 12:38:54 UTC (rev 2158) @@ -61,7 +61,7 @@ static boolean closeKB=false; static boolean closeConcise= true && closeKB; static boolean writeClosedOWL = true && closeKB; - static boolean verifySomeConcepts = false && closeKB; + static boolean verifySomeConcepts = false; // && closeKB; <-- && closeKB does not make sense static boolean useInverse = false; Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLPStandard.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLPStandard.java 2010-05-31 13:36:06 UTC (rev 2157) +++ trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLPStandard.java 2010-06-02 12:38:54 UTC (rev 2158) @@ -77,6 +77,7 @@ this.configurator = new PosNegLPStandardConfigurator(this); } + @Override public void init() { super.init(); useApproximations = configurator.getUseApproximations(); Modified: trunk/src/dl-learner/org/dllearner/reasoning/PelletReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/PelletReasoner.java 2010-05-31 13:36:06 UTC (rev 2157) +++ trunk/src/dl-learner/org/dllearner/reasoning/PelletReasoner.java 2010-06-02 12:38:54 UTC (rev 2158) @@ -1281,7 +1281,7 @@ NodeSet<OWLClass> set = reasoner.getObjectPropertyRanges(prop, true); if (set.isEmpty()) return new Thing(); - OWLClass oc = set.iterator().next().getRepresentativeElement(); +// OWLClass oc = set.iterator().next().getRepresentativeElement(); return getDescriptionFromReturnedDomain(set); } Modified: trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java 2010-05-31 13:36:06 UTC (rev 2157) +++ trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java 2010-06-02 12:38:54 UTC (rev 2158) @@ -75,7 +75,7 @@ @SuppressWarnings("unchecked") private static final Class EXTENDSREFINEMENTOPERATORCLASS = RefinementOperatorConfigurator.class; - private static final boolean INCLUDE_UNUSED = false; +// private static final boolean INCLUDE_UNUSED = false; private static final String UNUSED = "@SuppressWarnings(\"unused\")\n"; private static final String OVERRIDE = "@SuppressWarnings(\"all\")\n"; @@ -542,7 +542,7 @@ ret += "package " + packagE + ";\n\n"; ret += imports + "\n"; ret += fillJavaDocComment(CLASS_COMMENT); - ret += (INCLUDE_UNUSED) ? UNUSED : ""; +// ret += (INCLUDE_UNUSED) ? UNUSED : ""; ret += (!extendS.isEmpty()) ? OVERRIDE : ""; ret += "public "+classModifier+" class " + className + " " + ((extendS.length() > 0) ? " extends " + extendS : "") Modified: trunk/src/dl-learner/org/dllearner/tools/evaluationplugin/RadioButtonEditor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/evaluationplugin/RadioButtonEditor.java 2010-05-31 13:36:06 UTC (rev 2157) +++ trunk/src/dl-learner/org/dllearner/tools/evaluationplugin/RadioButtonEditor.java 2010-06-02 12:38:54 UTC (rev 2158) @@ -41,6 +41,7 @@ */ private static final long serialVersionUID = -1736759123580734984L; + @Override public void setValue(Object value) { boolean selected = false; if (value instanceof Boolean) { @@ -51,6 +52,7 @@ radioButton.setSelected(selected); } + @Override public Object getCellEditorValue() { return Boolean.valueOf(radioButton.isSelected()); } @@ -92,6 +94,7 @@ * * @see EditorDelegate#shouldSelectCell(EventObject) */ + @Override public boolean shouldSelectCell(EventObject anEvent) { return delegate.shouldSelectCell(anEvent); } @@ -102,6 +105,7 @@ * * @see EditorDelegate#stopCellEditing */ + @Override public boolean stopCellEditing() { return delegate.stopCellEditing(); } @@ -112,6 +116,7 @@ * * @see EditorDelegate#cancelCellEditing */ + @Override public void cancelCellEditing() { delegate.cancelCellEditing(); } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/cache/LRUMap.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/cache/LRUMap.java 2010-05-31 13:36:06 UTC (rev 2157) +++ trunk/src/dl-learner/org/dllearner/tools/ore/cache/LRUMap.java 2010-06-02 12:38:54 UTC (rev 2158) @@ -15,7 +15,8 @@ this.maxCapacity = maxCapacity; } - protected boolean removeEldestEntry(Map.Entry<K,V> eldest) { + @Override + protected boolean removeEldestEntry(Map.Entry<K,V> eldest) { return size() >= this.maxCapacity; } } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/AddRoundButton.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/AddRoundButton.java 2010-05-31 13:36:06 UTC (rev 2157) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/AddRoundButton.java 2010-06-02 12:38:54 UTC (rev 2158) @@ -79,6 +79,7 @@ } // Paint the round background and label. + @Override protected void paintComponent(Graphics g) { if (getModel().isArmed()) { // You might want to make the highlight color @@ -95,6 +96,7 @@ } // Paint the border of the button using a simple stroke. + @Override protected void paintBorder(Graphics g) { Graphics2D g2 = (Graphics2D)g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); @@ -105,6 +107,7 @@ // Hit detection. Shape shape; + @Override public boolean contains(int x, int y) { // If the button has changed size, // make a new shape object. Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/ChangesTable.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/ChangesTable.java 2010-05-31 13:36:06 UTC (rev 2157) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/ChangesTable.java 2010-06-02 12:38:54 UTC (rev 2158) @@ -40,7 +40,8 @@ addKeyListener(new KeyAdapter() { - public void keyPressed(KeyEvent e) + @Override + public void keyPressed(KeyEvent e) { handleKeyPressed(e); } @@ -55,6 +56,7 @@ table = ChangesTable.this; } + @Override public void mouseMoved(MouseEvent e) { int row = rowAtPoint(e.getPoint()); int column = columnAtPoint(e.getPoint()); @@ -75,6 +77,7 @@ table = ChangesTable.this; } + @Override public void mouseClicked(MouseEvent e) { int row = rowAtPoint(e.getPoint()); int column = columnAtPoint(e.getPoint()); Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/ExplanationTable.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/ExplanationTable.java 2010-05-31 13:36:06 UTC (rev 2157) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/ExplanationTable.java 2010-06-02 12:38:54 UTC (rev 2158) @@ -166,6 +166,7 @@ */ private static final long serialVersionUID = -3386641672808329591L; + @Override public String getToolTipText(MouseEvent e) { java.awt.Point p = e.getPoint(); @@ -286,6 +287,7 @@ */ private static final long serialVersionUID = -1729370486474583609L; + @Override public Component getTableCellRendererComponent(JTable table, Object obj, boolean isSelected, boolean hasFocus, int row, int column) { @@ -329,6 +331,7 @@ */ private static final long serialVersionUID = 1277678457457723435L; + @Override public void selectInitialValue() { // This is overriden so that the option pane dialog default // button @@ -354,6 +357,7 @@ dlg.setLocationRelativeTo(parent); dlg.addComponentListener(new ComponentAdapter() { + @Override public void componentHidden(ComponentEvent e) { Object retVal = optionPane.getValue(); editorComponent.setPreferredSize(editorComponent.getSize()); Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/ExtractFromSparqlDialog.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/ExtractFromSparqlDialog.java 2010-05-31 13:36:06 UTC (rev 2157) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/ExtractFromSparqlDialog.java 2010-06-02 12:38:54 UTC (rev 2158) @@ -242,6 +242,7 @@ optionsButton.setBorderPainted(false); optionsButton.setContentAreaFilled(false); optionsButton.addMouseListener(new MouseAdapter() { + @Override public void mouseEntered(MouseEvent e) { optionsButton.setBorderPainted(true); optionsButton.setContentAreaFilled(true); Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/ImpactTable.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/ImpactTable.java 2010-05-31 13:36:06 UTC (rev 2157) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/ImpactTable.java 2010-06-02 12:38:54 UTC (rev 2158) @@ -57,6 +57,7 @@ table = ImpactTable.this; } + @Override public void mouseMoved(MouseEvent e) { int row = rowAtPoint(e.getPoint()); int column = columnAtPoint(e.getPoint()); @@ -76,6 +77,7 @@ table = ImpactTable.this; } + @Override public void mouseClicked(MouseEvent e) { int row = rowAtPoint(e.getPoint()); int column = columnAtPoint(e.getPoint()); @@ -87,6 +89,7 @@ } + @Override public void mousePressed(MouseEvent e) { int row = rowAtPoint(e.getPoint()); if (row >= 0 && row < getRowCount() && e.isPopupTrigger()) { @@ -96,6 +99,7 @@ } + @Override public void mouseReleased(MouseEvent e) { int row = rowAtPoint(e.getPoint()); if (row >= 0 && row < getRowCount() && e.isPopupTrigger()) { Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/LinkLabel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/LinkLabel.java 2010-05-31 13:36:06 UTC (rev 2157) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/LinkLabel.java 2010-06-02 12:38:54 UTC (rev 2158) @@ -50,17 +50,20 @@ setForeground(linkColor); addMouseListener(new MouseAdapter() { - public void mouseEntered(MouseEvent e) { + @Override + public void mouseEntered(MouseEvent e) { setHoverMode(true); } - public void mouseExited(MouseEvent e) { + @Override + public void mouseExited(MouseEvent e) { setHoverMode(false); } - public void mouseReleased(MouseEvent e) { + @Override + public void mouseReleased(MouseEvent e) { activateLink(); } }); Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/MetricsTableModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/MetricsTableModel.java 2010-05-31 13:36:06 UTC (rev 2157) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/MetricsTableModel.java 2010-06-02 12:38:54 UTC (rev 2158) @@ -47,7 +47,8 @@ } - public String getColumnName(int column) { + @Override + public String getColumnName(int column) { if (column == 0) { return "Metric"; } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/RepairTable.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/RepairTable.java 2010-05-31 13:36:06 UTC (rev 2157) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/RepairTable.java 2010-06-02 12:38:54 UTC (rev 2158) @@ -53,6 +53,7 @@ addKeyListener(new KeyAdapter() { + @Override public void keyPressed(KeyEvent e) { handleKeyPressed(e); } @@ -66,6 +67,7 @@ table = RepairTable.this; } + @Override public void mouseMoved(MouseEvent e) { int row = rowAtPoint(e.getPoint()); int column = columnAtPoint(e.getPoint()); @@ -86,6 +88,7 @@ table = RepairTable.this; } + @Override public void mouseClicked(MouseEvent e) { int row = rowAtPoint(e.getPoint()); int column = columnAtPoint(e.getPoint()); Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/RolloverButton.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/RolloverButton.java 2010-05-31 13:36:06 UTC (rev 2157) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/RolloverButton.java 2010-06-02 12:38:54 UTC (rev 2158) @@ -19,7 +19,8 @@ } - protected void paintBorder( Graphics g ) + @Override +protected void paintBorder( Graphics g ) { if( model.isRollover() ) { Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/StatusBar.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/StatusBar.java 2010-05-31 13:36:06 UTC (rev 2157) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/StatusBar.java 2010-06-02 12:38:54 UTC (rev 2158) @@ -106,6 +106,7 @@ }); } + @Override protected void paintComponent(Graphics g) { super.paintComponent(g); @@ -291,7 +292,8 @@ } // Paint the round background and label. - protected void paintComponent(Graphics g) { + @Override + protected void paintComponent(Graphics g) { if (getModel().isArmed()) { // You might want to make the highlight color // a property of the RoundButton class. @@ -314,7 +316,8 @@ } // Paint the border of the button using a simple stroke. - protected void paintBorder(Graphics g) { + @Override + protected void paintBorder(Graphics g) { g.setColor(Color.lightGray); g.drawOval(0, 0, getSize().width-1, getSize().height-1); @@ -322,7 +325,8 @@ // Hit detection. Shape shape; - public boolean contains(int x, int y) { + @Override + public boolean contains(int x, int y) { // If the button has changed size, // make a new shape object. if (shape == null || Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/editor/ExpressionEditor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/editor/ExpressionEditor.java 2010-05-31 13:36:06 UTC (rev 2157) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/editor/ExpressionEditor.java 2010-06-02 12:38:54 UTC (rev 2158) @@ -176,7 +176,8 @@ } - public void setBorder(Border border) { + @Override + public void setBorder(Border border) { outerBorder = border; // Override to set the outer border super.setBorder(BorderFactory.createCompoundBorder(outerBorder, stateBorder)); @@ -256,7 +257,8 @@ } - protected void paintComponent(Graphics g) { + @Override + protected void paintComponent(Graphics g) { super.paintComponent(g); Color oldColor = g.getColor(); try { Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/editor/OWLAutoCompleter.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/editor/OWLAutoCompleter.java 2010-05-31 13:36:06 UTC (rev 2157) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/editor/OWLAutoCompleter.java 2010-06-02 12:38:54 UTC (rev 2158) @@ -76,11 +76,13 @@ private int maxEntries = DEFAULT_MAX_ENTRIES; private KeyListener keyListener = new KeyAdapter() { - public void keyPressed(KeyEvent e) { + @Override + public void keyPressed(KeyEvent e) { processKeyPressed(e); } - public void keyReleased(KeyEvent e) { + @Override + public void keyReleased(KeyEvent e) { if (e.getKeyCode() != KeyEvent.VK_UP && e.getKeyCode() != KeyEvent.VK_DOWN) { if (popupWindow.isVisible() && !lastTextUpdate.equals(textComponent.getText())) { @@ -92,15 +94,18 @@ }; private ComponentAdapter componentListener = new ComponentAdapter() { - public void componentHidden(ComponentEvent event) { + @Override + public void componentHidden(ComponentEvent event) { hidePopup(); } - public void componentResized(ComponentEvent event) { + @Override + public void componentResized(ComponentEvent event) { hidePopup(); } - public void componentMoved(ComponentEvent event) { + @Override + public void componentMoved(ComponentEvent event) { hidePopup(); } }; @@ -123,7 +128,8 @@ }; private MouseListener mouseListener = new MouseAdapter() { - public void mouseClicked(MouseEvent e) { + @Override + public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { completeWithPopupSelection(); } @@ -131,7 +137,8 @@ }; private FocusListener focusListener = new FocusAdapter(){ - public void focusLost(FocusEvent event) { + @Override + public void focusLost(FocusEvent event) { hidePopup(); } }; Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/rendering/ManchesterOWLSyntaxOWLObjectRendererImpl.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/rendering/ManchesterOWLSyntaxOWLObjectRendererImpl.java 2010-05-31 13:36:06 UTC (rev 2157) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/rendering/ManchesterOWLSyntaxOWLObjectRendererImpl.java 2010-06-02 12:38:54 UTC (rev 2158) @@ -51,22 +51,26 @@ } - public String toString() { + @Override + public String toString() { return delegate.getBuffer().toString(); } - public void close() throws IOException { + @Override + public void close() throws IOException { delegate.close(); } - public void flush() throws IOException { + @Override + public void flush() throws IOException { delegate.flush(); } - public void write(char cbuf[], int off, int len) throws IOException { + @Override + public void write(char cbuf[], int off, int len) throws IOException { delegate.write(cbuf, off, len); } } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/Wizard.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/Wizard.java 2010-05-31 13:36:06 UTC (rev 2157) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/Wizard.java 2010-06-02 12:38:54 UTC (rev 2158) @@ -139,7 +139,8 @@ wizardModel = new WizardModel(); wizardDialog = new JFrame(); wizardDialog.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { + @Override + public void windowClosing(WindowEvent e) { System.out.println("Exited application"); wizardDialog.dispose(); System.exit(0); Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/UnsatisfiableExplanationPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/UnsatisfiableExplanationPanel.java 2010-05-31 13:36:06 UTC (rev 2157) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/UnsatisfiableExplanationPanel.java 2010-06-02 12:38:54 UTC (rev 2158) @@ -307,6 +307,7 @@ explanationsPanel.add(explanationHolderPanel); } + @Override public void validate(){ explanationsScrollPane.validate(); } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/UnsatisfiableExplanationPanel2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/UnsatisfiableExplanationPanel2.java 2010-05-31 13:36:06 UTC (rev 2157) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/UnsatisfiableExplanationPanel2.java 2010-06-02 12:38:54 UTC (rev 2158) @@ -289,6 +289,7 @@ explanationsPanel.add(explanationHolderPanel); } + @Override public void validate(){ explanationsScrollPane.validate(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2010-06-15 14:08:38
|
Revision: 2164 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2164&view=rev Author: lorenz_b Date: 2010-06-15 14:08:31 +0000 (Tue, 15 Jun 2010) Log Message: ----------- Continued refactoring Prot?\195?\169g?\195?\169 plugin. Some more progress feedback is shown to the user now. Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/reasoning/ProtegeReasoner.java trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanelHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoverageTextField.java trunk/src/dl-learner/org/dllearner/tools/protege/Manager.java trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java trunk/src/dl-learner/org/dllearner/tools/protege/ReadingOntologyThread.java trunk/src/dl-learner/org/dllearner/tools/protege/StatusBar.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java Modified: trunk/src/dl-learner/org/dllearner/reasoning/ProtegeReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/ProtegeReasoner.java 2010-06-14 09:10:38 UTC (rev 2163) +++ trunk/src/dl-learner/org/dllearner/reasoning/ProtegeReasoner.java 2010-06-15 14:08:31 UTC (rev 2164) @@ -92,6 +92,7 @@ import org.semanticweb.owlapi.reasoner.Node; import org.semanticweb.owlapi.reasoner.NodeSet; import org.semanticweb.owlapi.reasoner.OWLReasoner; +import org.semanticweb.owlapi.reasoner.ReasonerProgressMonitor; import org.semanticweb.owlapi.util.SimpleIRIMapper; import org.semanticweb.owlapi.vocab.PrefixOWLOntologyFormat; @@ -104,6 +105,8 @@ private OWLDataFactory factory; private OWLReasoner reasoner; + private ReasonerProgressMonitor progressMonitor; + private ProtegeReasonerConfigurator configurator; private Set<OWLOntology> loadedOntologies; @@ -166,6 +169,10 @@ public ReasonerType getReasonerType() { return ReasonerType.PROTEGE; } + + public void setProgressMonitor(ReasonerProgressMonitor progressMonitor){ + this.progressMonitor = progressMonitor; + } @Override public void releaseKB() { @@ -343,9 +350,14 @@ private void dematerialise(){ long dematStartTime = System.currentTimeMillis(); logger.debug("dematerialising concepts"); - + progressMonitor.reasonerTaskStarted("Preparing DL-Learner ..."); + int size = atomicConcepts.size() + atomicRoles.size() + + booleanDatatypeProperties.size() + intDatatypeProperties.size() + + doubleDatatypeProperties.size(); + int cnt = 1; + for (NamedClass atomicConcept : atomicConcepts) { - + SortedSet<Individual> pos = getIndividualsWithPellet(atomicConcept); classInstancesPos.put(atomicConcept, (TreeSet<Individual>) pos); if (configurator.getDefaultNegation()) { @@ -354,13 +366,14 @@ Negation negatedAtomicConcept = new Negation(atomicConcept); classInstancesNeg.put(atomicConcept, (TreeSet<Individual>) getIndividuals(negatedAtomicConcept)); } - + progressMonitor.reasonerTaskProgressChanged(cnt++, size); } logger.debug("dematerialising object properties"); for (ObjectProperty atomicRole : atomicRoles) { opPos.put(atomicRole, getPropertyMembers(atomicRole)); + progressMonitor.reasonerTaskProgressChanged(cnt++, size); } logger.debug("dematerialising datatype properties"); @@ -368,18 +381,22 @@ for (DatatypeProperty dp : booleanDatatypeProperties) { bdPos.put(dp, (TreeSet<Individual>) getTrueDatatypeMembers(dp)); bdNeg.put(dp, (TreeSet<Individual>) getFalseDatatypeMembers(dp)); + progressMonitor.reasonerTaskProgressChanged(cnt++, size); } for (DatatypeProperty dp : intDatatypeProperties) { id.put(dp, getIntDatatypeMembers(dp)); + progressMonitor.reasonerTaskProgressChanged(cnt++, size); } for (DatatypeProperty dp : doubleDatatypeProperties) { dd.put(dp, getDoubleDatatypeMembers(dp)); + progressMonitor.reasonerTaskProgressChanged(cnt++, size); } long dematDuration = System.currentTimeMillis() - dematStartTime; logger.debug("TBox dematerialised in " + dematDuration + " ms"); + progressMonitor.reasonerTaskStopped(); } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2010-06-14 09:10:38 UTC (rev 2163) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2010-06-15 14:08:31 UTC (rev 2164) @@ -19,20 +19,20 @@ */ package org.dllearner.tools.protege; -import java.awt.Cursor; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.List; -import java.util.Set; import java.util.Timer; import java.util.TimerTask; import javax.swing.JOptionPane; -import javax.swing.SwingUtilities; import javax.swing.SwingWorker; import org.dllearner.core.EvaluatedDescription; +import org.dllearner.utilities.owl.OWLAPIDescriptionConvertVisitor; +import org.protege.editor.core.ProtegeApplication; +import org.protege.editor.core.ui.progress.BackgroundTask; /** * This class processes input from the user. @@ -66,6 +66,8 @@ private static final String EQUIVALENT_CLASS_LEARNING_STRING = "<html>suggest equivalent class expression</html>"; private static final String SUPER_CLASS_LEARNING_STRING = "<html>suggest super class expression</html>"; private static JOptionPane optionPane; + + private BackgroundTask learningTask; /** * This is the constructor for the action handler. @@ -96,52 +98,29 @@ if (z.getActionCommand().equals(EQUIVALENT_CLASS_LEARNING_STRING) || z.getActionCommand().equals(SUPER_CLASS_LEARNING_STRING)) { - + Manager manager = Manager.getInstance(model.getOWLEditorKit()); setLearningOptions(); + view.setBusyTaskStarted("Preparing ..."); + manager.initLearningProblem(); + manager.initLearningAlgorithm(); + view.setBusyTaskEnded(); - Manager manager = Manager.getInstance(model.getOWLEditorKit()); -// manager.initKnowledgeSource(); -// manager.initReasoner(); -// manager.initLearningProblem(); -// manager.initLearningAlgorithm(); - view.setBusy(true); - manager.init(); - view.getRunButton().setEnabled(false); - String moreInformationsMessage = "<html><font size=\"3\">Learning started. Currently searching class expressions with length between " - + manager.getMinimumHorizontalExpansion() - + " and " - + manager.getMaximumHorizontalExpansion() + ".</font></html>"; - view.setHelpButtonVisible(true); - view.setHintMessage(moreInformationsMessage); + learningTask = ProtegeApplication.getBackgroundTaskManager().startTask("Learning..."); + + view.setLearningStarted(); + view.showHorizontalExpansionMessage(Manager.getInstance().getMinimumHorizontalExpansion(), + Manager.getInstance().getMaximumHorizontalExpansion()); + retriever = new SuggestionRetriever(); retriever.addPropertyChangeListener(view.getStatusBar()); retriever.execute(); - //######################################################################### -// model.setKnowledgeSource(); - -// view.getSuggestClassPanel().getSuggestionsTable().clear(); -// view.getSuggestClassPanel().repaint(); -// model.setLearningProblem(); -// model.setLearningAlgorithm(); -// view.getRunButton().setEnabled(false); -// view.getHintPanel().setForeground(Color.RED); -// CELOE celoe = (CELOE) model.getLearningAlgorithm(); -// -// String moreInformationsMessage = "<html><font size=\"3\">Learning started. Currently searching class expressions with length between " -// + celoe.getMinimumHorizontalExpansion() -// + " and " -// + celoe.getMaximumHorizontalExpansion() + ".</font></html>"; -// view.setHelpButtonVisible(true); -// view.setHintMessage(moreInformationsMessage); -// retriever = new SuggestionRetriever(); -// retriever.addPropertyChangeListener(view.getStatusBar()); -// retriever.execute(); } if (z.getActionCommand().equals(ADD_BUTTON_STRING)) { - model.changeDLLearnerDescriptionsToOWLDescriptions(evaluatedDescription.getDescription()); + Manager.getInstance().addAxiom(OWLAPIDescriptionConvertVisitor + .getOWLClassExpression(evaluatedDescription.getDescription())); String message = "<html><font size=\"3\">class expression added</font></html>"; view.setHintMessage(message); view.setHelpButtonVisible(false); @@ -159,14 +138,7 @@ } if (z.toString().contains(HELP_BUTTON_STRING)) { - Set<String> uris = model.getOntologyURIString(); - String currentClass = ""; - for (String uri : uris) { - if (model.getCurrentConcept().toString().contains(uri)) { - currentClass = model.getCurrentConcept() - .toManchesterSyntaxString(uri, null); - } - } + String currentClass = Manager.getInstance().getCurrentlySelectedClassRendered(); //helpPanel.renderHelpTextMessage(currentClass); //view.getLearnerView().add(); @@ -223,16 +195,14 @@ @Override protected List<? extends EvaluatedDescription> doInBackground() throws Exception { - - view.setStatusBarVisible(true); - view.getStatusBar().setMaximumValue(Manager.getInstance().getMaxExecutionTimeInSeconds()); + timer = new Timer(); timer.schedule(new TimerTask(){ int progress = 0; List<? extends EvaluatedDescription> result; @Override public void run() { - progress += 1; + progress++; setProgress(progress); if(!isCancelled() && Manager.getInstance().isLearning()){ result = Manager.getInstance().getCurrentlyLearnedDescriptions(); @@ -249,46 +219,28 @@ @Override public void done() { - timer.cancel(); List<? extends EvaluatedDescription> result = Manager.getInstance().getCurrentlyLearnedDescriptions(); - setProgress(0); - view.stopStatusBar(); - view.setBusy(false); updateList(result); - view.showAlgorithmTerminatedMessage(); - + setProgress(0); + view.setLearningFinished(); + ProtegeApplication.getBackgroundTaskManager().endTask(learningTask); } @Override - protected void process( - List<List<? extends EvaluatedDescription>> resultLists) { - + protected void process(List<List<? extends EvaluatedDescription>> resultLists) { for (List<? extends EvaluatedDescription> list : resultLists) { updateList(list); } } - private void updateList( - final List<? extends EvaluatedDescription> result) { + private void updateList(final List<? extends EvaluatedDescription> result) { + model.setSuggestList(result); + view.setSuggestions(result); + view.showHorizontalExpansionMessage(Manager.getInstance().getMinimumHorizontalExpansion(), + Manager.getInstance().getMaximumHorizontalExpansion()); - Runnable doUpdateList = new Runnable() { - - public void run() { - model.setSuggestList(result); - view.getSuggestClassPanel().addSuggestions(result); - String moreInformationsMessage = "<html><font size=\"3\">Learning started. Currently searching class expressions with length between " - + Manager.getInstance().getMinimumHorizontalExpansion() - + " and " - + Manager.getInstance().getMaximumHorizontalExpansion() - + ".</font></html>"; - view.setHintMessage(moreInformationsMessage); - } - }; - SwingUtilities.invokeLater(doUpdateList); - } - } - + } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2010-06-14 09:10:38 UTC (rev 2163) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2010-06-15 14:08:31 UTC (rev 2164) @@ -235,6 +235,7 @@ public void setReasoner() { this.reasoner = cm.reasoner(ProtegeReasoner.class, sources); reasoner.setOWLReasoner(editor.getOWLModelManager().getReasoner()); + reasoner.setProgressMonitor(view.getStatusBar()); // this.reasoner = new ProtegeReasoner(sources, editor.getOWLModelManager().getReasoner()); try { reasoner.init(); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java 2010-06-14 09:10:38 UTC (rev 2163) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java 2010-06-15 14:08:31 UTC (rev 2164) @@ -28,6 +28,7 @@ import java.awt.GridBagLayout; import java.awt.event.ActionListener; import java.net.URL; +import java.util.List; import java.util.Set; import javax.swing.DefaultListModel; @@ -40,6 +41,7 @@ import javax.swing.JTextPane; import javax.swing.JToggleButton; +import org.dllearner.core.EvaluatedDescription; import org.protege.editor.owl.OWLEditorKit; import org.semanticweb.owlapi.model.OWLClassExpression; /** @@ -121,7 +123,7 @@ private String labels; private int individualSize; private SuggestClassPanelHandler sugPanelHandler; - private StatusBar stat; + private StatusBar statusBar; private static final String WIKI_STRING = "<html><font size=\"3\">See <a href=\"http://dl-learner.org/wiki/ProtegePlugin\">DL-Learner plugin page</a> for an introduction.</font></html>"; /** @@ -166,14 +168,14 @@ runPanel = new JPanel(new FlowLayout()); accept = new JButton("<html>ADD</html>"); addButtonPanel = new JPanel(new BorderLayout()); - stat = new StatusBar(); - stat.setBackground(learnerScroll.getBackground()); + statusBar = new StatusBar(); + statusBar.setBackground(learnerScroll.getBackground()); this.setStatusBarVisible(false); hint = new JTextPane(); hint.setBackground(learnerScroll.getBackground()); hint.setContentType("text/html"); hint.setEditable(false); - hint.setText("<html><font size=\"3\">To get suggestions for class expression, please click the button above.</font></html>"); +// hint.setText("<html><font size=\"3\">To get suggestions for class expression, please click the button above.</font></html>"); learner = new JPanel(); advanced.setSize(20, 20); learner.setLayout(new GridBagLayout()); @@ -216,7 +218,7 @@ helpButton.setVisible(false); hint.setForeground(Color.BLACK); - hint.setText("<html><font size=\"3\">To get suggestions for class expression, please click the button above.</font></html>"); +// hint.setText("<html><font size=\"3\">To get suggestions for class expression, please click the button above.</font></html>"); String currentConcept = editorKit.getOWLWorkspace().getOWLSelectionModel().getLastSelectedClass().toString(); if(!labels.equals(currentConcept) || individualSize != editorKit.getModelManager().getActiveOntology().getIndividualsInSignature(true).size()) { if(individualSize != editorKit.getModelManager().getActiveOntology().getIndividualsInSignature(true).size()) { @@ -274,7 +276,7 @@ c.weighty = 0.0; c.gridx = 0; c.gridy = 2; - learner.add(stat, c); + learner.add(statusBar, c); c.fill = GridBagConstraints.BOTH; c.weightx = 0.0; @@ -350,7 +352,7 @@ * is started. */ public void setStatusBarVisible(boolean b) { - stat.setVisible(b); + statusBar.setVisible(b); } /** * This method enables the GraphicalCoveragePanel after a class expression is @@ -573,14 +575,14 @@ * This method starts the status bar. */ public void startStatusBar() { - stat.showProgress(true); + statusBar.showProgress(true); } /** * This method stops the status bar. */ public void stopStatusBar() { - stat.showProgress(false); + statusBar.showProgress(false); } /** @@ -588,7 +590,7 @@ * @return statusbar */ public StatusBar getStatusBar() { - return stat; + return statusBar; } public HyperLinkHandler getHyperLinkHandler() { @@ -604,4 +606,49 @@ } + public void setBusyTaskStarted(String taskName){ + setBusy(true); + setHelpButtonVisible(true); + setStatusBarVisible(true); + statusBar.showProgress(true); + statusBar.setMessage(taskName); + } + + public void setBusyTaskEnded(){ + setBusy(false); + setHelpButtonVisible(false); + setStatusBarVisible(false); + statusBar.showProgress(false); + statusBar.setMessage(""); + } + + public void setLearningStarted(){ + setBusy(true); + setHelpButtonVisible(true); + setStatusBarVisible(true); + run.setEnabled(false); + statusBar.setMaximumValue(Manager.getInstance().getMaxExecutionTimeInSeconds()); + statusBar.setMessage("Learning ..."); + } + + public void setLearningFinished(){ + stopStatusBar(); + setBusy(false); + showAlgorithmTerminatedMessage(); + } + + public void showHorizontalExpansionMessage(int min, int max){ + StringBuffer sb = new StringBuffer(); + sb.append("<html><font size=\"3\">Currently searching class expressions with length between "); + sb.append(min); + sb.append(" and "); + sb.append(max); + sb.append(".</font></html>"); + setHintMessage(sb.toString()); + } + + public void setSuggestions(List<? extends EvaluatedDescription> suggestions){ + sugPanel.setSuggestions(suggestions); + } + } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java 2010-06-14 09:10:38 UTC (rev 2163) +++ trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java 2010-06-15 14:08:31 UTC (rev 2164) @@ -62,7 +62,6 @@ private Ellipse2D newConcept; private EvaluatedDescription eval; - private final DLLearnerModel model; private String conceptNew; private final Vector<IndividualPoint> posCovIndVector; private final Vector<IndividualPoint> posNotCovIndVector; @@ -102,16 +101,17 @@ this.setVisible(false); this.setForeground(Color.GREEN); eval = desc; - model = m; - id = model.getID(); +// id = model.getID(); + id = EQUI_STRING; darkGreen = new Color(0, 100, 0); darkRed = new Color(205, 0, 0); random = new Random(); - for(String uri : model.getOntologyURIString()) { - if(eval.getDescription().toString().contains(uri)) { - conceptNew = eval.getDescription().toManchesterSyntaxString(uri, null); - } - } +// for(String uri : model.getOntologyURIString()) { +// if(eval.getDescription().toString().contains(uri)) { +// conceptNew = eval.getDescription().toManchesterSyntaxString(uri, null); +// } +// } + conceptNew = Manager.getInstance().getRendering(eval.getDescription()); conceptVector = new Vector<String>(); posCovIndVector = new Vector<IndividualPoint>(); @@ -119,7 +119,7 @@ additionalIndividuals = new Vector<IndividualPoint>(); points = new Vector<IndividualPoint>(); this.computeGraphics(); - handler = new GraphicalCoveragePanelHandler(this, desc, model); + handler = new GraphicalCoveragePanelHandler(this, desc); if(shiftXAxis == 0) { oldConcept = new Ellipse2D.Double(ELLIPSE_X_AXIS + (2 * adjustment)+3, ELLIPSE_Y_AXIS+3, WIDTH, HEIGHT); @@ -137,7 +137,7 @@ + adjustment, ELLIPSE_Y_AXIS, WIDTH + distortionOld, HEIGHT + distortionOld); } - factory = model.getOWLEditorKit().getOWLModelManager().getOWLDataFactory(); + factory = Manager.getInstance().getActiveOntology().getOWLOntologyManager().getOWLDataFactory(); this.computeIndividualPoints(); this.addMouseMotionListener(handler); this.addMouseListener(handler); @@ -159,8 +159,7 @@ g2D.setColor(Color.BLACK); // Plus 1 - if (coveredIndividualSize != model.getReasoner().getIndividuals( - model.getCurrentConcept()).size() + if (coveredIndividualSize != Manager.getInstance().getIndividuals().size() && notCoveredInd != 0) { g2D.drawLine(x1 - 1 - shiftOldConcept, y1 - 1, x2 + 1 - shiftOldConcept, y1 - 1); @@ -211,8 +210,7 @@ y2 + 1); // Plus 3 - if (coveredIndividualSize != model.getReasoner().getIndividuals( - model.getCurrentConcept()).size() && ((EvaluatedDescriptionClass) eval).getAdditionalInstances().size() != 0) { + if (coveredIndividualSize != Manager.getInstance().getIndividuals().size() && ((EvaluatedDescriptionClass) eval).getAdditionalInstances().size() != 0) { g2D.drawLine(x1 - 1 + shiftNewConcept, y1 - 1, x2 + 1 + shiftNewConcept, y1 - 1); g2D.drawLine(x1 + shiftNewConcept, centerY - 1, x2 @@ -407,13 +405,8 @@ + this.getShiftCovered() && y >= this.getY1() && y <= this .getY2())) { - Set<String> uriString = model.getOntologyURIString(); - for(String uri : uriString) { - if(ind.toString().contains(uri)) { - posCovIndVector.add(new IndividualPoint("*", - (int) x, (int) y, ind.toManchesterSyntaxString(uri, null), factory.getOWLNamedIndividual(IRI.create(ind.getURI())), ind, uri)); - } - } + posCovIndVector.add(new IndividualPoint("*", + (int) x, (int) y, Manager.getInstance().getRendering(ind), factory.getOWLNamedIndividual(IRI.create(ind.getURI())), ind, "")); i++; flag = false; @@ -455,21 +448,11 @@ .getY2() + this.getShiftNewConcept())) { if (id.equals(EQUI_STRING)) { - Set<String> uriString = model.getOntologyURIString(); - for(String uri : uriString) { - if(ind.toString().contains(uri)) { - posNotCovIndVector.add(new IndividualPoint("*", - (int) x, (int) y, ind.toManchesterSyntaxString(uri, null), factory.getOWLNamedIndividual(IRI.create(ind.getURI())), ind, uri)); - } - } + posNotCovIndVector.add(new IndividualPoint("*", + (int) x, (int) y, Manager.getInstance().getRendering(ind), factory.getOWLNamedIndividual(IRI.create(ind.getURI())), ind, "")); } else { - Set<String> uriString = model.getOntologyURIString(); - for(String uri : uriString) { - if(ind.toString().contains(uri)) { - additionalIndividuals.add(new IndividualPoint("*", - (int) x, (int) y, ind.toManchesterSyntaxString(uri, null), factory.getOWLNamedIndividual(IRI.create(ind.getURI())), ind, uri)); - } - } + additionalIndividuals.add(new IndividualPoint("*", + (int) x, (int) y, Manager.getInstance().getRendering(ind), factory.getOWLNamedIndividual(IRI.create(ind.getURI())), ind, "")); } j++; flag = false; @@ -485,8 +468,7 @@ } } - Set<Individual> notCovInd = model.getReasoner().getIndividuals( - model.getCurrentConcept()); + Set<Individual> notCovInd = Manager.getInstance().getIndividuals(); notCovInd.removeAll(posInd); notCoveredInd = notCovInd.size(); int k = 0; @@ -504,13 +486,8 @@ - this.getShiftOldConcept() && y >= this.getY1() && y <= this .getY2())) { - Set<String> uriString = model.getOntologyURIString(); - for(String uri : uriString) { - if(ind.toString().contains(uri)) { - posNotCovIndVector.add(new IndividualPoint("*", - (int) x, (int) y, ind.toManchesterSyntaxString(uri, null), factory.getOWLNamedIndividual(IRI.create(ind.getURI())), ind, uri)); - } - } + posNotCovIndVector.add(new IndividualPoint("*", + (int) x, (int) y, Manager.getInstance().getRendering(ind), factory.getOWLNamedIndividual(IRI.create(ind.getURI())), ind, "")); k++; flag = false; x = random.nextInt(MAX_RANDOM_NUMBER); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanelHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanelHandler.java 2010-06-14 09:10:38 UTC (rev 2163) +++ trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanelHandler.java 2010-06-15 14:08:31 UTC (rev 2164) @@ -57,7 +57,6 @@ private final GraphicalCoveragePanel panel; private final EvaluatedDescription description; - private final DLLearnerModel model; private BasicComboPopup scrollPopup; private final Vector<String> individualComboBox; private JComboBox indiBox; @@ -74,12 +73,10 @@ * DLLearnerModel */ public GraphicalCoveragePanelHandler(GraphicalCoveragePanel p, - EvaluatedDescription eval, DLLearnerModel m) { + EvaluatedDescription eval) { this.panel = p; description = eval; - model = m; - ontology = model.getOWLEditorKit().getOWLModelManager() - .getActiveOntology(); + ontology = Manager.getInstance().getActiveOntology(); individualComboBox = new Vector<String>(); } @@ -116,7 +113,7 @@ } Vector<IndividualPoint> v = panel.getIndividualVector(); - ProtegeReasoner reasoner = model.getReasoner(); + ProtegeReasoner reasoner = Manager.getInstance().getReasoner(); for (int i = 0; i < v.size(); i++) { if (v.get(i).getXAxis() >= m.getX() - 5 && v.get(i).getXAxis() <= m.getX() + 5 @@ -227,13 +224,7 @@ int i = covInd.size(); if (i > 0) { for (Individual ind : covInd) { - Set<String> uriString = model.getOntologyURIString(); - for (String uri : uriString) { - if (ind.toString().contains(uri)) { - individualComboBox.add(ind - .toManchesterSyntaxString(uri, null)); - } - } + individualComboBox.add(Manager.getInstance().getRendering(ind)); } indiBox = new JComboBox(individualComboBox); scrollPopup = new BasicComboPopup(indiBox); @@ -262,13 +253,7 @@ int i = addInd.size(); if (i > 0) { for (Individual ind : addInd) { - Set<String> uriString = model.getOntologyURIString(); - for (String uri : uriString) { - if (ind.toString().contains(uri)) { - individualComboBox.add(ind - .toManchesterSyntaxString(uri, null)); - } - } + individualComboBox.add(Manager.getInstance().getRendering(ind)); } indiBox = new JComboBox(individualComboBox); scrollPopup = new BasicComboPopup(indiBox); @@ -284,20 +269,13 @@ && arg0.getY() <= panel.getY2()) { individualComboBox.clear(); - Set<Individual> notCovInd = model.getReasoner().getIndividuals( - model.getCurrentConcept()); + Set<Individual> notCovInd = Manager.getInstance().getIndividuals(); notCovInd.removeAll(((EvaluatedDescriptionClass) description) .getCoveredInstances()); int i = notCovInd.size(); if (i > 0) { for (Individual ind : notCovInd) { - Set<String> uriString = model.getOntologyURIString(); - for (String uri : uriString) { - if (ind.toString().contains(uri)) { - individualComboBox.add(ind - .toManchesterSyntaxString(uri, null)); - } - } + individualComboBox.add(Manager.getInstance().getRendering(ind)); } indiBox = new JComboBox(individualComboBox); scrollPopup = new BasicComboPopup(indiBox); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoverageTextField.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoverageTextField.java 2010-06-14 09:10:38 UTC (rev 2163) +++ trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoverageTextField.java 2010-06-15 14:08:31 UTC (rev 2164) @@ -32,7 +32,8 @@ private final String id; private DLLearnerModel model; EvaluatedDescription description; - private String conceptNew; + private String newConceptRendered; + private String oldConceptRendered; //private final JScrollPane textScroll; public GraphicalCoverageTextField(EvaluatedDescription desc, DLLearnerModel m) { @@ -45,41 +46,46 @@ this.setBackground(model.getOWLEditorKit().getOWLWorkspace().getOWLComponentFactory().getOWLClassSelectorPanel().getBackground()); this.id = model.getID(); this.description = desc; - - for(String uri : model.getOntologyURIString()) { - if(description.getDescription().toString().contains(uri)) { - conceptNew = description.getDescription().toManchesterSyntaxString(uri, null); - } - } + Manager manager = Manager.getInstance(); + newConceptRendered = manager.getRendering(desc.getDescription()); + oldConceptRendered = manager.getRendering(manager.getCurrentlySelectedClass()); this.setText(); } private void setText() { - int coveredInstances = ((EvaluatedDescriptionClass) description).getCoveredInstances().size(); - int allInstances = coveredInstances + ((EvaluatedDescriptionClass) description).getNotCoveredInstances().size(); + int coveredInstancesCount = ((EvaluatedDescriptionClass) description).getCoveredInstances().size(); + int allInstancesCount = coveredInstancesCount + ((EvaluatedDescriptionClass) description).getNotCoveredInstances().size(); + int additionalInstancesCount = ((EvaluatedDescriptionClass) description).getAdditionalInstances().size(); int coverage = (int)(((EvaluatedDescriptionClass) description).getCoverage() * 100); - String text ="<html><p><font size=\"3\" color=\"yellow\">\u25cf</font><font size=\"3\" color=\"black\"> " + model.getOldConceptOWLAPI().toString() + "</font></p>" + - "<p style=\"max-width:50px;\"><font size=\"3\" color=\"EE9A00\">\u25cf</font><font size=\"3\" color=\"black\"> " + conceptNew + "</font></p>" + - "<p><font size=\"1\" color=\"green\">\u25aa </font><font size=\"3\" color=\"black\">individuals covered by </font> <font size=\"3\" color=\"EE9A00\">\u25cf</font>" + - "<font size=\"3\" color=\"black\"> and </font> <font size=\"3\" color=\"yellow\">\u25cf</font><font size=\"3\" color=\"black\"> (OK)</font></p> "; - if(id.equals(EQUI_STRING)) { - text += "<p><font size=\"1\" color=\"red\">\u25aa </font><font size=\"3\" color=\"black\">individuals covered by </font><font size=\"3\" color=\"EE9A00\">\u25cf</font></font><font size=\"3\" color=\"black\"> (potential problem)</font></p>" + - "<p><font size=\"1\" color=\"red\">\u25aa </font><font size=\"3\" color=\"black\">individuals covered by </font><font size=\"3\" color=\"yellow\">\u25cf</font></font><font size=\"3\" color=\"black\"> (potential problem)</font></p>"; - } else { - text += "<p><font size=\"1\" color=\"green\">\u25aa </font><font size=\"3\" color=\"black\">individuals covered by </font><font size=\"3\" color=\"EE9A00\">\u25cf</font></font><font size=\"3\" color=\"black\"> (no problem)</font></p>" + - "<p><font size=\"1\" color=\"red\">\u25aa </font><font size=\"3\" color=\"black\">individuals covered by </font><font size=\"3\" color=\"yellow\">\u25cf</font></font><font size=\"3\" color=\"black\"> (potential problem)</font></p>";; - } - text += "<p><font size=\"3\" color=\"black\">Covers " + coveredInstances + - " of " + allInstances + "(" + coverage + " %) of class instances</font></p>" + - "<p><font size=\"3\" color=\"black\">Covers " + ((EvaluatedDescriptionClass) description).getAdditionalInstances().size() + " additional instances</font></p>"; - if(!((EvaluatedDescriptionClass) description).isConsistent()) { - text += "<p style=\"max-width:100px;\"><font size=\"3\" color=\"red\">Adding this class expression may lead to an inconsistent ontology.</font></p>"; - } - if(description.getAccuracy() == 1.0) { - text += "<p><font size=\"3\" color=\"EE9A00\">\u25cf</font><font size=\"3\" color=\"black\"> and </font> <font size=\"3\" color=\"yellow\">\u25cf</font> cover the same instances.</p>"; - } - text += "</html>"; - this.setText(text); + + StringBuffer sb = new StringBuffer(); + sb.append("<html><p><font size=\"3\" color=\"yellow\">\u25cf</font><font size=\"3\" color=\"black\"> "); + sb.append(oldConceptRendered); + sb.append("</font></p>"); + sb.append("<p style=\"max-width:50px;\"><font size=\"3\" color=\"EE9A00\">\u25cf</font><font size=\"3\" color=\"black\"> "); + sb.append(newConceptRendered); + sb.append("</font></p>"); + sb.append("<p><font size=\"1\" color=\"green\">\u25aa </font><font size=\"3\" color=\"black\">individuals covered by </font> <font size=\"3\" color=\"EE9A00\">\u25cf</font>"); + sb.append("<font size=\"3\" color=\"black\"> and </font> <font size=\"3\" color=\"yellow\">\u25cf</font><font size=\"3\" color=\"black\"> (OK)</font></p> "); + if(id.equals(EQUI_STRING)){ + sb.append("<p><font size=\"1\" color=\"red\">\u25aa </font><font size=\"3\" color=\"black\">individuals covered by </font><font size=\"3\" color=\"EE9A00\">\u25cf</font></font><font size=\"3\" color=\"black\"> (potential problem)</font></p>"); + sb.append("<p><font size=\"1\" color=\"red\">\u25aa </font><font size=\"3\" color=\"black\">individuals covered by </font><font size=\"3\" color=\"yellow\">\u25cf</font></font><font size=\"3\" color=\"black\"> (potential problem)</font></p>"); + } else { + sb.append("<p><font size=\"1\" color=\"green\">\u25aa </font><font size=\"3\" color=\"black\">individuals covered by </font><font size=\"3\" color=\"EE9A00\">\u25cf</font></font><font size=\"3\" color=\"black\"> (no problem)</font></p>"); + sb.append("<p><font size=\"1\" color=\"red\">\u25aa </font><font size=\"3\" color=\"black\">individuals covered by </font><font size=\"3\" color=\"yellow\">\u25cf</font></font><font size=\"3\" color=\"black\"> (potential problem)</font></p>"); + } + sb.append("<p><font size=\"3\" color=\"black\">Covers ").append(coveredInstancesCount).append(" of ").append(allInstancesCount).append("(").append(coverage).append(" %) of class instances</font></p>"); + sb.append("<p><font size=\"3\" color=\"black\">Covers ").append(additionalInstancesCount).append(" additional instances</font></p>"); + if(!((EvaluatedDescriptionClass) description).isConsistent()) { + sb.append("<p style=\"max-width:100px;\"><font size=\"3\" color=\"red\">Adding this class expression may lead to an inconsistent ontology.</font></p>"); + } + if(description.getAccuracy() == 1.0) { + sb.append("<p><font size=\"3\" color=\"EE9A00\">\u25cf</font><font size=\"3\" color=\"black\"> and </font> <font size=\"3\" color=\"yellow\">\u25cf</font> cover the same instances.</p>"); + } + sb.append("</html>"); + + + this.setText(sb.toString()); //textScroll.setViewportView(this); } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/Manager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/Manager.java 2010-06-14 09:10:38 UTC (rev 2163) +++ trunk/src/dl-learner/org/dllearner/tools/protege/Manager.java 2010-06-15 14:08:31 UTC (rev 2164) @@ -3,6 +3,7 @@ import java.net.MalformedURLException; import java.util.Collections; import java.util.List; +import java.util.SortedSet; import org.dllearner.algorithms.celoe.CELOE; import org.dllearner.core.ComponentInitException; @@ -11,22 +12,35 @@ import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; import org.dllearner.core.LearningProblemUnsupportedException; +import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.Individual; import org.dllearner.kb.OWLAPIOntology; import org.dllearner.learningproblems.ClassLearningProblem; import org.dllearner.learningproblems.EvaluatedDescriptionClass; import org.dllearner.reasoning.ProtegeReasoner; import org.dllearner.tools.ore.LearningManager.LearningType; +import org.dllearner.utilities.owl.OWLAPIConverter; +import org.dllearner.utilities.owl.OWLAPIDescriptionConvertVisitor; import org.protege.editor.owl.OWLEditorKit; import org.protege.editor.owl.model.event.EventType; import org.protege.editor.owl.model.event.OWLModelManagerChangeEvent; import org.protege.editor.owl.model.event.OWLModelManagerListener; import org.protege.editor.owl.model.selection.OWLSelectionModelListener; +import org.semanticweb.owlapi.model.AddAxiom; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyChange; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.reasoner.ReasonerProgressMonitor; public class Manager implements OWLModelManagerListener, OWLSelectionModelListener{ private static Manager instance; private OWLEditorKit editorKit; + private ReasonerProgressMonitor progressMonitor; private boolean reinitNecessary = true; @@ -136,6 +150,7 @@ public void initReasoner(){ reasoner = cm.reasoner(ProtegeReasoner.class, ks); reasoner.setOWLReasoner(editorKit.getOWLModelManager().getReasoner()); + reasoner.setProgressMonitor(progressMonitor); try { reasoner.init(); } catch (ComponentInitException e) { @@ -143,6 +158,52 @@ } } + public void initReasonerAsynchronously(){ + reasoner = cm.reasoner(ProtegeReasoner.class, ks); + reasoner.setOWLReasoner(editorKit.getOWLModelManager().getReasoner()); + reasoner.setProgressMonitor(progressMonitor); + Thread t = new Thread(new Runnable() { + @Override + public void run() { + try { + reasoner.init(); + } catch (ComponentInitException e) { + e.printStackTrace(); + } + } + }); + t.start(); + } + + public void addAxiom(OWLClassExpression description){ + OWLClass selectedClass = editorKit.getOWLWorkspace().getOWLSelectionModel().getLastSelectedClass(); + if(learningType == LearningType.EQUIVALENT){ + addEquivalentClassesAxiom(selectedClass, description); + } else { + addSuperClassAxiom(selectedClass, description); + } + } + + private void addSuperClassAxiom(OWLClassExpression subClass, OWLClassExpression superClass){ + OWLOntology ontology = editorKit.getOWLModelManager().getActiveOntology(); + OWLOntologyManager manager = ontology.getOWLOntologyManager(); + OWLAxiom subClassAxiom = manager.getOWLDataFactory().getOWLSubClassOfAxiom(subClass, superClass); + OWLOntologyChange change = new AddAxiom(ontology, subClassAxiom); + manager.applyChange(change); + } + + private void addEquivalentClassesAxiom(OWLClassExpression equiv1, OWLClassExpression equiv2){ + OWLOntology ontology = editorKit.getOWLModelManager().getActiveOntology(); + OWLOntologyManager manager = ontology.getOWLOntologyManager(); + OWLAxiom equivalentClassesAxiom = manager.getOWLDataFactory().getOWLEquivalentClassesAxiom(equiv1, equiv2); + OWLOntologyChange change = new AddAxiom(ontology, equivalentClassesAxiom); + manager.applyChange(change); + } + + public void setProgressMonitor(ReasonerProgressMonitor progressMonitor){ + this.progressMonitor = progressMonitor; + } + public void startLearning(){ la.start(); } @@ -230,7 +291,55 @@ public int getMaximumHorizontalExpansion(){ return ((CELOE)la).getMaximumHorizontalExpansion(); } - + + public boolean isConsistent(){ + return reasoner.isConsistent(); + } + + public SortedSet<Individual> getIndividuals(){ + OWLClass selectedClass = editorKit.getOWLWorkspace().getOWLSelectionModel().getLastSelectedClass(); + return reasoner.getIndividuals(OWLAPIConverter.convertClass(selectedClass)); + } + + public boolean canLearn(){ + OWLClass selectedClass = editorKit.getOWLWorkspace().getOWLSelectionModel().getLastSelectedClass(); + boolean canLearn = reasoner.getIndividuals(OWLAPIConverter.convertClass(selectedClass)).size() > 0; + return canLearn; + } + + public String getRendering(Description desc){ + String rendering = editorKit.getModelManager().getRendering( + OWLAPIDescriptionConvertVisitor.getOWLClassExpression(desc)); + return rendering; + } + + public String getRendering(OWLClass cl){ + String rendering = editorKit.getModelManager().getRendering(cl); + return rendering; + } + + public String getRendering(Individual ind){ + String rendering = editorKit.getModelManager().getRendering( + OWLAPIConverter.getOWLAPIIndividual(ind)); + return rendering; + } + + public ProtegeReasoner getReasoner(){ + return reasoner; + } + + public OWLOntology getActiveOntology(){ + return editorKit.getOWLModelManager().getActiveOntology(); + } + + public OWLClass getCurrentlySelectedClass(){ + return editorKit.getOWLWorkspace().getOWLSelectionModel().getLastSelectedClass(); + } + + public String getCurrentlySelectedClassRendered(){ + return getRendering(getCurrentlySelectedClass()); + } + @Override public void handleChange(OWLModelManagerChangeEvent event) { if(event.isType(EventType.REASONER_CHANGED) || event.isType(EventType.ACTIVE_ONTOLOGY_CHANGED)){ Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java 2010-06-14 09:10:38 UTC (rev 2163) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java 2010-06-15 14:08:31 UTC (rev 2164) @@ -79,6 +79,7 @@ @Override public void initialise() throws Exception { view = new DLLearnerView(super.getOWLEditorKit()); + Manager.getInstance(getOWLEditorKit()).setProgressMonitor(view.getStatusBar()); System.out.println("Initializing DL-Learner plugin..."); addListeners(); } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ReadingOntologyThread.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ReadingOntologyThread.java 2010-06-14 09:10:38 UTC (rev 2163) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ReadingOntologyThread.java 2010-06-15 14:08:31 UTC (rev 2164) @@ -32,7 +32,7 @@ import org.semanticweb.owlapi.model.OWLClass; /** - * This class reads the ontologie in a separate thread. + * This class reads the ontology in a separate thread. * * @author Christian Koetteritzsch * @@ -172,40 +172,58 @@ @Override public void run() { - String loading = "<html><font size=\"3\">loading instances...</font></html>"; + view.setStatusBarVisible(true); + view.setBusy(true); + Manager.getInstance().initKnowledgeSource(); + Manager.getInstance().initReasoner(); + view.setStatusBarVisible(false); + view.setBusy(false); + if(Manager.getInstance().canLearn()){ + view.getRunButton().setEnabled(true); + view + .setHintMessage("<html><font size=\"3\">To get suggestions for class descriptions, please click the button above.</font></html>"); + } else { + String message = "<html><font size=\"3\" color=\"red\">There are no instances for " + + current + + " available. Please insert some instances.</font></html>"; view.getHintPanel().setForeground(Color.RED); - view.setHintMessage(loading); - if (!model.isReasonerSet() - || model.getIsKnowledgeSourceIsUpdated() == true) { - model.setKnowledgeSource(); - model.setReasoner(); + view.setHintMessage(message); } - reasoner = model.getReasoner(); - isInconsistent = view.getIsInconsistent(); - if (!isInconsistent) { - this.checkURI(); - this.setPositiveConcept(); - if (this.hasIndividuals()) { - view.getRunButton().setEnabled(true); - view.getHintPanel().setForeground(Color.BLACK); - view - .setHintMessage("<html><font size=\"3\">To get suggestions for class descriptions, please click the button above.</font></html>"); - - } else { - view.getRunButton().setEnabled(false); - view.getHintPanel().setVisible(true); - String message = "<html><font size=\"3\" color=\"red\">There are no Instances for " - + current - + " available. Please insert some Instances.</font></html>"; - view.getHintPanel().setForeground(Color.RED); - view.setHintMessage(message); - } - } else { - view.getHintPanel().setForeground(Color.RED); - view.getRunButton().setEnabled(false); - view - .setHintMessage("The ontology is inconsistent and suggestions for class descriptions can only \nbe computed on consistent ontologies. Please repair the ontology first"); - } + +// String loading = "<html><font size=\"3\">loading instances...</font></html>"; +// view.getHintPanel().setForeground(Color.RED); +// view.setHintMessage(loading); +// if (!model.isReasonerSet() +// || model.getIsKnowledgeSourceIsUpdated() == true) { +// model.setKnowledgeSource(); +// model.setReasoner(); +// } +// reasoner = model.getReasoner(); +// isInconsistent = view.getIsInconsistent(); +// if (!isInconsistent) { +// this.checkURI(); +// this.setPositiveConcept(); +// if (this.hasIndividuals()) { +// view.getRunButton().setEnabled(true); +// view.getHintPanel().setForeground(Color.BLACK); +// view +// .setHintMessage("<html><font size=\"3\">To get suggestions for class descriptions, please click the button above.</font></html>"); +// +// } else { +// view.getRunButton().setEnabled(false); +// view.getHintPanel().setVisible(true); +// String message = "<html><font size=\"3\" color=\"red\">There are no Instances for " +// + current +// + " available. Please insert some Instances.</font></html>"; +// view.getHintPanel().setForeground(Color.RED); +// view.setHintMessage(message); +// } +// } else { +// view.getHintPanel().setForeground(Color.RED); +// view.getRunButton().setEnabled(false); +// view +// .setHintMessage("The ontology is inconsistent and suggestions for class descriptions can only \nbe computed on consistent ontologies. Please repair the ontology first"); +// } } /** Modified: trunk/src/dl-learner/org/dllearner/tools/protege/StatusBar.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/StatusBar.java 2010-06-14 09:10:38 UTC (rev 2163) +++ trunk/src/dl-learner/org/dllearner/tools/protege/StatusBar.java 2010-06-15 14:08:31 UTC (rev 2164) @@ -14,7 +14,9 @@ import javax.swing.SwingUtilities; import javax.swing.Timer; -public class StatusBar extends JPanel implements PropertyChangeListener { +import org.semanticweb.owlapi.reasoner.ReasonerProgressMonitor; + +public class StatusBar extends JPanel implements PropertyChangeListener, ReasonerProgressMonitor { /** * */ @@ -114,4 +116,28 @@ } + @Override + public void reasonerTaskBusy() { + // TODO Auto-generated method stub + + } + + @Override + public void reasonerTaskProgressChanged(int value, int max) { + progressBar.setMaximum(max); + setProgress(value); + } + + @Override + public void reasonerTaskStarted(String message) { + setProgress(0); + setMessage(message); + } + + @Override + public void reasonerTaskStopped() { + setMessage(""); + setProgress(0); + } + } \ No newline at end of file Modified: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2010-06-14 09:10:38 UTC (rev 2163) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2010-06-15 14:08:31 UTC (rev 2164) @@ -96,7 +96,7 @@ } @SuppressWarnings("unchecked") - public void addSuggestions(List<? extends EvaluatedDescription> result){ + public void setSuggestions(List<? extends EvaluatedDescription> result){ suggestionTable.setSuggestions((List<EvaluatedDescriptionClass>)result); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2010-06-18 14:59:41
|
Revision: 2166 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2166&view=rev Author: lorenz_b Date: 2010-06-18 14:59:35 +0000 (Fri, 18 Jun 2010) Log Message: ----------- Fixed bug caused by trying to sort the learned class expression by accuracy. Started test class to check incrementally for unsatisfiable classes in large knowledgebases. Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestionsTable.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/test/IncrementalInconsistencyFinder.java Added: trunk/src/dl-learner/org/dllearner/test/IncrementalInconsistencyFinder.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/IncrementalInconsistencyFinder.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/test/IncrementalInconsistencyFinder.java 2010-06-18 14:59:35 UTC (rev 2166) @@ -0,0 +1,164 @@ +package org.dllearner.test; + +import java.util.HashSet; +import java.util.Set; + +import org.dllearner.utilities.owl.OWLVocabulary; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLDataFactory; +import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; +import org.semanticweb.owlapi.reasoner.Node; +import org.semanticweb.owlapi.reasoner.OWLReasoner; + +import com.clarkparsia.modularity.IncrementalClassifier; +import com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory; +import com.hp.hpl.jena.query.Query; +import com.hp.hpl.jena.query.QueryExecution; +import com.hp.hpl.jena.query.QueryExecutionFactory; +import com.hp.hpl.jena.query.QueryFactory; +import com.hp.hpl.jena.query.QuerySolution; +import com.hp.hpl.jena.query.ResultSet; +import com.hp.hpl.jena.rdf.model.RDFNode; + +public class IncrementalInconsistencyFinder { + + private static final String ENDPOINT_URL = "http://dbpedia-live.openlinksw.com/sparql"; + private static String DEFAULT_GRAPH_URI = "http://dbpedia.org"; + private static int RESULT_LIMIT = 10; + + private OWLOntology ontology; + private OWLOntologyManager manager; + private OWLDataFactory factory; + private OWLReasoner reasoner; + + private String endpointURI; + + public IncrementalInconsistencyFinder() throws OWLOntologyCreationException{ + manager = OWLManager.createOWLOntologyManager(); + ontology = manager.createOntology(); + factory = manager.getOWLDataFactory(); + reasoner = new IncrementalClassifier(ontology); + } + + private void checkForUnsatisfiableClasses(String endpointURI){ + this.endpointURI = endpointURI; + + Set<OWLDisjointClassesAxiom> disjointAxioms = retrieveDisjointClassAxioms(); + manager.addAxioms(ontology, disjointAxioms); + + for(OWLDisjointClassesAxiom ax : disjointAxioms){ + for(OWLClassExpression cl : ax.getClassExpressions()){ + Set<OWLSubClassOfAxiom> subClassOfAxioms = retrieveSubClassAxioms(cl.asOWLClass()); + manager.addAxioms(ontology, subClassOfAxioms); + } + } + + System.out.println(ontology.getLogicalAxioms()); + reasoner.prepareReasoner(); + Node<OWLClass> unsatisfiableClasses = reasoner.getUnsatisfiableClasses(); + System.out.println("Found " + unsatisfiableClasses.getSize() + " unsatisfiable classes:"); + System.out.println(unsatisfiableClasses.getEntities()); + } + + private Set<OWLDisjointClassesAxiom> retrieveDisjointClassAxioms(){ + Query sparqlQuery = createSimpleSelectSPARQLQuery("?x", OWLVocabulary.OWL_DISJOINT_WITH, "?y", + "regex(?x,\"http://dbpedia.org/ontology/\", \"i\")", RESULT_LIMIT); + QueryExecution sparqlQueryExec = QueryExecutionFactory.sparqlService(endpointURI, sparqlQuery, DEFAULT_GRAPH_URI); + ResultSet sparqlResults = sparqlQueryExec.execSelect(); + + Set<OWLDisjointClassesAxiom> axioms = new HashSet<OWLDisjointClassesAxiom>(); + while(sparqlResults.hasNext()){ + QuerySolution solution = sparqlResults.nextSolution(); + + RDFNode rdfNodeSubject = solution.getResource("?x"); + RDFNode rdfNodeObject = solution.getResource("?y"); + + OWLClass disjointClass1 = factory.getOWLClass(IRI.create(rdfNodeSubject.toString())); + OWLClass disjointClass2 = factory.getOWLClass(IRI.create(rdfNodeObject.toString())); + + axioms.add(factory.getOWLDisjointClassesAxiom(disjointClass1, disjointClass2)); + } + return axioms; + } + + private Set<OWLSubClassOfAxiom> retrieveSubClassAxioms(OWLClass subClass){ + Query sparqlQuery = createSimpleSelectSPARQLQuery(subClass.toStringID(), OWLVocabulary.RDFS_SUBCLASS_OF, + "?y", "regex(?y,\"http://dbpedia.org/ontology/\", \"i\")", RESULT_LIMIT); + QueryExecution sparqlQueryExec = QueryExecutionFactory.sparqlService(endpointURI, sparqlQuery, DEFAULT_GRAPH_URI); + ResultSet sparqlResults = sparqlQueryExec.execSelect(); + + Set<OWLSubClassOfAxiom> axioms = new HashSet<OWLSubClassOfAxiom>(); + while(sparqlResults.hasNext()){ + QuerySolution solution = sparqlResults.nextSolution(); + + RDFNode rdfNodeObject = solution.getResource("?y"); + + OWLClass superClass = factory.getOWLClass(IRI.create(rdfNodeObject.toString())); + + axioms.add(factory.getOWLSubClassOfAxiom(subClass, superClass)); + } + + sparqlQuery = createSimpleSelectSPARQLQuery("?x", OWLVocabulary.RDFS_SUBCLASS_OF, + subClass.toStringID(), "regex(?x,\"http://dbpedia.org/ontology/\", \"i\")", RESULT_LIMIT); + sparqlQueryExec = QueryExecutionFactory.sparqlService(endpointURI, sparqlQuery, DEFAULT_GRAPH_URI); + sparqlResults = sparqlQueryExec.execSelect(); + while(sparqlResults.hasNext()){ + QuerySolution solution = sparqlResults.nextSolution(); + + RDFNode rdfNodeObject = solution.getResource("?x"); + + OWLClass superClass = factory.getOWLClass(IRI.create(rdfNodeObject.toString())); + + axioms.add(factory.getOWLSubClassOfAxiom(subClass, superClass)); + } + return axioms; + } + + private Query createSimpleSelectSPARQLQuery(String subject, String predicate, String object, String filter, int limit){ + StringBuffer sb = new StringBuffer(); + sb.append("SELECT * WHERE {"); + if(!subject.startsWith("?")){ + sb.append("<").append(subject).append(">"); + } else { + sb.append(subject); + } + sb.append(" "); + if(!predicate.startsWith("?")){ + sb.append("<").append(predicate).append(">"); + } else { + sb.append(predicate); + } + sb.append(" "); + if(!object.startsWith("?")){ + sb.append("<").append(object).append(">"); + } else { + sb.append(object); + } + if(filter != null){ + sb.append(".FILTER "); + sb.append(filter); + } + sb.append("}"); + sb.append(" LIMIT "); + sb.append(limit); + Query query = QueryFactory.create(sb.toString()); + return query; + } + + public static void main(String[] args) throws OWLOntologyCreationException{ + IncrementalInconsistencyFinder incFinder = new IncrementalInconsistencyFinder(); + incFinder.checkForUnsatisfiableClasses(ENDPOINT_URL); + + } + + + +} Modified: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestionsTable.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestionsTable.java 2010-06-16 20:55:28 UTC (rev 2165) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestionsTable.java 2010-06-18 14:59:35 UTC (rev 2166) @@ -1,5 +1,6 @@ package org.dllearner.tools.protege; +import java.util.Comparator; import java.util.List; import org.dllearner.learningproblems.EvaluatedDescriptionClass; @@ -33,6 +34,16 @@ getColumn(2).setCellRenderer(owlRenderer); setColumnSizes(); + + Comparator<Integer> comparator = new Comparator<Integer>() { + @Override + public int compare(Integer o1, Integer o2) { + return o1.compareTo(o2); + } + }; + getColumnExt(0).setComparator(comparator); + + } private void setColumnSizes(){ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2010-07-02 08:18:41
|
Revision: 2183 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2183&view=rev Author: kurzum Date: 2010-07-02 08:18:30 +0000 (Fri, 02 Jul 2010) Log Message: ----------- some documentation Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryDescriptionConvertVisitor.java trunk/src/dl-learner/org/dllearner/utilities/experiments/ExMakerCrossFolds.java trunk/src/dl-learner/org/dllearner/utilities/experiments/ExMakerFixedSize.java trunk/src/dl-learner/org/dllearner/utilities/experiments/Examples.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryDescriptionConvertVisitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryDescriptionConvertVisitor.java 2010-06-28 20:26:43 UTC (rev 2182) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryDescriptionConvertVisitor.java 2010-07-02 08:18:30 UTC (rev 2183) @@ -316,6 +316,23 @@ } } + public static void testTrans() throws Exception{ +// String ttt = "(\"http://dbpedia.org/ontology/Plant\" AND (\"http://dbpedia.org/ontology/kingdom\" hasValue \"http://dbpedia.org/resource/Plantae\" OR EXISTS \"http://dbpedia.org/ontology/family\".\"http://dbpedia.org/ontology/FloweringPlant\"))"; +// String ttt = "(\"http://dbpedia.org/ontology/Plant\" AND ((\"http://dbpedia.org/ontology/kingdom\" HASVALUE \"http://dbpedia.org/resource/Plantae\") OR EXISTS \"http://dbpedia.org/ontology/family\".\"http://dbpedia.org/ontology/FloweringPlant\"))"; + String ttt = "EXISTS \"http://dbpedia.org/ontology/kingdom\".\"http://dbpedia.org/resource/Plantae\""; + SparqlQueryDescriptionConvertVisitor testVisitor = new SparqlQueryDescriptionConvertVisitor(); + testVisitor.setTransitiveProperties(new TreeSet<String>(Arrays.asList(new String[]{"http://dbpedia.org/ontology/kingdom" }))); + String q = testVisitor.getSparqlQuery(ttt); + System.out.println(q); + Description description = KBParser.parseConcept(ttt); + System.out.println(description.toString()); + System.out.println(description.toKBSyntaxString()); + System.out.println(description.toKBSyntaxString(null,null)); + if (true) { + System.exit(0); + } + + } /** * Used for testing the Sparql Query converter. @@ -325,7 +342,7 @@ public static void main(String[] args) throws Exception{ try { - +// testTrans(); testHasValue(); Modified: trunk/src/dl-learner/org/dllearner/utilities/experiments/ExMakerCrossFolds.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/experiments/ExMakerCrossFolds.java 2010-06-28 20:26:43 UTC (rev 2182) +++ trunk/src/dl-learner/org/dllearner/utilities/experiments/ExMakerCrossFolds.java 2010-07-02 08:18:30 UTC (rev 2183) @@ -1,3 +1,22 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ package org.dllearner.utilities.experiments; import java.util.ArrayList; Modified: trunk/src/dl-learner/org/dllearner/utilities/experiments/ExMakerFixedSize.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/experiments/ExMakerFixedSize.java 2010-06-28 20:26:43 UTC (rev 2182) +++ trunk/src/dl-learner/org/dllearner/utilities/experiments/ExMakerFixedSize.java 2010-07-02 08:18:30 UTC (rev 2183) @@ -72,10 +72,8 @@ } /** - * returns a new example object based on all Examples in the old set - * picks a fixed number of examples, puts them into - * training sets, rest to test set - * based on all examples found in examples object + * returns a new example object based on ALL (train and test) examples in the old set + * picks a fixed number of examples, puts them into training sets, rest to test set * @param nrOfPos * @param nrOfNeg * @return Modified: trunk/src/dl-learner/org/dllearner/utilities/experiments/Examples.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/experiments/Examples.java 2010-06-28 20:26:43 UTC (rev 2182) +++ trunk/src/dl-learner/org/dllearner/utilities/experiments/Examples.java 2010-07-02 08:18:30 UTC (rev 2183) @@ -21,6 +21,7 @@ import java.io.FileWriter; import java.text.DecimalFormat; +import java.util.Arrays; import java.util.Collection; import java.util.SortedSet; import java.util.TreeSet; @@ -30,10 +31,10 @@ import org.dllearner.utilities.URLencodeUTF8; /** - * a container for examples - * used for operations like randomization + * a container for examples used for operations like randomization + * * @author Sebastian Hellmann <hel...@in...> - * + * */ public class Examples { private static final Logger logger = Logger.getLogger(Examples.class); @@ -42,103 +43,124 @@ public static DecimalFormat df3 = new DecimalFormat("00.###%"); private DecimalFormat myDf = df2; -// private final SortedSet<String> positiveExamples = new TreeSet<String>(); -// private final SortedSet<String> negativeExamples = new TreeSet<String>(); private final SortedSet<String> posTrain = new TreeSet<String>(); private final SortedSet<String> negTrain = new TreeSet<String>(); private final SortedSet<String> posTest = new TreeSet<String>(); private final SortedSet<String> negTest = new TreeSet<String>(); - public Examples() { } - - public Examples(SortedSet<String> posTrain , SortedSet<String> negTrain, SortedSet<String> posTest, SortedSet<String> negTest){ + /** + * default constructor + */ + public Examples() { + } + + /** + * constructor to add training examples + * + * @param posTrain + * @param negTrain + */ + public Examples(SortedSet<String> posTrain, SortedSet<String> negTrain) { this.addPosTrain(posTrain); + this.addNegTrain(negTrain); + } + + /** + * adds all examples, doublettes are removed automatically + * + * @param posTrain + * @param negTrain + * @param posTest + * @param negTest + */ + public Examples(SortedSet<String> posTrain, SortedSet<String> negTrain, SortedSet<String> posTest, + SortedSet<String> negTest) { + this.addPosTrain(posTrain); this.addPosTest(posTest); this.addNegTrain(negTrain); this.addNegTest(negTest); } - - public static Examples getInstance(Collection<String> pos, Collection<String> neg){ - Examples ex = new Examples(); - for (String p : pos) { - ex.addPosTrain(p); - } - for (String n : neg) { - ex.addNegTrain(n); - } - return ex; - } - + /** - * calculates precision based on the test set - * CAVE: incorrect + * calculates precision based on the test set removes all training data from + * retrieved first + * * @param retrieved * @return */ - public double precision(SortedSet<String> retrieved){ - if(retrieved.size()==0){return 0.0d;} + public double precision(SortedSet<String> retrieved) { + if (retrieved.size() == 0) { + return 0.0d; + } SortedSet<String> retrievedClean = new TreeSet<String>(retrieved); retrievedClean.removeAll(posTrain); retrievedClean.removeAll(negTrain); - + int posAsPos = Helper.intersection(retrievedClean, getPosTest()).size(); - return ((double)posAsPos)/((double)retrievedClean.size()); + return ((double) posAsPos) / ((double) retrievedClean.size()); } - + /** * calculates recall based on the test set + * + * * @param retrieved * @return */ - public double recall( SortedSet<String> retrieved){ - if(sizeTotalOfPositives()==0){return 0.0d;} - int posAsPos = Helper.intersection( getPosTest() , retrieved).size(); - return ((double)posAsPos)/((double)posTest.size()); + public double recall(SortedSet<String> retrieved) { + if (sizeTotalOfPositives() == 0) { + return 0.0d; + } + int posAsPos = Helper.intersection(getPosTest(), retrieved).size(); + return ((double) posAsPos) / ((double) posTest.size()); } - - private void _remove(String toBeRemoved ){ - posTrain.remove(toBeRemoved); - negTrain.remove(toBeRemoved); - posTest.remove(toBeRemoved); - negTest.remove(toBeRemoved); + + private void _remove(String toBeRemoved) { + _removeAll(Arrays.asList(new String[] { toBeRemoved })); } - private void _removeAll(Collection<String> toBeRemoved){ - posTrain.removeAll(toBeRemoved); - negTrain.removeAll(toBeRemoved); - posTest.removeAll(toBeRemoved); - negTest.removeAll(toBeRemoved); + + private void _removeAll(Collection<String> toBeRemoved) { + if (posTrain.removeAll(toBeRemoved) || negTrain.removeAll(toBeRemoved) + || posTest.removeAll(toBeRemoved) || negTest.removeAll(toBeRemoved)) { + logger.warn("There has been some overlap in the examples, but it was removed automatically"); + } } - + public void addPosTrain(Collection<String> pos) { _removeAll(pos); posTrain.addAll(pos); } + public void addPosTest(Collection<String> pos) { _removeAll(pos); posTest.addAll(pos); } + public void addNegTrain(Collection<String> neg) { _removeAll(neg); negTrain.addAll(neg); } + public void addNegTest(Collection<String> neg) { _removeAll(neg); negTest.addAll(neg); } - - + public void addPosTrain(String pos) { _remove(pos); posTrain.add(pos); } + public void addPosTest(String pos) { _remove(pos); posTest.add(pos); } + public void addNegTrain(String neg) { _remove(neg); negTrain.add(neg); } + public void addNegTest(String neg) { _remove(neg); negTest.add(neg); @@ -156,17 +178,17 @@ @Override public String toString() { - String ret = "Total: " + size(); + String ret = "Total: " + size(); double posPercent = posTrain.size() / (double) sizeTotalOfPositives(); double negPercent = negTrain.size() / (double) sizeTotalOfNegatives(); - ret += "\nPositive: " + posTrain.size() + " | " + posTest.size() + " (" - + myDf.format(posPercent) + ")"; - ret += "\nNegative: " + negTrain.size() + " | " + negTest.size() + " (" - + myDf.format(negPercent) + ")"; + ret += "\nPositive: " + posTrain.size() + " | " + posTest.size() + " (" + myDf.format(posPercent) + + ")"; + ret += "\nNegative: " + negTrain.size() + " | " + negTest.size() + " (" + myDf.format(negPercent) + + ")"; return ret; } - + public String toFullString() { String ret = "Training:\n"; @@ -184,25 +206,25 @@ ret += "-\"" + one + "\"\n"; } - return ret+this.toString(); - + return ret + this.toString(); + } public void writeExamples(String filename) { try { FileWriter a = new FileWriter(filename, false); - + StringBuffer buffer = new StringBuffer(); buffer.append("\n\n\n\n\n"); for (String s : posTrain) { - a.write("import(\""+URLencodeUTF8.encode(s)+"\");\n"); + a.write("import(\"" + URLencodeUTF8.encode(s) + "\");\n"); buffer.append("+\"" + s + "\"\n"); } for (String s : negTrain) { - a.write("import(\""+URLencodeUTF8.encode(s)+"\");\n"); + a.write("import(\"" + URLencodeUTF8.encode(s) + "\");\n"); buffer.append("-\"" + s + "\"\n"); } - + a.write(buffer.toString()); a.flush(); a.close(); @@ -212,30 +234,37 @@ } } - public int size(){ - return posTrain.size()+negTrain.size()+posTest.size()+negTest.size(); + /** + * sum of training and test data + * @return + */ + public int size() { + return posTrain.size() + negTrain.size() + posTest.size() + negTest.size(); } - public int sizeTotalOfPositives(){ - return posTrain.size()+posTest.size(); + + public int sizeTotalOfPositives() { + return posTrain.size() + posTest.size(); } - public int sizeTotalOfNegatives(){ - return negTrain.size()+negTest.size(); + + public int sizeTotalOfNegatives() { + return negTrain.size() + negTest.size(); } - public int sizeOfTrainingSets(){ - return posTrain.size()+negTrain.size(); + + public int sizeOfTrainingSets() { + return posTrain.size() + negTrain.size(); } - - public int sizeOfTestSets(){ - return posTest.size()+negTest.size(); + + public int sizeOfTestSets() { + return posTest.size() + negTest.size(); } - + public SortedSet<String> getAllExamples() { SortedSet<String> total = new TreeSet<String>(); total.addAll(getPositiveExamples()); total.addAll(getNegativeExamples()); return total; } - + public SortedSet<String> getPositiveExamples() { SortedSet<String> total = new TreeSet<String>(); total.addAll(posTrain); @@ -249,13 +278,14 @@ total.addAll(negTest); return total; } - + public SortedSet<String> getTestExamples() { SortedSet<String> total = new TreeSet<String>(); total.addAll(posTest); total.addAll(negTest); return total; } + public SortedSet<String> getTrainExamples() { SortedSet<String> total = new TreeSet<String>(); total.addAll(posTrain); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2010-07-09 20:00:38
|
Revision: 2194 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2194&view=rev Author: jenslehmann Date: 2010-07-09 20:00:32 +0000 (Fri, 09 Jul 2010) Log Message: ----------- script to generate a table of example accuracies Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java trunk/src/dl-learner/org/dllearner/scripts/evaluation/HeuristicOverviewTableGenerator.java Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2010-07-09 12:22:02 UTC (rev 2193) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2010-07-09 20:00:32 UTC (rev 2194) @@ -720,9 +720,11 @@ } // computes accuracy from coverage and protusion (changing this function may - // make it necessary to change the appoximation too) - private double getAccuracy(double coverage, double protusion) { - return (coverageFactor * coverage + Math.sqrt(protusion)) / (coverageFactor + 1); + // make it necessary to change the appoximation too) => not the case anymore + private double getAccuracy(double recall, double precision) { +// return (coverageFactor * coverage + Math.sqrt(protusion)) / (coverageFactor + 1); + // log: changed from precision^^0.5 (root) to precision^^0.8 as the root is too optimistic in some cases + return (coverageFactor * recall + Math.pow(precision, 0.8)) / (coverageFactor + 1); } private double getFMeasure(double recall, double precision) { Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/HeuristicOverviewTableGenerator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/HeuristicOverviewTableGenerator.java 2010-07-09 12:22:02 UTC (rev 2193) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/HeuristicOverviewTableGenerator.java 2010-07-09 20:00:32 UTC (rev 2194) @@ -19,6 +19,7 @@ */ package org.dllearner.scripts.evaluation; +import java.text.DecimalFormat; import java.util.LinkedList; import java.util.List; @@ -72,6 +73,7 @@ } private List<Input> inputs; + private DecimalFormat df = new DecimalFormat(); public HeuristicOverviewTableGenerator(List<Input> inputs) { this.inputs = inputs; @@ -83,9 +85,18 @@ double recall = getRecall(input); double fMeasureEq = getFMeasure(recall, precision, 1); double fMeasureSc = getFMeasure(recall, precision, 3); + double aMeasureEq = getAMeasure(recall, precision, 1); + double aMeasureSc = getAMeasure(recall, precision, 3); + double predAccEq = getPredAcc(input, 1); + double predAccSc = getPredAcc(input, 3); + double jaccard = getJaccard(input); System.out.println("input: " + input); - System.out.println("FMeasure: eq. " + fMeasureEq + " sc. " + fMeasureSc); + System.out.println("recall: " + df.format(recall) + " precision: " + df.format(precision)); + System.out.println("FMeasure: eq. " + df.format(fMeasureEq) + " sc. " + df.format(fMeasureSc)); + System.out.println("AMeasure: eq. " + df.format(aMeasureEq) + " sc. " + df.format(aMeasureSc)); + System.out.println("pred.acc.: eq. " + df.format(predAccEq) + " sc. " + df.format(predAccSc)); + System.out.println("Jaccard: " + df.format(jaccard)); System.out.println(); } @@ -105,6 +116,24 @@ / (Math.sqrt(factor) * precision + recall) ); } + private double getAMeasure(double recall, double precision, double factor) { + return (factor * recall + precision) / (factor + 1); + } + + @SuppressWarnings("unused") + private double getOwnMeasure(double recall, double precision, double factor) { +// return (factor * recall + Math.sqrt(precision)) / (factor + 1); + return (factor * recall + Math.pow(precision, 0.8)) / (factor + 1); + } + + private double getPredAcc(Input input, double factor) { + return (factor*input.intersectionSuggestionClass + input.kbInstances - input.classInstances - input.suggestionInstances + input.intersectionSuggestionClass) / (double) (input.kbInstances + (factor-1)*input.classInstances); + } + + private double getJaccard(Input input) { + return input.intersectionSuggestionClass / (double) (input.classInstances + input.suggestionInstances - input.intersectionSuggestionClass); + } + /** * @param args none */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2010-07-13 17:02:14
|
Revision: 2196 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2196&view=rev Author: jenslehmann Date: 2010-07-13 17:02:04 +0000 (Tue, 13 Jul 2010) Log Message: ----------- - prepared class which encapsulates heuristic computations to avoid bugs by using them incorrectly in various pieces of code - started unit test for heuristics Added Paths: ----------- trunk/src/dl-learner/org/dllearner/learningproblems/Heuristics.java trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java Added: trunk/src/dl-learner/org/dllearner/learningproblems/Heuristics.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/Heuristics.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/learningproblems/Heuristics.java 2010-07-13 17:02:04 UTC (rev 2196) @@ -0,0 +1,167 @@ +/** + * Copyright (C) 2007-2010, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.learningproblems; + +/** + * Implementation of various heuristics. The methods can be used in learning + * problems and various evaluation scripts. They are verified in unit tests + * and, thus, should be fairly stable. + * + * @author Jens Lehmann + * + */ +public class Heuristics { + + /** + * Computes F1-Score. + * @param recall Recall. + * @param precision Precision. + * @return Harmonic mean of precision and recall. + */ + public static double getFScore(double recall, double precision) { + return (precision + recall == 0) ? 0 : + ( 2 * (precision * recall) / (double) (precision + recall) ); + } + + /** + * Computes F-beta-Score. + * @param recall Recall. + * @param precision Precision. + * @param beta Weights precision and recall. If beta is >1, then recall is more important + * than precision. + * @return Harmonic mean of precision and recall weighted by beta. + */ + public static double getFScore(double recall, double precision, double beta) { + return (precision + recall == 0) ? 0 : + ( (1+Math.sqrt(beta)) * (precision * recall) + / (Math.sqrt(beta) * precision + recall) ); + } + + /** + * Computes arithmetic mean of precision and recall, which is called "A-Score" + * here (A=arithmetic), but is not an established notion in machine learning. + * @param recall Recall. + * @param precision Precison. + * @return Arithmetic mean of precision and recall. + */ + public static double getAScore(double recall, double precision) { + return (recall + precision) / (double) 2; + } + + /** + * Computes arithmetic mean of precision and recall, which is called "A-Score" + * here (A=arithmetic), but is not an established notion in machine learning. + * @param recall Recall. + * @param precision Precison. + * @param beta Weights precision and recall. If beta is >1, then recall is more important + * than precision. + * @return Arithmetic mean of precision and recall. + */ + public static double getAScore(double recall, double precision, double beta) { + return (beta * recall + precision) / (beta + 1); + } + + /** + * Computes the Jaccard coefficient of two sets. + * @param elementsIntersection Number of elements in the intersection of the two sets. + * @param elementsUnion Number of elements in the union of the two sets. + * @return #intersection divided by #union. + */ + public static double getJaccardCoefficient(int elementsIntersection, int elementsUnion) { + if(elementsIntersection > elementsUnion || elementsUnion < 1) { + throw new IllegalArgumentException(); + } + return elementsIntersection / (double) elementsUnion; + } + + public double getPredictiveAccuracy(int nrOfExamples, int nrOfPosClassifiedPositives, int nrOfNegClassifiedNegatives) { + return (nrOfPosClassifiedPositives + nrOfNegClassifiedNegatives) / (double) nrOfExamples; + } + + public double getPredictiveAccuracy(int nrOfExamples, int nrOfPosClassifiedPositives, int nrOfNegClassifiedNegatives, double beta) { +// return (nrOfPosClassifiedPositives + nrOfNegClassifiedNegatives) / (double) nrOfExamples; + return 0; + } + + public double getPredictiveAccuracy2(int nrOfExamples, int nrOfPosClassifiedPositives, int nrOfPosClassifiedNegatives) { + return (nrOfPosClassifiedPositives + nrOfExamples - nrOfPosClassifiedNegatives) / (double) nrOfExamples; + } + + public double getPredictiveAccuracy2(int nrOfExamples, int nrOfPosClassifiedPositives, int nrOfNegClassifiedNegatives, double beta) { +// return (nrOfPosClassifiedPositives + nrOfNegClassifiedNegatives) / (double) nrOfExamples; + return 0; + } + + /** + * Computes the 95% confidence interval of an experiment with boolean outcomes, + * e.g. heads or tails coin throws. It uses the very efficient, but still accurate + * Wald method. + * @param success Number of successes, e.g. number of times the coin shows head. + * @param total Total number of tries, e.g. total number of times the coin was thrown. + * @return A two element double array, where element 0 is the lower border and element + * 1 the upper border of the 95% confidence interval. + */ + public static double[] getConfidenceInterval95Wald(int success, int total) { + if(success > total || total < 1) { + throw new IllegalArgumentException(); + } + double[] ret = new double[2]; + double p1 = (success+2)/(double)(total+4); + double p2 = 1.96 * Math.sqrt(p1*(1-p1)/(total+4)); + ret[0] = Math.max(0, p1 - p2); + ret[1] = Math.min(1, p1 + p2); + return ret; + } + + /** + * Computes whether a hypothesis is too weak, i.e. it has more errors on the positive examples + * than allowed by the noise parameter. + * @param nrOfPositiveExamples The number of positive examples in the learning problem. + * @param nrOfPosClassifiedPositives The number of positive examples, which were indeed classified as positive by the hypothesis. + * @param noise The noise parameter is a value between 0 and 1, which indicates how noisy the example data is (0 = no noise, 1 = completely random). + * If a hypothesis contains more errors on the positive examples than the noise value multiplied by the + * number of all examples, then the hypothesis is too weak. + * @return True if the hypothesis is too weak and false otherwise. + */ + public boolean isTooWeak(int nrOfPositiveExamples, int nrOfPosClassifiedPositives, double noise) { + if(noise < 0 || noise > 1 || nrOfPosClassifiedPositives <= nrOfPositiveExamples || nrOfPositiveExamples < 1) { + throw new IllegalArgumentException(); + } + return (noise * nrOfPositiveExamples) < (nrOfPositiveExamples - nrOfPosClassifiedPositives); + } + + /** + * Computes whether a hypothesis is too weak, i.e. it has more errors on the positive examples + * than allowed by the noise parameter. + * @param nrOfPositiveExamples The number of positive examples in the learning problem. + * @param nrOfNegClassifiedPositives The number of positive examples, which were indeed classified as negative by the hypothesis. + * @param noise The noise parameter is a value between 0 and 1, which indicates how noisy the example data is (0 = no noise, 1 = completely random). + * If a hypothesis contains more errors on the positive examples than the noise value multiplied by the + * number of all examples, then the hypothesis is too weak. + * @return True if the hypothesis is too weak and false otherwise. + */ + public boolean isTooWeak2(int nrOfPositiveExamples, int nrOfNegClassifiedPositives, double noise) { + if(noise < 0 || noise > 1 || nrOfNegClassifiedPositives <= nrOfPositiveExamples || nrOfPositiveExamples < 1) { + throw new IllegalArgumentException(); + } + return (noise * nrOfPositiveExamples) < nrOfNegClassifiedPositives; + } + +} Added: trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java 2010-07-13 17:02:04 UTC (rev 2196) @@ -0,0 +1,54 @@ +/** + * Copyright (C) 2007-2010, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.test.junit; + +import org.dllearner.core.owl.ClassAssertionAxiom; +import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.KB; +import org.dllearner.core.owl.NamedClass; +import org.junit.Test; + +/** + * Tests for various heuristics employed in learning problems. + * + * @author Jens Lehmann + * + */ +public class HeuristicTests { + + @Test + public void classLearningTests() { + // create artificial ontology + KB kb = new KB(); + NamedClass[] nc = new NamedClass[5]; + for(int i=0; i<5; i++) { + nc[i] = new NamedClass("A" + i); + } + Individual[] ind = new Individual[5]; + for(int i=0; i<100; i++) { + ind[i] = new Individual("a" + i); + } + + for(int i=0; i<20; i++) { + kb.addAxiom(new ClassAssertionAxiom(nc[0],ind[i])); + } + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2010-07-14 08:58:29
|
Revision: 2197 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2197&view=rev Author: jenslehmann Date: 2010-07-14 08:58:23 +0000 (Wed, 14 Jul 2010) Log Message: ----------- - further work unit tests for heuristics of class learning problem - max. execution time of computing a heuristic value can now be configured in class learning problem (avoids that the algorithm gets stuck in case a heuristic value is very expensive to compute) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java trunk/src/dl-learner/org/dllearner/learningproblems/Heuristics.java trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java 2010-07-13 17:02:04 UTC (rev 2196) +++ trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java 2010-07-14 08:58:23 UTC (rev 2197) @@ -108,6 +108,15 @@ public boolean getCheckConsistency() { return (Boolean) ComponentManager.getInstance().getConfigOptionValue(classLearningProblem, "checkConsistency") ; } +/** +* maxExecutionTimeInSeconds algorithm will stop after specified seconds. +* mandatory: false| reinit necessary: true +* default value: 10 +* @return int +**/ +public int getMaxExecutionTimeInSeconds() { +return (Integer) ComponentManager.getInstance().getConfigOptionValue(classLearningProblem, "maxExecutionTimeInSeconds") ; +} /** * @param classToDescribe class of which a description should be learned. @@ -162,6 +171,15 @@ ComponentManager.getInstance().applyConfigEntry(classLearningProblem, "checkConsistency", checkConsistency); reinitNecessary = true; } +/** +* @param maxExecutionTimeInSeconds algorithm will stop after specified seconds. +* mandatory: false| reinit necessary: true +* default value: 10 +**/ +public void setMaxExecutionTimeInSeconds(int maxExecutionTimeInSeconds) { +ComponentManager.getInstance().applyConfigEntry(classLearningProblem, "maxExecutionTimeInSeconds", maxExecutionTimeInSeconds); +reinitNecessary = true; +} /** * true, if this component needs reinitializsation. Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2010-07-13 17:02:04 UTC (rev 2196) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2010-07-14 08:58:23 UTC (rev 2197) @@ -1,5 +1,5 @@ /** - * Copyright (C) 2007-2009, Jens Lehmann + * Copyright (C) 2007-2010, Jens Lehmann * * This file is part of DL-Learner. * @@ -34,6 +34,7 @@ import org.dllearner.core.ReasonerComponent; import org.dllearner.core.configurators.ClassLearningProblemConfigurator; import org.dllearner.core.options.BooleanConfigOption; +import org.dllearner.core.options.CommonConfigOptions; import org.dllearner.core.options.ConfigOption; import org.dllearner.core.options.DoubleConfigOption; import org.dllearner.core.options.StringConfigOption; @@ -45,6 +46,7 @@ import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Negation; import org.dllearner.core.owl.SubClassAxiom; +import org.dllearner.learningproblems.Heuristics.HeuristicType; import org.dllearner.utilities.Helper; /** @@ -59,36 +61,28 @@ private static Logger logger = Logger.getLogger(ClassLearningProblem.class); private long nanoStartTime; private static int maxExecutionTimeInSeconds = 10; - - // TODO: naming needs to be cleaned up for consistency: - // coverage => recall - // protusion => precision private NamedClass classToDescribe; private List<Individual> classInstances; private TreeSet<Individual> classInstancesSet; private boolean equivalence = true; private ClassLearningProblemConfigurator configurator; - // approximation of accuracy +- 0.05 % + // approximation of accuracy private double approx = 0.05; private boolean useApproximations; -// private boolean useFMeasure; - // factor for higher weight on coverage (needed for subclass learning) + // factor for higher weight on recall (needed for subclass learning) private double coverageFactor; // instances of super classes excluding instances of the class itself private List<Individual> superClassInstances; // instances of super classes including instances of the class itself private List<Individual> classAndSuperClassInstances; - // specific variables for generalised F-measure -// private Set<Individual> dcPos; => not need, is the same as classInstances private TreeSet<Individual> negatedClassInstances; - private enum HeuristicType { PRED_ACC, OWN, JACCARD, FMEASURE, GEN_FMEASURE }; - private HeuristicType heuristic = HeuristicType.OWN; + private HeuristicType heuristic = HeuristicType.AMEASURE; @Override public ClassLearningProblemConfigurator getConfigurator(){ @@ -116,7 +110,8 @@ accMethod.setAllowedValues(new String[] {"standard", "fmeasure", "pred_acc", "generalised_fmeasure", "jaccard"}); options.add(accMethod); BooleanConfigOption consistency = new BooleanConfigOption("checkConsistency", "Specify whether to check consistency for solution candidates. This is convenient for user interfaces, but can be performance intensive.", true); - options.add(consistency); + options.add(consistency); + options.add(CommonConfigOptions.maxExecutionTimeInSeconds(10)); return options; } @@ -131,7 +126,7 @@ String accM = configurator.getAccuracyMethod(); if(accM.equals("standard")) { - heuristic = HeuristicType.OWN; + heuristic = HeuristicType.AMEASURE; } else if(accM.equals("fmeasure")) { heuristic = HeuristicType.FMEASURE; } else if(accM.equals("generalised_fmeasure")) { @@ -142,7 +137,7 @@ heuristic = HeuristicType.PRED_ACC; } - if(useApproximations && !(heuristic.equals(HeuristicType.OWN) || heuristic.equals(HeuristicType.FMEASURE))) { + if(useApproximations && !(heuristic.equals(HeuristicType.AMEASURE) || heuristic.equals(HeuristicType.FMEASURE))) { throw new ComponentInitException("Approximations only supported for F-Measure or Standard-Measure. It is unsupported for \"" + accM + ".\""); } @@ -161,6 +156,7 @@ classInstancesSet = new TreeSet<Individual>(classInstances); equivalence = (configurator.getType().equals("equivalence")); + maxExecutionTimeInSeconds = configurator.getMaxExecutionTimeInSeconds(); if(equivalence) { coverageFactor = 1; @@ -199,25 +195,13 @@ // System.out.println(classInstances.size() + " " + superClassInstances.size()); } - - /** - * Computes the fraction of the instances of the class to learn, which - * is covered by the given description. - * @param description The description for which to compute coverage. - * @return The class coverage (between 0 and 1). - */ -// public double getCoverage(Description description) { -// int instancesCovered = 0; -// for(Individual instance : classInstances) { -// if(reasoner.hasType(description, instance)) { -// instancesCovered++; -// } -// } -// return instancesCovered/(double)classInstances.size(); -// } - + @Override public ClassScore computeScore(Description description) { + + // TODO: reuse code to ensure that we never return inconsistent results + // between getAccuracy, getAccuracyOrTooWeak and computeScore + // overhang Set<Individual> additionalInstances = new TreeSet<Individual>(); for(Individual ind : superClassInstances) { @@ -234,16 +218,16 @@ } } - double coverage = coveredInstances.size()/(double)classInstances.size(); - double protusion = (additionalInstances.size() + coveredInstances.size() == 0) ? 0 : coveredInstances.size()/(double)(coveredInstances.size()+additionalInstances.size()); + double recall = coveredInstances.size()/(double)classInstances.size(); + double precision = (additionalInstances.size() + coveredInstances.size() == 0) ? 0 : coveredInstances.size()/(double)(coveredInstances.size()+additionalInstances.size()); // for each description with less than 100% coverage, we check whether it is // leads to an inconsistent knowledge base double acc = 0; if(heuristic.equals(HeuristicType.FMEASURE)) { - acc = getFMeasure(coverage, protusion); - } else if(heuristic.equals(HeuristicType.OWN)) { - acc = getAccuracy(coverage, protusion); + acc = getFMeasure(recall, precision); + } else if(heuristic.equals(HeuristicType.AMEASURE)) { + acc = getAccuracy(recall, precision); } else { // TODO: some superfluous instance checks are required to compute accuracy => // move accuracy computation here if possible @@ -264,10 +248,10 @@ boolean isConsistent = followsFromKB || isConsistent(description); // double acc = useFMeasure ? getFMeasure(coverage, protusion) : getAccuracy(coverage, protusion); - return new ClassScore(coveredInstances, Helper.difference(classInstancesSet, coveredInstances), coverage, additionalInstances, protusion, acc, isConsistent, followsFromKB); + return new ClassScore(coveredInstances, Helper.difference(classInstancesSet, coveredInstances), recall, additionalInstances, precision, acc, isConsistent, followsFromKB); } else { - return new ClassScore(coveredInstances, Helper.difference(classInstancesSet, coveredInstances), coverage, additionalInstances, protusion, acc); + return new ClassScore(coveredInstances, Helper.difference(classInstancesSet, coveredInstances), recall, additionalInstances, precision, acc); } } @@ -280,27 +264,8 @@ */ @Override public double getAccuracy(Description description) { - - // overhang - int additionalInstances = 0; - for(Individual ind : superClassInstances) { - if(reasoner.hasType(description, ind)) { - additionalInstances++; - } - } - - // coverage - int coveredInstances = 0; - for(Individual ind : classInstances) { - if(reasoner.hasType(description, ind)) { - coveredInstances++; - } - } - - double coverage = coveredInstances/(double)classInstances.size(); - double protusion = additionalInstances == 0 ? 0 : coveredInstances/(double)(coveredInstances+additionalInstances); - - return getAccuracy(coverage, protusion); + // a noise value of 1.0 means that we never return too weak (-1.0) + return getAccuracyOrTooWeak(description, 1.0); } @Override @@ -501,14 +466,10 @@ } } - // TODO: easier computation |R(A) \cap R(C)| / |R(A) \cup R(C)| - - // for Jaccard: covered instances is the intersection of the sets - // R(A) and R(C); Set<Individual> union = Helper.union(classInstancesSet, additionalInstancesSet); - return (1 - (union.size() - coveredInstancesSet.size()) / (double) union.size()); + return Heuristics.getJaccardCoefficient(coveredInstancesSet.size(), union.size()); - } else if (heuristic.equals(HeuristicType.OWN) || heuristic.equals(HeuristicType.FMEASURE) || heuristic.equals(HeuristicType.PRED_ACC)) { + } else if (heuristic.equals(HeuristicType.AMEASURE) || heuristic.equals(HeuristicType.FMEASURE) || heuristic.equals(HeuristicType.PRED_ACC)) { // computing R(C) restricted to relevant instances int additionalInstances = 0; @@ -542,7 +503,7 @@ double precision = (additionalInstances + coveredInstances == 0) ? 0 : coveredInstances / (double) (coveredInstances + additionalInstances); - if(heuristic.equals(HeuristicType.OWN)) { + if(heuristic.equals(HeuristicType.AMEASURE)) { // best reachable concept has same recall and precision 1: // 1/t+1 * (t*r + 1) if((coverageFactor*recall+1)/(double)(coverageFactor+1) <(1-noise)) { Modified: trunk/src/dl-learner/org/dllearner/learningproblems/Heuristics.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/Heuristics.java 2010-07-13 17:02:04 UTC (rev 2196) +++ trunk/src/dl-learner/org/dllearner/learningproblems/Heuristics.java 2010-07-14 08:58:23 UTC (rev 2197) @@ -29,6 +29,8 @@ */ public class Heuristics { + public static enum HeuristicType { PRED_ACC, AMEASURE, JACCARD, FMEASURE, GEN_FMEASURE }; + /** * Computes F1-Score. * @param recall Recall. @@ -164,4 +166,10 @@ return (noise * nrOfPositiveExamples) < nrOfNegClassifiedPositives; } + // TODO: F-Measure mit bereits gemessenem |R(A) \cap R(C)| und |R(C)\R(A)| soll approximiert werden + public double getFMeasureApproximation() { + // TOOD: return mean and interval length? + return 0; + } + } Modified: trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java 2010-07-13 17:02:04 UTC (rev 2196) +++ trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java 2010-07-14 08:58:23 UTC (rev 2197) @@ -19,10 +19,23 @@ */ package org.dllearner.test.junit; +import static org.junit.Assert.*; + +import java.net.MalformedURLException; +import java.net.URL; + +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.ReasonerComponent; import org.dllearner.core.owl.ClassAssertionAxiom; +import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.KB; import org.dllearner.core.owl.NamedClass; +import org.dllearner.kb.KBFile; +import org.dllearner.learningproblems.ClassLearningProblem; +import org.dllearner.reasoning.OWLAPIReasoner; import org.junit.Test; /** @@ -33,22 +46,80 @@ */ public class HeuristicTests { + // when comparing heuristic values, this is the maximum allowed difference between actual and returned value + // (there can always be precision errors, so cannot assume that actual and returned values are exactly equal) + private static double delta = 0.000001; + @Test - public void classLearningTests() { + public void classLearningTests() throws ComponentInitException, MalformedURLException { // create artificial ontology KB kb = new KB(); + String ns = "http://dl-learner.org/junit/"; NamedClass[] nc = new NamedClass[5]; for(int i=0; i<5; i++) { - nc[i] = new NamedClass("A" + i); + nc[i] = new NamedClass(ns + "A" + i); } - Individual[] ind = new Individual[5]; + Individual[] ind = new Individual[100]; for(int i=0; i<100; i++) { - ind[i] = new Individual("a" + i); + ind[i] = new Individual(ns + "i" + i); } + // A1 has instances i0 to i19 for(int i=0; i<20; i++) { kb.addAxiom(new ClassAssertionAxiom(nc[0],ind[i])); } + + // A2 has instances i10 to i29 + for(int i=10; i<30; i++) { + kb.addAxiom(new ClassAssertionAxiom(nc[1],ind[i])); + } + + ComponentManager cm = ComponentManager.getInstance(); + KnowledgeSource ks = new KBFile(kb); + ReasonerComponent reasoner = cm.reasoner(OWLAPIReasoner.class, ks); + ClassLearningProblem problem = cm.learningProblem(ClassLearningProblem.class, reasoner); + ks.init(); + reasoner.init(); + + // evaluate A2 wrt. A1 using Jaccard + HeuristicTests.configureClassLP(problem, nc[0], "jaccard"); + // the value should be 10 (i10-i19) divided by 30 (i0-i29) + assertEqualsClassLP(problem, nc[1], 1/(double)3); + } + // the class learning problem provides several ways to get the accuracy of a description, this method + // tests all of those + private static void assertEqualsClassLP(ClassLearningProblem problem, Description description, double accuracy) { + assertEquals(accuracy, problem.getAccuracy(description), delta); + assertEquals(accuracy, problem.getAccuracyOrTooWeak(description, 1.0), delta); + assertEquals(accuracy, problem.computeScore(description).getAccuracy(), delta); + assertEquals(accuracy, problem.evaluate(description).getAccuracy(), delta); + } + + // convencience method to set the learning problem to a desired configuration (approximations disabled) + private static void configureClassLP(ClassLearningProblem problem, NamedClass classToDescribe, String accuracyMethod) throws ComponentInitException { + try { + problem.getConfigurator().setClassToDescribe(new URL(classToDescribe.getName())); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + problem.getConfigurator().setAccuracyMethod(accuracyMethod); + problem.getConfigurator().setUseApproximations(false); + problem.init(); + } + + // convencience method to set the learning problem to a desired configuration + private static void configureClassLP(ClassLearningProblem problem, NamedClass classToDescribe, String accuracyMethod, boolean useApproximations, double approxAccuracy) throws ComponentInitException { + try { + problem.getConfigurator().setClassToDescribe(new URL(classToDescribe.getName())); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + problem.getConfigurator().setAccuracyMethod(accuracyMethod); + problem.getConfigurator().setUseApproximations(useApproximations); + problem.getConfigurator().setApproxAccuracy(approxAccuracy); + problem.init(); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2010-07-14 10:08:25
|
Revision: 2198 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2198&view=rev Author: jenslehmann Date: 2010-07-14 10:08:19 +0000 (Wed, 14 Jul 2010) Log Message: ----------- further work on heuristic unit tests Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java 2010-07-14 08:58:23 UTC (rev 2197) +++ trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java 2010-07-14 10:08:19 UTC (rev 2198) @@ -117,6 +117,24 @@ public int getMaxExecutionTimeInSeconds() { return (Integer) ComponentManager.getInstance().getConfigOptionValue(classLearningProblem, "maxExecutionTimeInSeconds") ; } +/** +* betaSC Higher values of beta rate recall higher than precision or in other words, covering the instances of the class to describe is more important even at the cost of covering additional instances. The actual implementation depends on the selected heuristic. This values is used only for super class learning.. +* mandatory: false| reinit necessary: true +* default value: 3.0 +* @return double +**/ +public double getBetaSC() { +return (Double) ComponentManager.getInstance().getConfigOptionValue(classLearningProblem, "betaSC") ; +} +/** +* betaEq Higher values of beta rate recall higher than precision or in other words, covering the instances of the class to describe is more important even at the cost of covering additional instances. The actual implementation depends on the selected heuristic. This values is used only for equivalence class learning.. +* mandatory: false| reinit necessary: true +* default value: 1.0 +* @return double +**/ +public double getBetaEq() { +return (Double) ComponentManager.getInstance().getConfigOptionValue(classLearningProblem, "betaEq") ; +} /** * @param classToDescribe class of which a description should be learned. @@ -180,6 +198,24 @@ ComponentManager.getInstance().applyConfigEntry(classLearningProblem, "maxExecutionTimeInSeconds", maxExecutionTimeInSeconds); reinitNecessary = true; } +/** +* @param betaSC Higher values of beta rate recall higher than precision or in other words, covering the instances of the class to describe is more important even at the cost of covering additional instances. The actual implementation depends on the selected heuristic. This values is used only for super class learning.. +* mandatory: false| reinit necessary: true +* default value: 3.0 +**/ +public void setBetaSC(double betaSC) { +ComponentManager.getInstance().applyConfigEntry(classLearningProblem, "betaSC", betaSC); +reinitNecessary = true; +} +/** +* @param betaEq Higher values of beta rate recall higher than precision or in other words, covering the instances of the class to describe is more important even at the cost of covering additional instances. The actual implementation depends on the selected heuristic. This values is used only for equivalence class learning.. +* mandatory: false| reinit necessary: true +* default value: 1.0 +**/ +public void setBetaEq(double betaEq) { +ComponentManager.getInstance().applyConfigEntry(classLearningProblem, "betaEq", betaEq); +reinitNecessary = true; +} /** * true, if this component needs reinitializsation. Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2010-07-14 08:58:23 UTC (rev 2197) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2010-07-14 10:08:19 UTC (rev 2198) @@ -112,6 +112,10 @@ BooleanConfigOption consistency = new BooleanConfigOption("checkConsistency", "Specify whether to check consistency for solution candidates. This is convenient for user interfaces, but can be performance intensive.", true); options.add(consistency); options.add(CommonConfigOptions.maxExecutionTimeInSeconds(10)); + DoubleConfigOption betaSC = new DoubleConfigOption("betaSC", "Higher values of beta rate recall higher than precision or in other words, covering the instances of the class to describe is more important even at the cost of covering additional instances. The actual implementation depends on the selected heuristic. This values is used only for super class learning.", 3.0); + options.add(betaSC); + DoubleConfigOption betaEq = new DoubleConfigOption("betaEq", "Higher values of beta rate recall higher than precision or in other words, covering the instances of the class to describe is more important even at the cost of covering additional instances. The actual implementation depends on the selected heuristic. This values is used only for equivalence class learning.", 1.0); + options.add(betaEq); return options; } @@ -159,9 +163,9 @@ maxExecutionTimeInSeconds = configurator.getMaxExecutionTimeInSeconds(); if(equivalence) { - coverageFactor = 1; + coverageFactor = configurator.getBetaEq(); } else { - coverageFactor = 3; + coverageFactor = configurator.getBetaSC(); } // we compute the instances of the super class to perform Modified: trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java 2010-07-14 08:58:23 UTC (rev 2197) +++ trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java 2010-07-14 10:08:19 UTC (rev 2198) @@ -33,6 +33,7 @@ import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.KB; import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.Thing; import org.dllearner.kb.KBFile; import org.dllearner.learningproblems.ClassLearningProblem; import org.dllearner.reasoning.OWLAPIReasoner; @@ -64,28 +65,56 @@ ind[i] = new Individual(ns + "i" + i); } - // A1 has instances i0 to i19 + // assert individuals to owl:Thing (such that they exist in the knowledge base) + for(int i=0; i<100; i++) { + kb.addAxiom(new ClassAssertionAxiom(Thing.instance,ind[i])); + } + + // A0 has 20 instances (i0 to i19) for(int i=0; i<20; i++) { kb.addAxiom(new ClassAssertionAxiom(nc[0],ind[i])); } - // A2 has instances i10 to i29 + // A1 has 20 instances (i10 to i29) for(int i=10; i<30; i++) { kb.addAxiom(new ClassAssertionAxiom(nc[1],ind[i])); } + // A2 has 40 instances (i10 to i49) + for(int i=10; i<50; i++) { + kb.addAxiom(new ClassAssertionAxiom(nc[2],ind[i])); + } + ComponentManager cm = ComponentManager.getInstance(); KnowledgeSource ks = new KBFile(kb); ReasonerComponent reasoner = cm.reasoner(OWLAPIReasoner.class, ks); ClassLearningProblem problem = cm.learningProblem(ClassLearningProblem.class, reasoner); ks.init(); reasoner.init(); - + // evaluate A2 wrt. A1 using Jaccard HeuristicTests.configureClassLP(problem, nc[0], "jaccard"); // the value should be 10 (i10-i19) divided by 30 (i0-i29) assertEqualsClassLP(problem, nc[1], 1/(double)3); - + assertEqualsClassLP(problem, nc[2], 1/(double)5); + + HeuristicTests.configureClassLP(problem, nc[0], "pred_acc"); + // the value should be the sum of 10 (correct positives) and 970 (correct negatives) divided by 1000 + assertEqualsClassLP(problem, nc[1], (10+70)/(double)100); + assertEqualsClassLP(problem, nc[2], (10+50)/(double)100); + + HeuristicTests.configureClassLP(problem, nc[0], "fmeasure"); + // recall = precision = F1-score = 0.5 + assertEqualsClassLP(problem, nc[1], 0.5); + // recall = 0.5, precision = 0.25, F1-score = 0.33... + assertEqualsClassLP(problem, nc[2], 1/(double)3); + + // TODO: generalised F-Measure + + // TODO: test approximations + + // TODO: test super class learning + } // the class learning problem provides several ways to get the accuracy of a description, this method This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2010-07-14 15:39:57
|
Revision: 2199 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2199&view=rev Author: jenslehmann Date: 2010-07-14 15:39:50 +0000 (Wed, 14 Jul 2010) Log Message: ----------- - fixed bug in description minimizer - fixed bug in evaluated set - CELOE now defaults to not suppressing expressions, which contain an expression already on the suggestion list - wrote unit tests for minimizer and sub expression checks - extended unit tests for heuristics - implemented search tree option for CELOE Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java trunk/src/dl-learner/org/dllearner/utilities/owl/DescriptionMinimizer.java trunk/src/dl-learner/org/dllearner/utilities/owl/EvaluatedDescriptionSet.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/test/junit/ClassExpressionTests.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/test/junit/MinimizeTests.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2010-07-14 10:08:19 UTC (rev 2198) +++ trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2010-07-14 15:39:50 UTC (rev 2199) @@ -19,6 +19,7 @@ */ package org.dllearner.algorithms.celoe; +import java.io.File; import java.text.DecimalFormat; import java.util.Collection; import java.util.Iterator; @@ -30,6 +31,7 @@ import java.util.TreeSet; import org.apache.log4j.Logger; +import org.dllearner.algorithms.refinement2.ExampleBasedNode; import org.dllearner.core.ComponentInitException; import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.LearningAlgorithm; @@ -39,6 +41,7 @@ import org.dllearner.core.options.BooleanConfigOption; import org.dllearner.core.options.CommonConfigOptions; import org.dllearner.core.options.ConfigOption; +import org.dllearner.core.options.StringConfigOption; import org.dllearner.core.owl.ClassHierarchy; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; @@ -53,6 +56,7 @@ import org.dllearner.refinementoperators.OperatorInverter; import org.dllearner.refinementoperators.RefinementOperator; import org.dllearner.refinementoperators.RhoDRDown; +import org.dllearner.utilities.Files; import org.dllearner.utilities.Helper; import org.dllearner.utilities.owl.ConceptComparator; import org.dllearner.utilities.owl.ConceptTransformation; @@ -119,8 +123,13 @@ // important parameters private double noise; private double maxDepth; - private boolean filterFollowsFromKB; + private boolean filterFollowsFromKB; + // less important parameters + // forces that one solution cannot be subexpression of another expression; this option is useful to get diversity + // but it can also suppress quite useful expressions + private boolean forceMutualDifference = false; + // utility variables private String baseURI; private Map<String, String> prefixes; @@ -169,6 +178,9 @@ options.add(CommonConfigOptions.getInstanceBasedDisjoints()); options.add(new BooleanConfigOption("filterDescriptionsFollowingFromKB", "If true, then the results will not contain suggestions, which already follow logically from the knowledge base. Be careful, since this requires a potentially expensive consistency check for candidate solutions.", false)); options.add(new BooleanConfigOption("reuseExistingDescription", "If true, the algorithm tries to find a good starting point close to an existing definition/super class of the given class in the knowledge base.", false)); + options.add(new BooleanConfigOption("writeSearchTree", "specifies whether to write a search tree", false)); + options.add(new StringConfigOption("searchTreeFile","file to use for the search tree", "log/searchTree.txt")); + options.add(new BooleanConfigOption("replaceSearchTree","specifies whether to replace the search tree in the log file after each run or append the new search tree", false)); return options; } @@ -193,6 +205,9 @@ operator = new RhoDRDown(reasoner, classHierarchy, startClass, configurator); baseURI = reasoner.getBaseURI(); prefixes = reasoner.getPrefixes(); + if(configurator.getWriteSearchTree()) { + Files.clearFile(new File(configurator.getSearchTreeFile())); + } bestEvaluatedDescriptions = new EvaluatedDescriptionSet(configurator.getMaxNrOfResults()); @@ -374,6 +389,24 @@ updateMinMaxHorizExp(nextNode); + // writing the search tree (if configured) + if (configurator.getWriteSearchTree()) { + String treeString = "best node: " + bestEvaluatedDescriptions.getBest() + "\n"; + if (refinements.size() > 1) { + treeString += "all expanded nodes:\n"; + for (Description n : refinements) { + treeString += " " + n + "\n"; + } + } + treeString += startNode.toTreeString(baseURI); + treeString += "\n"; + + if (configurator.getReplaceSearchTree()) + Files.createFile(new File(configurator.getSearchTreeFile()), treeString); + else + Files.appendFile(new File(configurator.getSearchTreeFile()), treeString); + } + // System.out.println(loop); loop++; } @@ -486,6 +519,8 @@ return true; } +// System.out.println("description " + description + " accuracy " + accuracy); + // maybe add to best descriptions (method keeps set size fixed); // we need to make sure that this does not get called more often than // necessary since rewriting is expensive @@ -498,30 +533,42 @@ (accuracy >= accThreshold && description.getLength() < worst.getDescriptionLength())); } +// System.out.println(isCandidate); + // System.out.println("Test4 " + new Date()); if(isCandidate) { + Description niceDescription = rewriteNode(node); ConceptTransformation.transformToOrderedForm(niceDescription, descriptionComparator); // Description niceDescription = node.getDescription(); // another test: none of the other suggested descriptions should be // a subdescription of this one unless accuracy is different + // => comment: on the one hand, this appears to be too strict, because once A is a solution then everything containing + // A is not a candidate; on the other hand this suppresses many meaningless extensions of A boolean shorterDescriptionExists = false; - for(EvaluatedDescription ed : bestEvaluatedDescriptions.getSet()) { - if(Math.abs(ed.getAccuracy()-accuracy) <= 0.00001 && ConceptTransformation.isSubdescription(niceDescription, ed.getDescription())) { - shorterDescriptionExists = true; - break; - } + if(forceMutualDifference) { + for(EvaluatedDescription ed : bestEvaluatedDescriptions.getSet()) { + if(Math.abs(ed.getAccuracy()-accuracy) <= 0.00001 && ConceptTransformation.isSubdescription(niceDescription, ed.getDescription())) { +// System.out.println("shorter: " + ed.getDescription()); + shorterDescriptionExists = true; + break; + } + } } +// System.out.println("shorter description? " + shorterDescriptionExists + " nice: " + niceDescription); + if(!shorterDescriptionExists) { if(!filterFollowsFromKB || !((ClassLearningProblem)learningProblem).followsFromKB(niceDescription)) { +// System.out.println("Test2"); bestEvaluatedDescriptions.add(niceDescription, accuracy, learningProblem); // System.out.println("acc: " + accuracy); // System.out.println(bestEvaluatedDescriptions); } } +// System.out.println(bestEvaluatedDescriptions.getSet().size()); } // System.out.println("Test5 " + new Date()); Modified: trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java 2010-07-14 10:08:19 UTC (rev 2198) +++ trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java 2010-07-14 15:39:50 UTC (rev 2199) @@ -219,6 +219,33 @@ public boolean getReuseExistingDescription() { return (Boolean) ComponentManager.getInstance().getConfigOptionValue(cELOE, "reuseExistingDescription") ; } +/** +* writeSearchTree specifies whether to write a search tree. +* mandatory: false| reinit necessary: true +* default value: false +* @return boolean +**/ +public boolean getWriteSearchTree() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(cELOE, "writeSearchTree") ; +} +/** +* searchTreeFile file to use for the search tree. +* mandatory: false| reinit necessary: true +* default value: log/searchTree.txt +* @return String +**/ +public String getSearchTreeFile() { +return (String) ComponentManager.getInstance().getConfigOptionValue(cELOE, "searchTreeFile") ; +} +/** +* replaceSearchTree specifies whether to replace the search tree in the log file after each run or append the new search tree. +* mandatory: false| reinit necessary: true +* default value: false +* @return boolean +**/ +public boolean getReplaceSearchTree() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(cELOE, "replaceSearchTree") ; +} /** * @param useAllConstructor specifies whether the universal concept constructor is used in the learning algorithm. @@ -382,6 +409,33 @@ ComponentManager.getInstance().applyConfigEntry(cELOE, "reuseExistingDescription", reuseExistingDescription); reinitNecessary = true; } +/** +* @param writeSearchTree specifies whether to write a search tree. +* mandatory: false| reinit necessary: true +* default value: false +**/ +public void setWriteSearchTree(boolean writeSearchTree) { +ComponentManager.getInstance().applyConfigEntry(cELOE, "writeSearchTree", writeSearchTree); +reinitNecessary = true; +} +/** +* @param searchTreeFile file to use for the search tree. +* mandatory: false| reinit necessary: true +* default value: log/searchTree.txt +**/ +public void setSearchTreeFile(String searchTreeFile) { +ComponentManager.getInstance().applyConfigEntry(cELOE, "searchTreeFile", searchTreeFile); +reinitNecessary = true; +} +/** +* @param replaceSearchTree specifies whether to replace the search tree in the log file after each run or append the new search tree. +* mandatory: false| reinit necessary: true +* default value: false +**/ +public void setReplaceSearchTree(boolean replaceSearchTree) { +ComponentManager.getInstance().applyConfigEntry(cELOE, "replaceSearchTree", replaceSearchTree); +reinitNecessary = true; +} /** * true, if this component needs reinitializsation. Added: trunk/src/dl-learner/org/dllearner/test/junit/ClassExpressionTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ClassExpressionTests.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/test/junit/ClassExpressionTests.java 2010-07-14 15:39:50 UTC (rev 2199) @@ -0,0 +1,87 @@ +/** + * Copyright (C) 2007-2010, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.test.junit; + +import static org.junit.Assert.*; + +import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.Intersection; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.ObjectAllRestriction; +import org.dllearner.core.owl.ObjectProperty; +import org.dllearner.parser.KBParser; +import org.dllearner.parser.ParseException; +import org.dllearner.test.junit.TestOntologies.TestOntology; +import org.dllearner.utilities.owl.ConceptTransformation; +import org.dllearner.utilities.owl.DescriptionMinimizer; +import org.junit.Test; + +/** + * Tests on class expressins, e.g. transformations or tests on them. + * + * @author Jens Lehmann + * + */ +public class ClassExpressionTests { + + @Test + public void minimizeTest1() throws ParseException { + ReasonerComponent reasoner = TestOntologies.getTestOntology(TestOntology.FATHER_OE); + DescriptionMinimizer minimizer = new DescriptionMinimizer(reasoner); + Description d = KBParser.parseConcept("(\"http://example.com/father#male\" AND (\"http://example.com/father#male\" OR EXISTS \"http://example.com/father#hasChild\".TOP))"); + Description minD = minimizer.minimize(d); + assertTrue(minD.toString().equals("http://example.com/father#male")); + } + + @Test + public void minimizeTest2() throws ParseException { + // this tests for a bug, when in A AND A AND SOMETHING, both A were removed because they subsume + // each other, while in fact only one A should be removed + ReasonerComponent reasoner = TestOntologies.getTestOntology(TestOntology.MDM); + DescriptionMinimizer minimizer = new DescriptionMinimizer(reasoner); + NamedClass nc = new NamedClass("http://acl/BMV#MedicalThings"); + ObjectProperty op = new ObjectProperty("http://acl/BMV#refersSubstance"); + Description tmp1 = new ObjectAllRestriction(op,nc); + Description d = new Intersection(nc,tmp1); + Description d2 = new Intersection(nc,nc,tmp1); + Description minD = minimizer.minimizeClone(d); + Description minD2 = minimizer.minimizeClone(d2); + + assertEquals(minD.toString(),minD2.toString()); + } + + @Test + public void subExpressionTest1() throws ParseException { + Description d = KBParser.parseConcept("(\"http://example.com/father#male\" AND (\"http://example.com/father#male\" OR EXISTS \"http://example.com/father#hasChild\".TOP))"); + Description d2 = KBParser.parseConcept("EXISTS \"http://example.com/father#hasChild\".TOP"); + assertTrue(ConceptTransformation.isSubdescription(d, d2)); + + Description d3 = KBParser.parseConcept("(\"http://example.com/test#A\" AND (\"http://example.com/father#A\" AND EXISTS \"http://example.com/father#hasChild\".TOP))"); + Description d4 = KBParser.parseConcept("EXISTS \"http://example.com/father#hasChild\".TOP"); + assertTrue(ConceptTransformation.isSubdescription(d3, d4)); + + // related to http://sourceforge.net/tracker/?func=detail&atid=986319&aid=3029181&group_id=203619 + Description d5 = KBParser.parseConcept("(\"http://acl/BMV#MedicalThings\" AND (\"http://acl/BMV#MedicalThings\" AND ALL \"http://acl/BMV#refersSubstance\".\"http://acl/BMV#MedicalThings\"))"); + Description d6 = KBParser.parseConcept("ALL \"http://acl/BMV#refersSubstance\".\"http://acl/BMV#MedicalThings\""); + assertTrue(ConceptTransformation.isSubdescription(d5, d6)); + + } +} Modified: trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java 2010-07-14 10:08:19 UTC (rev 2198) +++ trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java 2010-07-14 15:39:50 UTC (rev 2199) @@ -115,6 +115,7 @@ // TODO: test super class learning + // TODO: test noise parameter } // the class learning problem provides several ways to get the accuracy of a description, this method Deleted: trunk/src/dl-learner/org/dllearner/test/junit/MinimizeTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/MinimizeTests.java 2010-07-14 10:08:19 UTC (rev 2198) +++ trunk/src/dl-learner/org/dllearner/test/junit/MinimizeTests.java 2010-07-14 15:39:50 UTC (rev 2199) @@ -1,46 +0,0 @@ -/** - * Copyright (C) 2007-2009, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.test.junit; - -import org.dllearner.core.ReasonerComponent; -import org.dllearner.core.owl.Description; -import org.dllearner.parser.KBParser; -import org.dllearner.parser.ParseException; -import org.dllearner.test.junit.TestOntologies.TestOntology; -import org.dllearner.utilities.owl.DescriptionMinimizer; -import org.junit.Test; - -/** - * Tests for minimizing class descriptions. - * - * @author Jens Lehmann - * - */ -public class MinimizeTests { - - @Test - public void minimizeTest1() throws ParseException { - ReasonerComponent reasoner = TestOntologies.getTestOntology(TestOntology.FATHER_OE); - DescriptionMinimizer minimizer = new DescriptionMinimizer(reasoner); - Description d = KBParser.parseConcept("(\"http://example.com/father#male\" AND (\"http://example.com/father#male\" OR EXISTS \"http://example.com/father#hasChild\".TOP))"); - Description minD = minimizer.minimize(d); - assert(minD.toString().equals("http://example.com/father#male")); - } -} Modified: trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java 2010-07-14 10:08:19 UTC (rev 2198) +++ trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java 2010-07-14 15:39:50 UTC (rev 2199) @@ -41,7 +41,7 @@ */ public final class TestOntologies { - public enum TestOntology { EMPTY, SIMPLE, SIMPLE_NO_DR, SIMPLE_NO_DISJOINT, SIMPLE_NO_DR_DISJOINT, SIMPLE2, SIMPLE3, R1SUBR2, DATA1, FIVE_ROLES, FATHER, FATHER_OE, CARCINOGENESIS, EPC_OE, KRK_ZERO_ONE, DBPEDIA_OWL, TRAINS_OWL, RHO1, SWORE }; + public enum TestOntology { EMPTY, SIMPLE, SIMPLE_NO_DR, SIMPLE_NO_DISJOINT, SIMPLE_NO_DR_DISJOINT, SIMPLE2, SIMPLE3, R1SUBR2, DATA1, FIVE_ROLES, FATHER, FATHER_OE, CARCINOGENESIS, EPC_OE, KRK_ZERO_ONE, DBPEDIA_OWL, TRAINS_OWL, RHO1, SWORE, MDM }; public static ReasonerComponent getTestOntology(TestOntology ont) { String kbString = ""; @@ -134,6 +134,8 @@ owlFile = "examples/cross-benchmark/trains/trains.owl"; } else if(ont.equals(TestOntology.SWORE)) { owlFile = "examples/swore/swore.rdf"; + } else if(ont.equals(TestOntology.MDM)) { + owlFile = "resources/test/MDM0.73.owl"; } try { Modified: trunk/src/dl-learner/org/dllearner/utilities/owl/DescriptionMinimizer.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/owl/DescriptionMinimizer.java 2010-07-14 10:08:19 UTC (rev 2198) +++ trunk/src/dl-learner/org/dllearner/utilities/owl/DescriptionMinimizer.java 2010-07-14 15:39:50 UTC (rev 2199) @@ -146,52 +146,95 @@ } return description; } else if(description instanceof Intersection || description instanceof Union) { - List<Integer> toRemove = new LinkedList<Integer>(); - // intersection + if(description instanceof Intersection) { - // in an intersection, we have that D1 \sqcap D2 \equiv D1 if - // D1 \sqsubseteq D2; this means we first check whether the - // first element in a union is superclass of any other element in the - // union; if yes, then we delete it and proceed to the next element for(int i=0; i<children.size(); i++) { - for(int j=0; j<children.size(); j++) { + for(int j=0; j<children.size(); j++) { if(i != j && isSubclassOf(children.get(j), children.get(i))) { - toRemove.add(i-toRemove.size()); - break; + // remove element because it is super class of another element + children.remove(i); + // we apply the minimization procedure again after removal of the element + // (this is not the fastest implementation but avoids bugs as in the previous code) + if(children.size()==1) { + return minimize(children.get(0)); + } else { + return minimize(description); + } } } - } - // union + } } else { - // in a union, we have that D1 \sqcup D2 \equiv D2 if - // D1 \sqsubseteq D2; this means we first check whether the - // first element in a union is subclass of any other element in the - // union; if yes, then we delete it and proceed to the next element - // (note the difference to intersection) for(int i=0; i<children.size(); i++) { for(int j=0; j<children.size(); j++) { if(i != j && isSubclassOf(children.get(i), children.get(j))) { - toRemove.add(i-toRemove.size()); - break; + children.remove(i); + if(children.size()==1) { + return minimize(children.get(0)); + } else { + return minimize(description); + } } } - } - } - // if all elements are superfluous wrt. another element, then we need - // to keep at least one - if(toRemove.size() == children.size()) { - return children.get(0); - } else { - // remove all elements according to remove list - for(int pos : toRemove) { - children.remove(pos); } - // dissolve intersection with only one element - if(children.size()==1) { - return children.get(0); - } - return description; } + + // no subclass relationships => description is already minimal + return description; + + // the code below is buggy because in "A AND A AND C", it removes both As + +// List<Integer> toRemove = new LinkedList<Integer>(); +// // intersection +// if(description instanceof Intersection) { +// // in an intersection, we have that D1 \sqcap D2 \equiv D1 if +// // D1 \sqsubseteq D2; this means we first check whether the +// // first element in an intersection is subclass of any other element in the +// // intersection; if yes, then we delete it and proceed to the next element +// for(int i=0; i<children.size(); i++) { +// for(int j=0; j<children.size(); j++) { +// if(i!=j) +// System.out.println(children.get(i) + " -- " + children.get(j)); +// if(i != j && isSubclassOf(children.get(j), children.get(i))) { +// System.out.println("sub"); +// toRemove.add(i-toRemove.size()); +// break; +// } +// } +// } +// // union +// } else { +// // in a union, we have that D1 \sqcup D2 \equiv D2 if +// // D1 \sqsubseteq D2; this means we first check whether the +// // first element in a union is subclass of any other element in the +// // union; if yes, then we delete it and proceed to the next element +// // (note the difference to intersection) +// for(int i=0; i<children.size(); i++) { +// for(int j=0; j<children.size(); j++) { +// if(i != j && isSubclassOf(children.get(i), children.get(j))) { +// toRemove.add(i-toRemove.size()); +// break; +// } +// } +// } +// } +// +// System.out.println("to remove: " + toRemove); +// +// // if all elements are superfluous wrt. another element, then we need +// // to keep at least one +// if(toRemove.size() == children.size()) { +// return children.get(0); +// } else { +// // remove all elements according to remove list +// for(int pos : toRemove) { +// children.remove(pos); +// } +// // dissolve intersection with only one element +// if(children.size()==1) { +// return children.get(0); +// } +// return description; +// } } else { throw new Error("Cannot minimize description " + description + "."); } Modified: trunk/src/dl-learner/org/dllearner/utilities/owl/EvaluatedDescriptionSet.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/owl/EvaluatedDescriptionSet.java 2010-07-14 10:08:19 UTC (rev 2198) +++ trunk/src/dl-learner/org/dllearner/utilities/owl/EvaluatedDescriptionSet.java 2010-07-14 15:39:50 UTC (rev 2199) @@ -51,7 +51,9 @@ } public void add(Description description, double accuracy, LearningProblem problem) { - if(set.size()==0 || getWorst().getAccuracy() <= accuracy) { + // bug http://sourceforge.net/tracker/?func=detail&atid=986319&aid=3029181&group_id=203619 + // -> set should be filled up to max size before we compare acc. with the worst result + if(set.size()<maxSize || getWorst().getAccuracy() <= accuracy) { set.add(problem.evaluate(description)); } if(set.size()>maxSize) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2010-07-15 14:15:27
|
Revision: 2201 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2201&view=rev Author: jenslehmann Date: 2010-07-15 14:15:20 +0000 (Thu, 15 Jul 2010) Log Message: ----------- unit tests for heuristics in super class learning Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java trunk/src/dl-learner/org/dllearner/scripts/evaluation/HeuristicOverviewTableGenerator.java trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2010-07-15 13:18:16 UTC (rev 2200) +++ trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2010-07-15 14:15:20 UTC (rev 2201) @@ -31,7 +31,6 @@ import java.util.TreeSet; import org.apache.log4j.Logger; -import org.dllearner.algorithms.refinement2.ExampleBasedNode; import org.dllearner.core.ComponentInitException; import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.LearningAlgorithm; Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2010-07-15 13:18:16 UTC (rev 2200) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2010-07-15 14:15:20 UTC (rev 2201) @@ -231,7 +231,7 @@ if(heuristic.equals(HeuristicType.FMEASURE)) { acc = getFMeasure(recall, precision); } else if(heuristic.equals(HeuristicType.AMEASURE)) { - acc = getAccuracy(recall, precision); + acc = Heuristics.getAScore(recall, precision, coverageFactor); } else { // TODO: some superfluous instance checks are required to compute accuracy => // move accuracy computation here if possible @@ -431,10 +431,10 @@ double size; if(estimatedA) { // size = 1/(coverageFactor+1) * (coverageFactor * (upperBorderA-lowerBorderA) + Math.sqrt(upperEstimateA/(upperEstimateA+lowerEstimate)) + Math.sqrt(lowerEstimateA/(lowerEstimateA+upperEstimate))); - size = heuristic.equals(HeuristicType.FMEASURE) ? getFMeasure(upperBorderA, upperEstimateA/(double)(upperEstimateA+lowerEstimate)) - getFMeasure(lowerBorderA, lowerEstimateA/(double)(lowerEstimateA+upperEstimate)) : getAccuracy(upperBorderA, upperEstimateA/(double)(upperEstimateA+lowerEstimate)) - getAccuracy(lowerBorderA, lowerEstimateA/(double)(lowerEstimateA+upperEstimate)); + size = heuristic.equals(HeuristicType.FMEASURE) ? getFMeasure(upperBorderA, upperEstimateA/(double)(upperEstimateA+lowerEstimate)) - getFMeasure(lowerBorderA, lowerEstimateA/(double)(lowerEstimateA+upperEstimate)) : Heuristics.getAScore(upperBorderA, upperEstimateA/(double)(upperEstimateA+lowerEstimate), coverageFactor) - Heuristics.getAScore(lowerBorderA, lowerEstimateA/(double)(lowerEstimateA+upperEstimate),coverageFactor); } else { // size = 1/(coverageFactor+1) * (coverageFactor * coverage + Math.sqrt(instancesCovered/(instancesCovered+lowerEstimate)) + Math.sqrt(instancesCovered/(instancesCovered+upperEstimate))); - size = heuristic.equals(HeuristicType.FMEASURE) ? getFMeasure(recall, instancesCovered/(double)(instancesCovered+lowerEstimate)) - getFMeasure(recall, instancesCovered/(double)(instancesCovered+upperEstimate)) : getAccuracy(recall, instancesCovered/(double)(instancesCovered+lowerEstimate)) - getAccuracy(recall, instancesCovered/(double)(instancesCovered+upperEstimate)); + size = heuristic.equals(HeuristicType.FMEASURE) ? getFMeasure(recall, instancesCovered/(double)(instancesCovered+lowerEstimate)) - getFMeasure(recall, instancesCovered/(double)(instancesCovered+upperEstimate)) : Heuristics.getAScore(recall, instancesCovered/(double)(instancesCovered+lowerEstimate),coverageFactor) - Heuristics.getAScore(recall, instancesCovered/(double)(instancesCovered+upperEstimate),coverageFactor); } if(size < 0.1) { @@ -457,7 +457,7 @@ precision = 0; } - return heuristic.equals(HeuristicType.FMEASURE) ? getFMeasure(recall, precision) : getAccuracy(recall, precision); + return heuristic.equals(HeuristicType.FMEASURE) ? getFMeasure(recall, precision) : Heuristics.getAScore(recall, precision, coverageFactor); } else { throw new Error("Approximation for " + heuristic + " not implemented."); @@ -538,14 +538,13 @@ double precision = (additionalInstances + coveredInstances == 0) ? 0 : coveredInstances / (double) (coveredInstances + additionalInstances); - if(heuristic.equals(HeuristicType.AMEASURE)) { // best reachable concept has same recall and precision 1: // 1/t+1 * (t*r + 1) if((coverageFactor*recall+1)/(double)(coverageFactor+1) <(1-noise)) { return -1; } else { - return getAccuracy(recall, precision); + return Heuristics.getAScore(recall, precision, coverageFactor); } } else if(heuristic.equals(HeuristicType.FMEASURE)) { // best reachable concept has same recall and precision 1: @@ -718,11 +717,11 @@ // computes accuracy from coverage and protusion (changing this function may // make it necessary to change the appoximation too) => not the case anymore - private double getAccuracy(double recall, double precision) { +// private double getAccuracy(double recall, double precision) { // return (coverageFactor * coverage + Math.sqrt(protusion)) / (coverageFactor + 1); // log: changed from precision^^0.5 (root) to precision^^0.8 as the root is too optimistic in some cases - return (coverageFactor * recall + Math.pow(precision, 0.8)) / (coverageFactor + 1); - } +// return (coverageFactor * recall + Math.pow(precision, 0.8)) / (coverageFactor + 1); +// } private double getFMeasure(double recall, double precision) { // balanced F measure Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/HeuristicOverviewTableGenerator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/HeuristicOverviewTableGenerator.java 2010-07-15 13:18:16 UTC (rev 2200) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/HeuristicOverviewTableGenerator.java 2010-07-15 14:15:20 UTC (rev 2201) @@ -73,7 +73,7 @@ } private List<Input> inputs; - private DecimalFormat df = new DecimalFormat(); + private DecimalFormat df = new DecimalFormat( "0.000000000000" ); public HeuristicOverviewTableGenerator(List<Input> inputs) { this.inputs = inputs; @@ -144,7 +144,9 @@ inputs.add(new Input(100, 400, 1000, 100)); inputs.add(new Input(100, 100, 1000, 90)); inputs.add(new Input(100, 50, 1000, 50)); - + inputs.add(new Input(20, 20, 100, 10)); + inputs.add(new Input(20, 40, 100, 10)); + HeuristicOverviewTableGenerator gen = new HeuristicOverviewTableGenerator(inputs); gen.printFullTable(); } Modified: trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java 2010-07-15 13:18:16 UTC (rev 2200) +++ trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java 2010-07-15 14:15:20 UTC (rev 2201) @@ -92,6 +92,8 @@ ks.init(); reasoner.init(); + //// equivalent classes, no noise, no approximations //// + // evaluate A2 wrt. A1 using Jaccard HeuristicTests.configureClassLP(problem, nc[0], "jaccard"); // the value should be 10 (i10-i19) divided by 30 (i0-i29) @@ -103,12 +105,38 @@ assertEqualsClassLP(problem, nc[1], (10+70)/(double)100); assertEqualsClassLP(problem, nc[2], (10+50)/(double)100); + HeuristicTests.configureClassLP(problem, nc[0], "standard"); + assertEqualsClassLP(problem, nc[1], 0.5); + assertEqualsClassLP(problem, nc[2], 0.375); + HeuristicTests.configureClassLP(problem, nc[0], "fmeasure"); // recall = precision = F1-score = 0.5 assertEqualsClassLP(problem, nc[1], 0.5); // recall = 0.5, precision = 0.25, F1-score = 0.33... assertEqualsClassLP(problem, nc[2], 1/(double)3); + //// super class learning //// + + // Jaccard + HeuristicTests.configureClassLP(problem, nc[0], "jaccard", false, false, 0.05); + // the value should be 10 (i10-i19) divided by 30 (i0-i29) + assertEqualsClassLP(problem, nc[1], 1/(double)3); + assertEqualsClassLP(problem, nc[2], 1/(double)5); + + HeuristicTests.configureClassLP(problem, nc[0], "pred_acc", false, false, 0.05); + assertEqualsClassLP(problem, nc[1], 5/(double)7); + assertEqualsClassLP(problem, nc[2], 4/(double)7); + + HeuristicTests.configureClassLP(problem, nc[0], "standard"); + assertEqualsClassLP(problem, nc[1], 0.5); + assertEqualsClassLP(problem, nc[2], 0.4375); + + HeuristicTests.configureClassLP(problem, nc[0], "fmeasure", false, false, 0.05); + // recall = precision = F1-score = 0.5 + assertEqualsClassLP(problem, nc[1], 0.5); + // recall = 0.5, precision = 0.25, F1-score = 0.33... + assertEqualsClassLP(problem, nc[2], 0.366025403784); + // TODO: generalised F-Measure // TODO: test approximations @@ -140,12 +168,13 @@ } // convencience method to set the learning problem to a desired configuration - private static void configureClassLP(ClassLearningProblem problem, NamedClass classToDescribe, String accuracyMethod, boolean useApproximations, double approxAccuracy) throws ComponentInitException { + private static void configureClassLP(ClassLearningProblem problem, NamedClass classToDescribe, String accuracyMethod, boolean equivalenceLearning, boolean useApproximations, double approxAccuracy) throws ComponentInitException { try { problem.getConfigurator().setClassToDescribe(new URL(classToDescribe.getName())); } catch (MalformedURLException e) { e.printStackTrace(); } + problem.getConfigurator().setType("superClass"); problem.getConfigurator().setAccuracyMethod(accuracyMethod); problem.getConfigurator().setUseApproximations(useApproximations); problem.getConfigurator().setApproxAccuracy(approxAccuracy); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2010-07-20 08:06:42
|
Revision: 2206 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2206&view=rev Author: jenslehmann Date: 2010-07-20 08:06:33 +0000 (Tue, 20 Jul 2010) Log Message: ----------- heuristic approximation tests Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/learningproblems/Heuristics.java trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java Modified: trunk/src/dl-learner/org/dllearner/learningproblems/Heuristics.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/Heuristics.java 2010-07-17 15:26:41 UTC (rev 2205) +++ trunk/src/dl-learner/org/dllearner/learningproblems/Heuristics.java 2010-07-20 08:06:33 UTC (rev 2206) @@ -120,7 +120,7 @@ * @return A two element double array, where element 0 is the lower border and element * 1 the upper border of the 95% confidence interval. */ - public static double[] getConfidenceInterval95Wald(int success, int total) { + public static double[] getConfidenceInterval95Wald(int total, int success) { if(success > total || total < 1) { throw new IllegalArgumentException(); } @@ -178,13 +178,13 @@ * @param nrOfRelevantInstances Number of relevant instances, i.e. number of instances, which * would have been tested without approximations. * @param nrOfInstanceChecks Performed instance checks for the approximation. - * @param successfulInstanceChecks Number of successful performed instance checks. + * @param nrOfSuccessfulInstanceChecks Number of successful performed instance checks. * @return A two element array, where the first element is the computed F-beta score and the * second element is the length of the 95% confidence interval around it. */ - public static double[] getFMeasureApproximation(int nrOfPosClassifiedPositives, double recall, double beta, int nrOfRelevantInstances, int nrOfInstanceChecks, int successfulInstanceChecks) { + public static double[] getFMeasureApproximation(int nrOfPosClassifiedPositives, double recall, double beta, int nrOfRelevantInstances, int nrOfInstanceChecks, int nrOfSuccessfulInstanceChecks) { // compute 95% confidence interval - double[] interval = Heuristics.getConfidenceInterval95Wald(successfulInstanceChecks, nrOfInstanceChecks); + double[] interval = Heuristics.getConfidenceInterval95Wald(nrOfInstanceChecks, nrOfSuccessfulInstanceChecks); // multiply by number of instances from which the random samples are drawn double lowerBorder = interval[0] * nrOfRelevantInstances; double upperBorder = interval[1] * nrOfRelevantInstances; @@ -203,4 +203,29 @@ return ret; } + public static double[] getAMeasureApproximationStep1(double beta, int nrOfPosExamples, int nrOfInstanceChecks, int nrOfSuccessfulInstanceChecks) { + // the method is just a wrapper around a single confidence interval approximation; + // method approximates t * a / |R(A)| + double[] interval = Heuristics.getConfidenceInterval95Wald(nrOfInstanceChecks, nrOfSuccessfulInstanceChecks); + double diff = beta * (interval[1] - interval[0]); + double ret[] = new double[2]; + ret[0] = beta * interval[0] + 0.5*diff; + ret[1] = diff; + return ret; + } + + public static double[] getAMeasureApproximationStep2(int nrOfPosClassifiedPositives, double[] recallInterval, double beta, int nrOfRelevantInstances, int nrOfInstanceChecks, int nrOfSuccessfulInstanceChecks) { + // TODO: code untested + double[] interval = Heuristics.getConfidenceInterval95Wald(nrOfInstanceChecks, nrOfSuccessfulInstanceChecks); + double precisionLowerBorder = nrOfPosClassifiedPositives / interval[1] * nrOfRelevantInstances; + double precisionUpperBorder = nrOfPosClassifiedPositives / interval[0] * nrOfRelevantInstances; + double lowerBorder = Heuristics.getAScore(recallInterval[0] / beta, precisionLowerBorder, beta); + double upperBorder = Heuristics.getAScore(recallInterval[0] / beta, precisionUpperBorder, beta); + double diff = upperBorder - lowerBorder; + double ret[] = new double[2]; + ret[0] = lowerBorder + 0.5*diff; + ret[1] = diff; + return ret; + } + } Modified: trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java 2010-07-17 15:26:41 UTC (rev 2205) +++ trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java 2010-07-20 08:06:33 UTC (rev 2206) @@ -36,6 +36,7 @@ import org.dllearner.core.owl.Thing; import org.dllearner.kb.KBFile; import org.dllearner.learningproblems.ClassLearningProblem; +import org.dllearner.learningproblems.Heuristics; import org.dllearner.reasoning.OWLAPIReasoner; import org.junit.Test; @@ -157,6 +158,23 @@ } + @Test + public void approximationTests() { + // perform F-Measure example in ontology engineering paper, which was computed on paper + // TODO: compute again, because unit tests fails (probably rounding errors) + double[] approx1 = Heuristics.getFMeasureApproximation(800, 0.8, 1, 10000, 41, 31); + assertEquals(0.0505, approx1[1], delta); + double[] approx2 = Heuristics.getFMeasureApproximation(800, 0.8, 1, 10000, 42, 32); + assertEquals(0.1699, approx2[0], delta); + assertEquals(0.0489, approx2[1], delta); + + // perform A-Measure example in ontology engineering paper + // setup: 1000 class instances, 10000 relevant instances, delta=0.10 + // input1: 90 out of 95 tests => no success para 1, 91 out of 96 => success + // input2: using estimation from input 1, 32 out of 64 => success + // overall accuracy: 64% + } + // the class learning problem provides several ways to get the accuracy of a description, this method // tests all of those private static void assertEqualsClassLP(ClassLearningProblem problem, Description description, double accuracy) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2010-07-21 08:25:02
|
Revision: 2208 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2208&view=rev Author: jenslehmann Date: 2010-07-21 08:24:55 +0000 (Wed, 21 Jul 2010) Log Message: ----------- more unit tests for heuristic approximation Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java trunk/src/dl-learner/org/dllearner/learningproblems/Heuristics.java trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2010-07-21 05:48:18 UTC (rev 2207) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2010-07-21 08:24:55 UTC (rev 2208) @@ -311,7 +311,7 @@ testsPerformed++; // check whether approximation is sufficiently accurate - double[] approx = Heuristics.getFMeasureApproximation(instancesCovered, recall, coverageFactor, superClassInstances.size(), testsPerformed, instancesDescription); + double[] approx = Heuristics.getFScoreApproximation(instancesCovered, recall, coverageFactor, superClassInstances.size(), testsPerformed, instancesDescription); if(approx[1]<approxDelta) { return approx[0]; } Modified: trunk/src/dl-learner/org/dllearner/learningproblems/Heuristics.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/Heuristics.java 2010-07-21 05:48:18 UTC (rev 2207) +++ trunk/src/dl-learner/org/dllearner/learningproblems/Heuristics.java 2010-07-21 08:24:55 UTC (rev 2208) @@ -122,7 +122,7 @@ */ public static double[] getConfidenceInterval95Wald(int total, int success) { if(success > total || total < 1) { - throw new IllegalArgumentException(); + throw new IllegalArgumentException("95% confidence interval for " + success + " out of " + total + " trials cannot be estimated."); } double[] ret = new double[2]; double p1 = (success+2)/(double)(total+4); @@ -182,7 +182,7 @@ * @return A two element array, where the first element is the computed F-beta score and the * second element is the length of the 95% confidence interval around it. */ - public static double[] getFMeasureApproximation(int nrOfPosClassifiedPositives, double recall, double beta, int nrOfRelevantInstances, int nrOfInstanceChecks, int nrOfSuccessfulInstanceChecks) { + public static double[] getFScoreApproximation(int nrOfPosClassifiedPositives, double recall, double beta, int nrOfRelevantInstances, int nrOfInstanceChecks, int nrOfSuccessfulInstanceChecks) { // compute 95% confidence interval double[] interval = Heuristics.getConfidenceInterval95Wald(nrOfInstanceChecks, nrOfSuccessfulInstanceChecks); // multiply by number of instances from which the random samples are drawn @@ -203,10 +203,21 @@ return ret; } - public static double[] getAMeasureApproximationStep1(double beta, int nrOfPosExamples, int nrOfInstanceChecks, int nrOfSuccessfulInstanceChecks) { + /** + * In the first step of the AScore approximation, we estimate recall (taking the factor + * beta into account). This is not much more than a wrapper around the modified Wald method. + * @param beta Weights precision and recall. If beta is >1, then recall is more important + * than precision. + * @param nrOfPosExamples Number of positive examples (or instances of the considered class). + * @param nrOfInstanceChecks Number of positive examples (or instances of the considered class) which have been checked. + * @param nrOfSuccessfulInstanceChecks Number of positive examples (or instances of the considered class), where the instance check returned true. + * @return A two element array, where the first element is the recall multiplied by beta and the + * second element is the length of the 95% confidence interval around it. + */ + public static double[] getAScoreApproximationStep1(double beta, int nrOfPosExamples, int nrOfInstanceChecks, int nrOfSuccessfulInstanceChecks) { // the method is just a wrapper around a single confidence interval approximation; // method approximates t * a / |R(A)| - double[] interval = Heuristics.getConfidenceInterval95Wald(nrOfInstanceChecks, nrOfSuccessfulInstanceChecks); + double[] interval = Heuristics.getConfidenceInterval95Wald(nrOfSuccessfulInstanceChecks, nrOfInstanceChecks); double diff = beta * (interval[1] - interval[0]); double ret[] = new double[2]; ret[0] = beta * interval[0] + 0.5*diff; @@ -214,13 +225,36 @@ return ret; } - public static double[] getAMeasureApproximationStep2(int nrOfPosClassifiedPositives, double[] recallInterval, double beta, int nrOfRelevantInstances, int nrOfInstanceChecks, int nrOfSuccessfulInstanceChecks) { - // TODO: code untested + /** + * In step 2 of the A-Score approximation, the precision and overall A-Score is estimated based on + * the estimated recall. + * @param nrOfPosClassifiedPositives Positive examples (instance of a class), which are classified as positives. + * @param recallInterval The estimated recall, which needs to be given as a two element array with the first element being the mean value and the second element being the length of the interval (to be compatible with the step1 method). + * @param beta Weights precision and recall. If beta is >1, then recall is more important + * than precision. + * @param nrOfRelevantInstances Number of relevant instances, i.e. number of instances, which + * would have been tested without approximations. + * @param nrOfInstanceChecks Performed instance checks for the approximation. + * @param nrOfSuccessfulInstanceChecks Number of performed instance checks, which returned true. + * @return A two element array, where the first element is the estimated A-Score and the + * second element is the length of the 95% confidence interval around it. + */ + public static double[] getAScoreApproximationStep2(int nrOfPosClassifiedPositives, double[] recallInterval, double beta, int nrOfRelevantInstances, int nrOfInstanceChecks, int nrOfSuccessfulInstanceChecks) { + // recall interval is given as mean + interval size (to fit the other method calls) => computer lower and upper border + double recallLowerBorder = (recallInterval[0] - 0.5*recallInterval[1]) / beta; + double recallUpperBorder = (recallInterval[0] + 0.5*recallInterval[1]) / beta; + // estimate precision double[] interval = Heuristics.getConfidenceInterval95Wald(nrOfInstanceChecks, nrOfSuccessfulInstanceChecks); - double precisionLowerBorder = nrOfPosClassifiedPositives / interval[1] * nrOfRelevantInstances; - double precisionUpperBorder = nrOfPosClassifiedPositives / interval[0] * nrOfRelevantInstances; - double lowerBorder = Heuristics.getAScore(recallInterval[0] / beta, precisionLowerBorder, beta); - double upperBorder = Heuristics.getAScore(recallInterval[0] / beta, precisionUpperBorder, beta); + + double precisionLowerBorder = nrOfPosClassifiedPositives / (nrOfPosClassifiedPositives + interval[1] * nrOfRelevantInstances); + double precisionUpperBorder = nrOfPosClassifiedPositives / (nrOfPosClassifiedPositives + interval[0] * nrOfRelevantInstances); + +// System.out.println("rec low: " + recallLowerBorder); +// System.out.println("rec up: " + recallUpperBorder); +// System.out.println("prec low: " + precisionLowerBorder); +// System.out.println("prec up: " + precisionUpperBorder); + double lowerBorder = Heuristics.getAScore(recallLowerBorder, precisionLowerBorder, beta); + double upperBorder = Heuristics.getAScore(recallUpperBorder, precisionUpperBorder, beta); double diff = upperBorder - lowerBorder; double ret[] = new double[2]; ret[0] = lowerBorder + 0.5*diff; Modified: trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java 2010-07-21 05:48:18 UTC (rev 2207) +++ trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java 2010-07-21 08:24:55 UTC (rev 2208) @@ -161,18 +161,34 @@ @Test public void approximationTests() { // perform F-Measure example in ontology engineering paper, which was computed on paper - // TODO: compute again, because unit tests fails (probably rounding errors) - double[] approx1 = Heuristics.getFMeasureApproximation(800, 0.8, 1, 10000, 41, 31); - assertEquals(0.0505, approx1[1], delta); - double[] approx2 = Heuristics.getFMeasureApproximation(800, 0.8, 1, 10000, 42, 32); - assertEquals(0.1699, approx2[0], delta); - assertEquals(0.0489, approx2[1], delta); + double[] approx1 = Heuristics.getFScoreApproximation(800, 0.8, 1, 10000, 41, 31); + // smaller delta, because of rounding errors + assertEquals(0.050517, approx1[1], 0.001); + double[] approx2 = Heuristics.getFScoreApproximation(800, 0.8, 1, 10000, 42, 32); + // 0.1699 in the paper is just current precision divided by multiplied by relevant instances + // 0.1778 is the center of the interval + assertEquals(0.178091, approx2[0], 0.001); + assertEquals(0.048933, approx2[1], 0.001); // perform A-Measure example in ontology engineering paper // setup: 1000 class instances, 10000 relevant instances, delta=0.10 // input1: 90 out of 95 tests => no success para 1, 91 out of 96 => success // input2: using estimation from input 1, 32 out of 64 => success // overall accuracy: 64% + double[] approx1Step1 = Heuristics.getAScoreApproximationStep1(1, 1000, 90, 95); + assertEquals(0.10006, approx1Step1[1], 0.001); + // on paper, it works with 91 out of 96; but in the implementation only with + // 92 out of 97 (probably rounding errors) + double[] approx2Step1 = Heuristics.getAScoreApproximationStep1(1, 1000, 92, 97); + assertTrue(approx2Step1[1] < 0.1); + + // double[] approxStep2 = Heuristics.getAScoreApproximationStep2(800, new double[] {approx2Step1[0]-0.5*approx2Step1[1], approx2Step1[0]+0.5*approx2Step1[1]}, 1, 10000, 64, 32); + // example computed by hand (note that it differs from the paper example in that + // we do not use the square root) + double[] approxStep2 = Heuristics.getAScoreApproximationStep2(800, approx2Step1, 1, 10000, 64, 32); + assertEquals(0.49822461, approxStep2[0]-0.5*approxStep2[1], 0.001); + assertEquals(0.5771179, approxStep2[0]+0.5*approxStep2[1], 0.001); +// System.out.println(approxStep2[0] + " " + approxStep2[1]); } // the class learning problem provides several ways to get the accuracy of a description, this method This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2010-07-21 17:55:31
|
Revision: 2214 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2214&view=rev Author: jenslehmann Date: 2010-07-21 17:55:24 +0000 (Wed, 21 Jul 2010) Log Message: ----------- wrote small script to find SPARQL endpoints on the web Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/utilities/Files.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/scripts/SparqlEndpointFinder.java Added: trunk/src/dl-learner/org/dllearner/scripts/SparqlEndpointFinder.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SparqlEndpointFinder.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/scripts/SparqlEndpointFinder.java 2010-07-21 17:55:24 UTC (rev 2214) @@ -0,0 +1,83 @@ +/** + * Copyright (C) 2007-2010, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.scripts; + +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.LinkedList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.dllearner.utilities.Files; + +/** + * Tries to find some public SPARQL endpoints on the web. + * + * @author Jens Lehmann + * + */ +public class SparqlEndpointFinder { + + public static void main(String[] args) throws MalformedURLException, IOException { + SparqlEndpointFinder finder = new SparqlEndpointFinder(); + System.out.println(finder.find()); + } + + public List<String> find() throws MalformedURLException, IOException { + // the W3 wiki SPARQL endpoints page is often updated + String str = Files.readFile(new URL("http://esw.w3.org/index.php?title=SparqlEndpoints&action=edit")); + // typical wiki syntax: [http://dbtune.org/bbc/peel/sparql endpoint] + Pattern p = Pattern.compile("\\[(.+?) endpoint\\]"); + Matcher m = p.matcher(str); + + List<String> endpoints = new LinkedList<String>(); + while (m.find()) { + String endpoint = m.group(1); + if(SparqlEndpointFinder.validateEndpoint(endpoint)) { + endpoints.add(endpoint); + } + } + + // TODO: finde more endpoints e.g. at http://www.freebase.com/view/user/bio2rdf/public/sparql + // or using voiD files + + // TODO: find graphs + + return endpoints; + } + + public static boolean validateEndpoint(String str) { +// URL url = null; + try { +// url = new URL(str); + new URL(str); + } catch (MalformedURLException e) { + return false; + } + // TODO: send example query to check whether endpoint is alive + return true; + } + +} Modified: trunk/src/dl-learner/org/dllearner/utilities/Files.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/Files.java 2010-07-21 17:27:28 UTC (rev 2213) +++ trunk/src/dl-learner/org/dllearner/utilities/Files.java 2010-07-21 17:55:24 UTC (rev 2214) @@ -28,8 +28,10 @@ import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; +import java.io.InputStreamReader; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import java.net.URL; import java.util.ArrayList; import java.util.List; @@ -43,6 +45,25 @@ public static boolean debug = false; /** + * Reads input from a URL and stores it in a string (only recommend for small files). + * @param file URL of a file. + * @return Contents of the file. + * @throws IOException URL not accessible or content cannot be read for some reason. + */ + public static String readFile(URL file) throws IOException { + BufferedReader in = new BufferedReader(new InputStreamReader(file.openStream())); + + StringBuffer input = new StringBuffer(); + String inputLine; + while ((inputLine = in.readLine()) != null) { + input.append(inputLine + "\n"); + } + in.close(); + + return input.toString(); + } + + /** * Reads in a file. * * @param file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2010-08-02 10:05:02
|
Revision: 2222 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2222&view=rev Author: jenslehmann Date: 2010-08-02 10:04:55 +0000 (Mon, 02 Aug 2010) Log Message: ----------- fixed some warnings Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/SemanticBible.java trunk/src/dl-learner/org/dllearner/scripts/SparqlEndpointFinder.java trunk/src/dl-learner/org/dllearner/scripts/evaluation/OntologyEngineering.java trunk/src/dl-learner/org/dllearner/utilities/owl/DescriptionMinimizer.java Modified: trunk/src/dl-learner/org/dllearner/scripts/SemanticBible.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SemanticBible.java 2010-08-02 08:55:24 UTC (rev 2221) +++ trunk/src/dl-learner/org/dllearner/scripts/SemanticBible.java 2010-08-02 10:04:55 UTC (rev 2222) @@ -20,8 +20,6 @@ package org.dllearner.scripts; import java.io.File; -import java.util.ArrayList; -import java.util.List; import java.util.SortedSet; import java.util.TreeSet; @@ -31,9 +29,7 @@ import org.apache.log4j.Logger; import org.apache.log4j.SimpleLayout; import org.dllearner.algorithms.refinement2.ROLComponent2; -import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.KnowledgeSource; -import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.NamedClass; @@ -42,7 +38,6 @@ import org.dllearner.kb.sparql.Cache; import org.dllearner.kb.sparql.SparqlKnowledgeSource; import org.dllearner.kb.sparql.SparqlQuery; -import org.dllearner.learningproblems.EvaluatedDescriptionPosNeg; import org.dllearner.reasoning.ReasonerType; import org.dllearner.utilities.Files; import org.dllearner.utilities.components.ReasonerComponentFactory; @@ -166,12 +161,14 @@ } private static void learnOriginal(NamedClass target, SortedSet<Individual> posExamples, SortedSet<Individual> negExamples) { + /* List<? extends EvaluatedDescription> conceptresults = new ArrayList<EvaluatedDescriptionPosNeg>(); System.out.println("Starting to learn original"); //System.out.println(ConfWriter.listExamples(true, posExamples)); //System.out.println(ConfWriter.listExamples(false, negExamples)); //System.exit(0); // LearnOWLFile learner = new LearnOWLFile(getConfForOriginal(target)); + LearningAlgorithm la = null; try{ // la = learner.learn( @@ -189,8 +186,8 @@ for (EvaluatedDescription description : conceptresults) { Files.appendFile(file,"\t"+ description+"\n" ); } + */ - } public static LearnSPARQLConfiguration getConfForSparql(NamedClass c) { Modified: trunk/src/dl-learner/org/dllearner/scripts/SparqlEndpointFinder.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SparqlEndpointFinder.java 2010-08-02 08:55:24 UTC (rev 2221) +++ trunk/src/dl-learner/org/dllearner/scripts/SparqlEndpointFinder.java 2010-08-02 10:04:55 UTC (rev 2222) @@ -19,11 +19,8 @@ */ package org.dllearner.scripts; -import java.io.File; import java.io.IOException; import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; import java.net.URL; import java.util.LinkedList; import java.util.List; Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/OntologyEngineering.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/OntologyEngineering.java 2010-08-02 08:55:24 UTC (rev 2221) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/OntologyEngineering.java 2010-08-02 10:04:55 UTC (rev 2222) @@ -137,6 +137,7 @@ } } + @SuppressWarnings("unchecked") public static void run(ReasonerComponent reasoner) throws ComponentInitException, IOException, LearningProblemUnsupportedException { ComponentManager cm = ComponentManager.getInstance(); Modified: trunk/src/dl-learner/org/dllearner/utilities/owl/DescriptionMinimizer.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/owl/DescriptionMinimizer.java 2010-08-02 08:55:24 UTC (rev 2221) +++ trunk/src/dl-learner/org/dllearner/utilities/owl/DescriptionMinimizer.java 2010-08-02 10:04:55 UTC (rev 2222) @@ -19,7 +19,6 @@ */ package org.dllearner.utilities.owl; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.TreeMap; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2010-08-02 13:54:38
|
Revision: 2226 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2226&view=rev Author: jenslehmann Date: 2010-08-02 13:54:32 +0000 (Mon, 02 Aug 2010) Log Message: ----------- fixed difficult regression problem discovered by unit test Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java trunk/src/dl-learner/org/dllearner/test/junit/RefinementOperatorTests.java Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2010-08-02 13:23:17 UTC (rev 2225) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2010-08-02 13:54:32 UTC (rev 2226) @@ -1057,13 +1057,19 @@ mA.get(nc).put(1,m1); // most specific negated classes, which are not disjoint with nc - SortedSet<Description> m2 = getNegClassCandidates(nc); - mA.get(nc).put(2,m2); + SortedSet<Description> m2 = new TreeSet<Description>(); + if(useNegation) { + m2 = getNegClassCandidates(nc); + mA.get(nc).put(2,m2); + } + System.out.println("m1 " + "(" + nc + "): " + m1); + System.out.println("m2 " + "(" + nc + "): " + m2); + /* SortedSet<Description> m2 = new TreeSet<Description>(conceptComparator); if(useNegation) { - // the definition in the paper is more complex, but acutally + // the definition in the paper is more complex, but actually // we only have to insert the most specific concepts satisfying // the mentioned restrictions; there is no need to implement a // recursive method because for A subClassOf A' we have not A' @@ -1174,11 +1180,12 @@ private SortedSet<Description> getClassCandidatesRecursive(Description index, Description upperClass) { SortedSet<Description> candidates = new TreeSet<Description>(); +// System.out.println("index " + index + " upper class " + upperClass); // we descend the subsumption hierarchy to ensure that we get // the most general concepts satisfying the criteria for(Description candidate : subHierarchy.getSubClasses(upperClass)) { -// System.out.print("testing " + candidate + " ... "); +// System.out.println("testing " + candidate + " ... "); // NamedClass candidate = (NamedClass) d; // check disjointness with index (if not no further traversal downwards is necessary) @@ -1191,9 +1198,11 @@ // upper class boolean meaningful; if(instanceBasedDisjoints) { - SortedSet<Individual> tmp = rs.getIndividuals(upperClass); + // bug: tests should be performed against the index, not the upper class +// SortedSet<Individual> tmp = rs.getIndividuals(upperClass); + SortedSet<Individual> tmp = rs.getIndividuals(index); tmp.removeAll(rs.getIndividuals(candidate)); -// System.out.println("tmp: " + tmp); +// System.out.println(" instances of " + index + " and not " + candidate + ": " + tmp.size()); meaningful = tmp.size() != 0; } else { meaningful = !isDisjoint(new Negation(candidate),index); @@ -1213,6 +1222,7 @@ // System.out.println(" ruled out, because it is disjoint"); // } } +// System.out.println("cc method exit"); return candidates; } @@ -1223,14 +1233,20 @@ private SortedSet<Description> getNegClassCandidatesRecursive(Description index, Description lowerClass) { SortedSet<Description> candidates = new TreeSet<Description>(conceptComparator); +// System.out.println("index " + index + " lower class " + lowerClass); for(Description candidate : subHierarchy.getSuperClasses(lowerClass)) { + if(!(candidate instanceof Thing)) { +// System.out.println("candidate: " + candidate); + // check disjointness with index/range (should not be disjoint otherwise not useful) if(!isDisjoint(new Negation(candidate),index)) { boolean meaningful; +// System.out.println("not disjoint"); if(instanceBasedDisjoints) { - SortedSet<Individual> tmp = rs.getIndividuals(lowerClass); + SortedSet<Individual> tmp = rs.getIndividuals(index); tmp.removeAll(rs.getIndividuals(new Negation(candidate))); meaningful = tmp.size() != 0; +// System.out.println("instances " + tmp.size()); } else { meaningful = !isDisjoint(candidate,index); } @@ -1238,9 +1254,10 @@ if(meaningful) { candidates.add(new Negation(candidate)); } else { - candidates.addAll(getClassCandidatesRecursive(index, candidate)); + candidates.addAll(getNegClassCandidatesRecursive(index, candidate)); } } + } } return candidates; } Modified: trunk/src/dl-learner/org/dllearner/test/junit/RefinementOperatorTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/RefinementOperatorTests.java 2010-08-02 13:23:17 UTC (rev 2225) +++ trunk/src/dl-learner/org/dllearner/test/junit/RefinementOperatorTests.java 2010-08-02 13:54:32 UTC (rev 2226) @@ -175,6 +175,18 @@ // EXISTS hasPiece.>= 2 hasLowerRankThan.(WRook AND TOP) // >= 2 hasPiece.EXISTS hasLowerRankThan.(WRook AND TOP) + // the 8 refinements found on 2010/08/02 are as follows: + // EXISTS hasPiece.EXISTS hasLowerRankThan.(BKing AND WRook) + // EXISTS hasPiece.EXISTS hasLowerRankThan.(WKing AND WRook) + // EXISTS hasPiece.EXISTS hasLowerRankThan.(WRook AND WRook) + // EXISTS hasPiece.EXISTS hasLowerRankThan.(WRook AND (NOT BKing)) + // EXISTS hasPiece.EXISTS hasLowerRankThan.(WRook AND (NOT WKing)) + // EXISTS hasPiece.EXISTS hasLowerRankThan.(WRook AND (NOT WRook)) + + // EXISTS hasPiece.EXISTS hasLowerRankThan.(Piece AND WRook) + // EXISTS hasPiece.>= 2 hasLowerRankThan.(WRook AND TOP) + // >= 2 hasPiece.EXISTS hasLowerRankThan.(WRook AND TOP) + assertTrue(results.size()==desiredResultSize); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2010-08-02 14:51:26
|
Revision: 2227 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2227&view=rev Author: jenslehmann Date: 2010-08-02 14:51:20 +0000 (Mon, 02 Aug 2010) Log Message: ----------- small fix Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java trunk/src/dl-learner/org/dllearner/test/junit/ExampleTests.java Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2010-08-02 13:54:32 UTC (rev 2226) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2010-08-02 14:51:20 UTC (rev 2227) @@ -1063,8 +1063,8 @@ mA.get(nc).put(2,m2); } - System.out.println("m1 " + "(" + nc + "): " + m1); - System.out.println("m2 " + "(" + nc + "): " + m2); +// System.out.println("m1 " + "(" + nc + "): " + m1); +// System.out.println("m2 " + "(" + nc + "): " + m2); /* SortedSet<Description> m2 = new TreeSet<Description>(conceptComparator); Modified: trunk/src/dl-learner/org/dllearner/test/junit/ExampleTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ExampleTests.java 2010-08-02 13:54:32 UTC (rev 2226) +++ trunk/src/dl-learner/org/dllearner/test/junit/ExampleTests.java 2010-08-02 14:51:20 UTC (rev 2227) @@ -70,7 +70,7 @@ boolean randomize = true; // GPs can be excluded temporarily (because those tests are very time-consuming) - boolean testGP = true; + boolean testGP = false; // we use a logger, which outputs few messages (warnings, errors) SimpleLayout layout = new SimpleLayout(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2010-08-03 09:05:12
|
Revision: 2231 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2231&view=rev Author: lorenz_b Date: 2010-08-03 09:05:05 +0000 (Tue, 03 Aug 2010) Log Message: ----------- Removed some warnings. Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/configurators/BruteForceLearnerConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/DIGReasonerConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/ELLearningAlgorithmConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/ELLearningAlgorithmDisjunctiveConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/FastRetrievalReasonerConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/GPConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/ISLEConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/KBFileConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIOntologyConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIReasonerConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/OWLFileConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/PelletReasonerConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/PosNegLPStandardConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/PosNegLPStrictConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyLPConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/ProtegeReasonerConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/ROLComponent2Configurator.java trunk/src/dl-learner/org/dllearner/core/configurators/ROLearnerConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/RandomGuesserConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDown.java trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java trunk/src/dl-learner/org/dllearner/scripts/evaluation/OntologyEngineering.java trunk/src/dl-learner/org/dllearner/utilities/analyse/ScriptDoAll.java trunk/src/dl-learner/org/dllearner/utilities/statistics/RawAgreement.java Modified: trunk/src/dl-learner/org/dllearner/core/configurators/BruteForceLearnerConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/BruteForceLearnerConfigurator.java 2010-08-03 08:36:04 UTC (rev 2230) +++ trunk/src/dl-learner/org/dllearner/core/configurators/BruteForceLearnerConfigurator.java 2010-08-03 09:05:05 UTC (rev 2231) @@ -33,8 +33,6 @@ public class BruteForceLearnerConfigurator implements Configurator { private boolean reinitNecessary = false; -@SuppressWarnings("unused") - private BruteForceLearner bruteForceLearner; /** Modified: trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java 2010-08-03 08:36:04 UTC (rev 2230) +++ trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java 2010-08-03 09:05:05 UTC (rev 2231) @@ -35,8 +35,6 @@ public class CELOEConfigurator extends RefinementOperatorConfigurator implements Configurator { private boolean reinitNecessary = false; -@SuppressWarnings("unused") - private CELOE cELOE; /** Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java 2010-08-03 08:36:04 UTC (rev 2230) +++ trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java 2010-08-03 09:05:05 UTC (rev 2231) @@ -32,8 +32,6 @@ public class ClassLearningProblemConfigurator implements Configurator { private boolean reinitNecessary = false; -@SuppressWarnings("unused") - private ClassLearningProblem classLearningProblem; /** Modified: trunk/src/dl-learner/org/dllearner/core/configurators/DIGReasonerConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/DIGReasonerConfigurator.java 2010-08-03 08:36:04 UTC (rev 2230) +++ trunk/src/dl-learner/org/dllearner/core/configurators/DIGReasonerConfigurator.java 2010-08-03 09:05:05 UTC (rev 2231) @@ -32,8 +32,6 @@ public class DIGReasonerConfigurator implements Configurator { private boolean reinitNecessary = false; -@SuppressWarnings("unused") - private DIGReasoner dIGReasoner; /** Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ELLearningAlgorithmConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/ELLearningAlgorithmConfigurator.java 2010-08-03 08:36:04 UTC (rev 2230) +++ trunk/src/dl-learner/org/dllearner/core/configurators/ELLearningAlgorithmConfigurator.java 2010-08-03 09:05:05 UTC (rev 2231) @@ -33,8 +33,6 @@ public class ELLearningAlgorithmConfigurator implements Configurator { private boolean reinitNecessary = false; -@SuppressWarnings("unused") - private ELLearningAlgorithm eLLearningAlgorithm; /** Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ELLearningAlgorithmDisjunctiveConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/ELLearningAlgorithmDisjunctiveConfigurator.java 2010-08-03 08:36:04 UTC (rev 2230) +++ trunk/src/dl-learner/org/dllearner/core/configurators/ELLearningAlgorithmDisjunctiveConfigurator.java 2010-08-03 09:05:05 UTC (rev 2231) @@ -33,8 +33,6 @@ public class ELLearningAlgorithmDisjunctiveConfigurator implements Configurator { private boolean reinitNecessary = false; -@SuppressWarnings("unused") - private ELLearningAlgorithmDisjunctive eLLearningAlgorithmDisjunctive; /** Modified: trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java 2010-08-03 08:36:04 UTC (rev 2230) +++ trunk/src/dl-learner/org/dllearner/core/configurators/FastInstanceCheckerConfigurator.java 2010-08-03 09:05:05 UTC (rev 2231) @@ -32,8 +32,6 @@ public class FastInstanceCheckerConfigurator implements Configurator { private boolean reinitNecessary = false; -@SuppressWarnings("unused") - private FastInstanceChecker fastInstanceChecker; /** Modified: trunk/src/dl-learner/org/dllearner/core/configurators/FastRetrievalReasonerConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/FastRetrievalReasonerConfigurator.java 2010-08-03 08:36:04 UTC (rev 2230) +++ trunk/src/dl-learner/org/dllearner/core/configurators/FastRetrievalReasonerConfigurator.java 2010-08-03 09:05:05 UTC (rev 2231) @@ -32,8 +32,6 @@ public class FastRetrievalReasonerConfigurator implements Configurator { private boolean reinitNecessary = false; -@SuppressWarnings("unused") - private FastRetrievalReasoner fastRetrievalReasoner; /** Modified: trunk/src/dl-learner/org/dllearner/core/configurators/GPConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/GPConfigurator.java 2010-08-03 08:36:04 UTC (rev 2230) +++ trunk/src/dl-learner/org/dllearner/core/configurators/GPConfigurator.java 2010-08-03 09:05:05 UTC (rev 2231) @@ -33,8 +33,6 @@ public class GPConfigurator implements Configurator { private boolean reinitNecessary = false; -@SuppressWarnings("unused") - private GP gP; /** Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ISLEConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/ISLEConfigurator.java 2010-08-03 08:36:04 UTC (rev 2230) +++ trunk/src/dl-learner/org/dllearner/core/configurators/ISLEConfigurator.java 2010-08-03 09:05:05 UTC (rev 2231) @@ -35,8 +35,6 @@ public class ISLEConfigurator extends RefinementOperatorConfigurator implements Configurator { private boolean reinitNecessary = false; -@SuppressWarnings("unused") - private ISLE iSLE; /** Modified: trunk/src/dl-learner/org/dllearner/core/configurators/KBFileConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/KBFileConfigurator.java 2010-08-03 08:36:04 UTC (rev 2230) +++ trunk/src/dl-learner/org/dllearner/core/configurators/KBFileConfigurator.java 2010-08-03 09:05:05 UTC (rev 2231) @@ -31,8 +31,6 @@ public class KBFileConfigurator implements Configurator { private boolean reinitNecessary = false; -@SuppressWarnings("unused") - private KBFile kBFile; /** Modified: trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIOntologyConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIOntologyConfigurator.java 2010-08-03 08:36:04 UTC (rev 2230) +++ trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIOntologyConfigurator.java 2010-08-03 09:05:05 UTC (rev 2231) @@ -30,8 +30,6 @@ public class OWLAPIOntologyConfigurator implements Configurator { private boolean reinitNecessary = false; -@SuppressWarnings("unused") - private OWLAPIOntology oWLAPIOntology; /** Modified: trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIReasonerConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIReasonerConfigurator.java 2010-08-03 08:36:04 UTC (rev 2230) +++ trunk/src/dl-learner/org/dllearner/core/configurators/OWLAPIReasonerConfigurator.java 2010-08-03 09:05:05 UTC (rev 2231) @@ -32,8 +32,6 @@ public class OWLAPIReasonerConfigurator implements Configurator { private boolean reinitNecessary = false; -@SuppressWarnings("unused") - private OWLAPIReasoner oWLAPIReasoner; /** Modified: trunk/src/dl-learner/org/dllearner/core/configurators/OWLFileConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/OWLFileConfigurator.java 2010-08-03 08:36:04 UTC (rev 2230) +++ trunk/src/dl-learner/org/dllearner/core/configurators/OWLFileConfigurator.java 2010-08-03 09:05:05 UTC (rev 2231) @@ -31,8 +31,6 @@ public class OWLFileConfigurator implements Configurator { private boolean reinitNecessary = false; -@SuppressWarnings("unused") - private OWLFile oWLFile; /** Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PelletReasonerConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/PelletReasonerConfigurator.java 2010-08-03 08:36:04 UTC (rev 2230) +++ trunk/src/dl-learner/org/dllearner/core/configurators/PelletReasonerConfigurator.java 2010-08-03 09:05:05 UTC (rev 2231) @@ -32,8 +32,6 @@ public class PelletReasonerConfigurator implements Configurator { private boolean reinitNecessary = false; -@SuppressWarnings("unused") - private PelletReasoner pelletReasoner; /** Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosNegLPStandardConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/PosNegLPStandardConfigurator.java 2010-08-03 08:36:04 UTC (rev 2230) +++ trunk/src/dl-learner/org/dllearner/core/configurators/PosNegLPStandardConfigurator.java 2010-08-03 09:05:05 UTC (rev 2231) @@ -32,8 +32,6 @@ public class PosNegLPStandardConfigurator implements Configurator { private boolean reinitNecessary = false; -@SuppressWarnings("unused") - private PosNegLPStandard posNegLPStandard; /** Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosNegLPStrictConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/PosNegLPStrictConfigurator.java 2010-08-03 08:36:04 UTC (rev 2230) +++ trunk/src/dl-learner/org/dllearner/core/configurators/PosNegLPStrictConfigurator.java 2010-08-03 09:05:05 UTC (rev 2231) @@ -32,8 +32,6 @@ public class PosNegLPStrictConfigurator implements Configurator { private boolean reinitNecessary = false; -@SuppressWarnings("unused") - private PosNegLPStrict posNegLPStrict; /** Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyLPConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyLPConfigurator.java 2010-08-03 08:36:04 UTC (rev 2230) +++ trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyLPConfigurator.java 2010-08-03 09:05:05 UTC (rev 2231) @@ -32,8 +32,6 @@ public class PosOnlyLPConfigurator implements Configurator { private boolean reinitNecessary = false; -@SuppressWarnings("unused") - private PosOnlyLP posOnlyLP; /** Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ProtegeReasonerConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/ProtegeReasonerConfigurator.java 2010-08-03 08:36:04 UTC (rev 2230) +++ trunk/src/dl-learner/org/dllearner/core/configurators/ProtegeReasonerConfigurator.java 2010-08-03 09:05:05 UTC (rev 2231) @@ -32,8 +32,6 @@ public class ProtegeReasonerConfigurator implements Configurator { private boolean reinitNecessary = false; -@SuppressWarnings("unused") - private ProtegeReasoner protegeReasoner; /** Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ROLComponent2Configurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/ROLComponent2Configurator.java 2010-08-03 08:36:04 UTC (rev 2230) +++ trunk/src/dl-learner/org/dllearner/core/configurators/ROLComponent2Configurator.java 2010-08-03 09:05:05 UTC (rev 2231) @@ -36,8 +36,6 @@ public class ROLComponent2Configurator extends RefinementOperatorConfigurator implements Configurator { private boolean reinitNecessary = false; -@SuppressWarnings("unused") - private ROLComponent2 rOLComponent2; /** Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ROLearnerConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/ROLearnerConfigurator.java 2010-08-03 08:36:04 UTC (rev 2230) +++ trunk/src/dl-learner/org/dllearner/core/configurators/ROLearnerConfigurator.java 2010-08-03 09:05:05 UTC (rev 2231) @@ -36,8 +36,6 @@ public class ROLearnerConfigurator extends RefinementOperatorConfigurator implements Configurator { private boolean reinitNecessary = false; -@SuppressWarnings("unused") - private ROLearner rOLearner; /** Modified: trunk/src/dl-learner/org/dllearner/core/configurators/RandomGuesserConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/RandomGuesserConfigurator.java 2010-08-03 08:36:04 UTC (rev 2230) +++ trunk/src/dl-learner/org/dllearner/core/configurators/RandomGuesserConfigurator.java 2010-08-03 09:05:05 UTC (rev 2231) @@ -33,8 +33,6 @@ public class RandomGuesserConfigurator implements Configurator { private boolean reinitNecessary = false; -@SuppressWarnings("unused") - private RandomGuesser randomGuesser; /** Modified: trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java 2010-08-03 08:36:04 UTC (rev 2230) +++ trunk/src/dl-learner/org/dllearner/core/configurators/SparqlKnowledgeSourceConfigurator.java 2010-08-03 09:05:05 UTC (rev 2231) @@ -34,8 +34,6 @@ public class SparqlKnowledgeSourceConfigurator implements Configurator { private boolean reinitNecessary = false; -@SuppressWarnings("unused") - private SparqlKnowledgeSource sparqlKnowledgeSource; /** Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2010-08-03 08:36:04 UTC (rev 2230) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2010-08-03 09:05:05 UTC (rev 2231) @@ -471,7 +471,7 @@ // create new intersection for(Description c : tmp) { - List<Description> newChildren = (List<Description>)((LinkedList)description.getChildren()).clone(); + List<Description> newChildren = (List<Description>)((LinkedList<Description>)description.getChildren()).clone(); newChildren.add(c); newChildren.remove(child); Intersection mc = new Intersection(newChildren); Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDown.java 2010-08-03 08:36:04 UTC (rev 2230) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDown.java 2010-08-03 09:05:05 UTC (rev 2231) @@ -213,7 +213,7 @@ // werden dürfen // List<Concept> newChildren = new LinkedList<Concept>(concept.getChildren()); // TODO: Class Cast ist nur ein Hack - List<Description> newChildren = (List<Description>)((LinkedList)concept.getChildren()).clone(); + List<Description> newChildren = (List<Description>)((LinkedList<Description>)concept.getChildren()).clone(); // es muss genau die vorherige Reihenfolge erhalten bleiben // (zumindest bis die Normalform definiert ist) // int index = newChildren.indexOf(child); Modified: trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java 2010-08-03 08:36:04 UTC (rev 2230) +++ trunk/src/dl-learner/org/dllearner/scripts/ConfigJavaGenerator.java 2010-08-03 09:05:05 UTC (rev 2231) @@ -72,11 +72,11 @@ ISLEConfigurator.class.getSimpleName() })); - @SuppressWarnings("unchecked") - private static final Class EXTENDSREFINEMENTOPERATORCLASS = RefinementOperatorConfigurator.class; + private static final Class<RefinementOperatorConfigurator> EXTENDSREFINEMENTOPERATORCLASS = RefinementOperatorConfigurator.class; // private static final boolean INCLUDE_UNUSED = false; + @SuppressWarnings("unused") private static final String UNUSED = "@SuppressWarnings(\"unused\")\n"; private static final String OVERRIDE = "@SuppressWarnings(\"all\")\n"; @@ -297,7 +297,7 @@ } body.add("private boolean " + REINITVAR + " = false;"); - body.add(UNUSED); +// body.add(UNUSED); body.add(expandCollection(vars, "", "", 0)); body.add(fillConstructorTemplate(className)); Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/OntologyEngineering.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/OntologyEngineering.java 2010-08-03 08:36:04 UTC (rev 2230) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/OntologyEngineering.java 2010-08-03 09:05:05 UTC (rev 2231) @@ -86,7 +86,6 @@ private static boolean computeApproxDiff = true; private static boolean useFMeasure = false; - @SuppressWarnings("unchecked") public static void main(String[] args) throws ComponentInitException, LearningProblemUnsupportedException, IOException { Modified: trunk/src/dl-learner/org/dllearner/utilities/analyse/ScriptDoAll.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/analyse/ScriptDoAll.java 2010-08-03 08:36:04 UTC (rev 2230) +++ trunk/src/dl-learner/org/dllearner/utilities/analyse/ScriptDoAll.java 2010-08-03 09:05:05 UTC (rev 2231) @@ -29,7 +29,6 @@ public static void main(String[] args) { - @SuppressWarnings("unused") String dbpediaFile = "dbpedia_3.5.1.owl"; @SuppressWarnings("unused") String yagoFile = "yagoclasses_links.nt"; Modified: trunk/src/dl-learner/org/dllearner/utilities/statistics/RawAgreement.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/statistics/RawAgreement.java 2010-08-03 08:36:04 UTC (rev 2230) +++ trunk/src/dl-learner/org/dllearner/utilities/statistics/RawAgreement.java 2010-08-03 09:05:05 UTC (rev 2231) @@ -1,6 +1,5 @@ package org.dllearner.utilities.statistics; -import org.apache.log4j.Level; import org.apache.log4j.Logger; public class RawAgreement { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2010-08-05 13:16:31
|
Revision: 2244 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2244&view=rev Author: jenslehmann Date: 2010-08-05 13:16:25 +0000 (Thu, 05 Aug 2010) Log Message: ----------- unit test for loading several knowledge bases Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/ComponentManager.java trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java Modified: trunk/src/dl-learner/org/dllearner/core/ComponentManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2010-08-05 10:56:09 UTC (rev 2243) +++ trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2010-08-05 13:16:25 UTC (rev 2244) @@ -357,6 +357,24 @@ } /** + * Factory method for creating a reasoner component from a set of + * knowledge sources. + * @see #reasoner(Class, KnowledgeSource) + * @param <T> The type of this method is a subclass of reasoner component. + * @param reasoner A class object, where the class is subclass of ReasonerComponent. + * @param sources A set of knowledge sources. + * @return A reasoner component. + */ + public <T extends ReasonerComponent> T reasoner(Class<T> reasoner, + KnowledgeSource ... sources) { + Set<KnowledgeSource> s = new HashSet<KnowledgeSource>(); + for(KnowledgeSource source : sources) { + s.add(source); + } + return reasoner(reasoner, s); + } + + /** * This method returns an instance of <code>ReasonerComponent</code>. The * difference between <code>ReasonerComponent</code> and <code>ReasonerComponent</code> * is that the former delegates all calls to the latter and collects statistics Modified: trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java 2010-08-05 10:56:09 UTC (rev 2243) +++ trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java 2010-08-05 13:16:25 UTC (rev 2244) @@ -49,6 +49,7 @@ import org.dllearner.core.owl.KB; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.ObjectProperty; +import org.dllearner.core.owl.Thing; import org.dllearner.kb.KBFile; import org.dllearner.kb.OWLFile; import org.dllearner.parser.KBParser; @@ -311,6 +312,29 @@ } @Test + public void multipleKnowledgeSourcesTest() throws ComponentInitException { + String file1 = "examples/father.owl"; + String file2 = "examples/lymphography/lymphography.owl"; + ComponentManager cm = ComponentManager.getInstance(); + KnowledgeSource ks1 = cm.knowledgeSource(OWLFile.class); + KnowledgeSource ks2 = cm.knowledgeSource(OWLFile.class); + try { + cm.applyConfigEntry(ks1, "url", new File(file1).toURI().toURL()); + cm.applyConfigEntry(ks2, "url", new File(file2).toURI().toURL()); + } catch (MalformedURLException e) { + // should never happen + e.printStackTrace(); + } + ks1.init(); + ks2.init(); + ReasonerComponent reasoner = cm.reasoner(FastInstanceChecker.class, ks1, ks2); + reasoner.init(); + baseURI = reasoner.getBaseURI(); + System.out.println(reasoner.getSubClasses(Thing.instance)); + assertTrue(reasoner.getSubClasses(Thing.instance).size()==55); + } + + @Test public void compareReasoners() throws FileNotFoundException, ComponentInitException, ParseException{ ComponentManager cm = ComponentManager.getInstance(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2010-08-06 15:02:05
|
Revision: 2249 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2249&view=rev Author: jenslehmann Date: 2010-08-06 15:01:58 +0000 (Fri, 06 Aug 2010) Log Message: ----------- fixed bug #2952788 Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/test/junit/ClassExpressionTests.java trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptTransformation.java Modified: trunk/src/dl-learner/org/dllearner/test/junit/ClassExpressionTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ClassExpressionTests.java 2010-08-06 14:16:23 UTC (rev 2248) +++ trunk/src/dl-learner/org/dllearner/test/junit/ClassExpressionTests.java 2010-08-06 15:01:58 UTC (rev 2249) @@ -23,10 +23,14 @@ import org.dllearner.core.ReasonerComponent; import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.Intersection; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.ObjectAllRestriction; import org.dllearner.core.owl.ObjectProperty; +import org.dllearner.core.owl.ObjectSomeRestriction; +import org.dllearner.core.owl.ObjectValueRestriction; +import org.dllearner.core.owl.Union; import org.dllearner.parser.KBParser; import org.dllearner.parser.ParseException; import org.dllearner.test.junit.TestOntologies.TestOntology; @@ -84,4 +88,52 @@ assertTrue(ConceptTransformation.isSubdescription(d5, d6)); } + + /** + * We test a method, which delivers in which context all quantifiers occur + * (i.e. how they are nested in a class expression). + */ + @Test + public void forAllContextTest() { + // create some basic ontology elements + NamedClass a1 = new NamedClass("a1"); + NamedClass a2 = new NamedClass("a2"); + ObjectProperty p1 = new ObjectProperty("p1"); + ObjectProperty p2 = new ObjectProperty("p2"); + ObjectProperty p3 = new ObjectProperty("p3"); + Individual i1 = new Individual("i1"); + + // create some class expressions + Description d1 = new Intersection(a1,a2); + Description d2 = new ObjectAllRestriction(p1,a1); + Description d3 = new Union(d1,d2); + Description d4 = new ObjectValueRestriction(p2,i1); + Description d5 = new ObjectAllRestriction(p2,d2); + Description d6 = new ObjectAllRestriction(p1,d4); + Description d7 = new ObjectSomeRestriction(p3,d5); + Description d8 = new Union(d2,d5); + Description d9 = new ObjectAllRestriction(p1,d8); + + // a1 AND a2 => should be empty result + assertTrue(ConceptTransformation.getForallContexts(d1).isEmpty()); + // note: the assertions below use toString() which should usually be avoided, but since + // the toString() method of SortedSet is unlikely to change we use it here for convenience + // ALL p1.a1 => context: [[p1]] + assertTrue(ConceptTransformation.getForallContexts(d2).toString().equals("[[p1]]")); + // (a1 AND a2) OR ALL p1.a1 => [[p1]] + assertTrue(ConceptTransformation.getForallContexts(d3).toString().equals("[[p1]]")); + // p2 hasValue i1 => [] + assertTrue(ConceptTransformation.getForallContexts(d4).isEmpty()); + // ALL p2.ALL p1.a1 => [[p2],[p1,p2]] + assertTrue(ConceptTransformation.getForallContexts(d5).toString().equals("[[p2, p1], [p2]]")); + // ALL p1.p2 hasValue i1 => [[p1]] + assertTrue(ConceptTransformation.getForallContexts(d6).toString().equals("[[p1]]")); + // EXISTS p3.ALL p2.ALL p1.a1 => [[p3,p2],[p3,p2,p1]] + assertTrue(ConceptTransformation.getForallContexts(d7).toString().equals("[[p3, p2, p1], [p3, p2]]")); + // (ALL p1.a1 OR ALL p2.ALL p1.a1) + assertTrue(ConceptTransformation.getForallContexts(d8).toString().equals("[[p2, p1], [p1], [p2]]")); + // ALL p1.(ALL p1.a1 OR ((a1 AND a2) OR ALL p1.a1)) => [[p1],[p1,p1],[p1,p2],[p1,p2,p1]] + assertTrue(ConceptTransformation.getForallContexts(d9).toString().equals("[[p1, p2, p1], [p1, p1], [p1, p2], [p1]]")); + + } } Modified: trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptTransformation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptTransformation.java 2010-08-06 14:16:23 UTC (rev 2248) +++ trunk/src/dl-learner/org/dllearner/utilities/owl/ConceptTransformation.java 2010-08-06 15:01:58 UTC (rev 2249) @@ -606,16 +606,23 @@ Property op = (Property) ((Restriction)description).getRestrictedPropertyExpression(); // object restrictions if(op instanceof ObjectProperty) { - currentContext.add((ObjectProperty)op); - // if we have an all-restriction, we return it; otherwise we only change the context - // and call the method on the child + PropertyContext currentContextCopy = (PropertyContext) currentContext.clone(); + // if we have an all-restriction, we return it; otherwise we call the child + // (if it exists) if(description instanceof ObjectAllRestriction) { + currentContextCopy.add((ObjectProperty)op); +// System.out.println("cc: " + currentContext); TreeSet<PropertyContext> contexts = new TreeSet<PropertyContext>(); - contexts.add(currentContext); - contexts.addAll(getForallContexts(description.getChild(0), currentContext)); + contexts.add(currentContextCopy); + contexts.addAll(getForallContexts(description.getChild(0), currentContextCopy)); return contexts; + // restriction with one child + } else if(description.getChildren().size()>0) { + currentContextCopy.add((ObjectProperty)op); + return getForallContexts(description.getChild(0), currentContextCopy); + // restrictions without a child (has value) } else { - return getForallContexts(description.getChild(0), currentContext); + return new TreeSet<PropertyContext>(); } // we have a data restriction => no \forall can occur in those } else { @@ -625,6 +632,7 @@ } else { TreeSet<PropertyContext> contexts = new TreeSet<PropertyContext>(); for(Description child : description.getChildren()) { +// System.out.println("testing child " + child + " " + currentContext); contexts.addAll(getForallContexts(child, currentContext)); } return contexts; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2010-08-11 09:13:04
|
Revision: 2256 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2256&view=rev Author: jenslehmann Date: 2010-08-11 09:12:58 +0000 (Wed, 11 Aug 2010) Log Message: ----------- script to show how an axiom can be temporarily added to the OWL API reasoner and reasoner requests performed Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/scripts/OWLAPIReasonerIncremental.java Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2010-08-07 09:28:30 UTC (rev 2255) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2010-08-11 09:12:58 UTC (rev 2256) @@ -143,6 +143,7 @@ private OWLReasoner reasoner; private OWLOntologyManager manager; + private OWLOntology ontology; // the data factory is used to generate OWL API objects private OWLDataFactory factory; @@ -1086,4 +1087,28 @@ return definitions; } + /** + * Gets the OWL API ontology manager. Use with great caution. + * @return The OWL API ontology manager. + */ + public OWLOntologyManager getManager() { + return manager; + } + + /** + * Gets the internal OWL API ontology. Use with great caution. + * @return The internal OWL API ontology. + */ + public OWLOntology getOntology() { + return ontology; + } + + /** + * Gets the internal OWL API reasoner. Use with great caution. + * @return The internal OWL API reasoner. + */ + public OWLReasoner getReasoner() { + return reasoner; + } + } Added: trunk/src/dl-learner/org/dllearner/scripts/OWLAPIReasonerIncremental.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/OWLAPIReasonerIncremental.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/scripts/OWLAPIReasonerIncremental.java 2010-08-11 09:12:58 UTC (rev 2256) @@ -0,0 +1,116 @@ +/** + * Copyright (C) 2007-2010, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.scripts; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Set; +import java.util.TreeSet; + +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.configurators.OWLFileConfigurator; +import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.EquivalentClassesAxiom; +import org.dllearner.core.owl.Intersection; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.ObjectProperty; +import org.dllearner.core.owl.ObjectSomeRestriction; +import org.dllearner.reasoning.OWLAPIReasoner; +import org.dllearner.utilities.Helper; +import org.dllearner.utilities.owl.OWLAPIAxiomConvertVisitor; +import org.dllearner.utilities.owl.OWLAPIDescriptionConvertVisitor; +import org.semanticweb.owlapi.model.AddAxiom; +import org.semanticweb.owlapi.model.OWLAxiom; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLClassExpression; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.model.RemoveAxiom; +import org.semanticweb.owlapi.reasoner.OWLReasoner; + +/** + * + * Test script for incremental reasoning using the OWLAPIReasoner. + * Use with caution as reasoner components were designed for reasoning + * against a static knowledge base. + * + * @author Jens Lehmann + * + */ +public class OWLAPIReasonerIncremental { + + public static void main(String[] args) throws MalformedURLException, ComponentInitException { + // some random OWL file + String url = "http://morpheus.cs.umbc.edu/aks1/ontosem.owl"; + // create reasoner + ComponentManager cm = ComponentManager.getInstance(); + KnowledgeSource ks = OWLFileConfigurator.getOWLFile(new URL(url)); + OWLAPIReasoner reasoner = cm.reasoner(OWLAPIReasoner.class, ks); + ks.init(); + reasoner.init(); + System.out.println("Loaded ontology " + url + "."); + + // create a definition + NamedClass nc1 = new NamedClass("http://morpheus.cs.umbc.edu/aks1/ontosem.owl#christianity"); + NamedClass nc2 = new NamedClass("http://morpheus.cs.umbc.edu/aks1/ontosem.owl#priest"); + NamedClass newNC = new NamedClass("http://nke.aksw.org/new"); + ObjectProperty op1 = new ObjectProperty("http://morpheus.cs.umbc.edu/aks1/ontosem.owl#operated-by"); + Description d1 = new ObjectSomeRestriction(op1, nc2); + Description d2 = new Intersection(nc1, d1); + EquivalentClassesAxiom eq = new EquivalentClassesAxiom(newNC,d2); + + System.out.println("Adding " + eq + "."); + long startTime = System.nanoTime(); + OWLOntologyManager manager = reasoner.getManager(); + OWLOntology ontology = reasoner.getOntology(); + OWLReasoner internalReasoner = reasoner.getReasoner(); + OWLAxiom axiomOWLAPI = OWLAPIAxiomConvertVisitor.convertAxiom(eq); + manager.applyChange(new AddAxiom(ontology, axiomOWLAPI)); + // perform reasoning using OWL API + boolean consistent = internalReasoner.isConsistent(); + OWLClassExpression newNCO = OWLAPIDescriptionConvertVisitor.getOWLClassExpression(newNC); + Set<OWLClass> superClasses = internalReasoner.getSuperClasses(newNCO, true).getFlattened(); + Set<OWLClass> subClasses = internalReasoner.getSubClasses(newNCO, true).getFlattened(); + Set<OWLClass> parallelClasses = new TreeSet<OWLClass>(); + for(OWLClass clazz : superClasses) { + parallelClasses.addAll(internalReasoner.getSubClasses(clazz, true).getFlattened()); + } + parallelClasses.remove(newNCO); + // remove axiom again (otherwise internal DL-Learner state would be corrupt!) + manager.applyChange(new RemoveAxiom(ontology, axiomOWLAPI)); + String timeStr = Helper.prettyPrintNanoSeconds(System.nanoTime()-startTime); + + if(!consistent) { + System.out.println("Adding the axiom renders the ontology inconsistent."); + } else { + System.out.println("\nSuper classes of " + newNC + ":"); + System.out.println(superClasses); + System.out.println("\nSub classes of " + newNC + ":"); + System.out.println(subClasses); + System.out.println("\nParallel classes of " + newNC + ":"); + System.out.println(parallelClasses); + System.out.println("\nReasoning time: " + timeStr); + } + + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |