From: <lor...@us...> - 2013-07-12 09:03:25
|
Revision: 4018 http://sourceforge.net/p/dl-learner/code/4018 Author: lorenz_b Date: 2013-07-12 09:03:21 +0000 (Fri, 12 Jul 2013) Log Message: ----------- Cont. ISLE. Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/OWLOntologyLuceneIndex.java trunk/components-core/src/main/java/org/dllearner/core/owl/Entity.java trunk/components-core/src/test/java/org/dllearner/algorithms/isle/ISLETest.java Added Paths: ----------- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/AnnotationEntityTextRetriever.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/EntityExtraction.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/RDFSCommentEntityTextRetriever.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/RDFSLabelEntityTextRetriever.java Removed Paths: ------------- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/LabelEntityTextRetriever.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/PMIRelevance.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/PMIRelevances.java Added: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/AnnotationEntityTextRetriever.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/AnnotationEntityTextRetriever.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/AnnotationEntityTextRetriever.java 2013-07-12 09:03:21 UTC (rev 4018) @@ -0,0 +1,93 @@ +/** + * + */ +package org.dllearner.algorithms.isle; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.dllearner.core.owl.Entity; +import org.dllearner.kb.OWLAPIOntology; +import org.dllearner.utilities.owl.OWLAPIConverter; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAnnotation; +import org.semanticweb.owlapi.model.OWLAnnotationProperty; +import org.semanticweb.owlapi.model.OWLEntity; +import org.semanticweb.owlapi.model.OWLLiteral; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.util.IRIShortFormProvider; +import org.semanticweb.owlapi.util.SimpleIRIShortFormProvider; + + +/** + * @author Lorenz Buehmann + * + */ +public class AnnotationEntityTextRetriever implements EntityTextRetriever{ + + private OWLOntology ontology; + private OWLOntologyManager manager; + + private String language = "en"; + private double weight = 1d; + + private boolean useShortFormFallback = true; + private IRIShortFormProvider sfp = new SimpleIRIShortFormProvider(); + + private OWLAnnotationProperty[] properties; + + public AnnotationEntityTextRetriever(OWLOntology ontology, OWLAnnotationProperty... properties) { + this.ontology = ontology; + this.properties = properties; + } + + public AnnotationEntityTextRetriever(OWLAPIOntology ontology, OWLAnnotationProperty... properties) { + this.ontology = ontology.createOWLOntology(manager); + } + + /** + * @param language the language to set + */ + public void setLanguage(String language) { + this.language = language; + } + + /** + * Whether to use the short form of the IRI as fallback, if no label is given. + * @param useShortFormFallback the useShortFormFallback to set + */ + public void setUseShortFormFallback(boolean useShortFormFallback) { + this.useShortFormFallback = useShortFormFallback; + } + + /* (non-Javadoc) + * @see org.dllearner.algorithms.isle.EntityTextRetriever#getRelevantText(org.dllearner.core.owl.Entity) + */ + @Override + public Map<String, Double> getRelevantText(Entity entity) { + Map<String, Double> textWithWeight = new HashMap<String, Double>(); + + OWLEntity e = OWLAPIConverter.getOWLAPIEntity(entity); + + for (OWLAnnotationProperty property : properties) { + Set<OWLAnnotation> annotations = e.getAnnotations(ontology, property); + for (OWLAnnotation annotation : annotations) { + if (annotation.getValue() instanceof OWLLiteral) { + OWLLiteral val = (OWLLiteral) annotation.getValue(); + if (val.hasLang(language)) { + String label = val.getLiteral(); + textWithWeight.put(label, weight); + } + } + } + } + + if(textWithWeight.isEmpty() && useShortFormFallback){ + textWithWeight.put(sfp.getShortForm(IRI.create(entity.getURI())), weight); + } + + return textWithWeight; + } +} Added: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/EntityExtraction.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/EntityExtraction.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/EntityExtraction.java 2013-07-12 09:03:21 UTC (rev 4018) @@ -0,0 +1,28 @@ +/** + * + */ +package org.dllearner.algorithms.isle; + +import java.util.Map; + +import org.dllearner.core.owl.Entity; + +/** + * @author Lorenz Buehmann + * + */ +public interface EntityExtraction { + + /** + * Extracts all entities contained in the working text with some confidence value. + * @return + */ + Map<Entity, Double> extractEntities(); + + /** + * Extracts all entities of the given <code>type</code> contained in the working text with some confidence value. + * @return + */ + Map<Entity, Double> extractEntities(Entity.Type type); + +} Deleted: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/LabelEntityTextRetriever.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/LabelEntityTextRetriever.java 2013-07-11 12:24:23 UTC (rev 4017) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/LabelEntityTextRetriever.java 2013-07-12 09:03:21 UTC (rev 4018) @@ -1,95 +0,0 @@ -/** - * - */ -package org.dllearner.algorithms.isle; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.dllearner.core.owl.Entity; -import org.dllearner.kb.OWLAPIOntology; -import org.dllearner.utilities.owl.OWLAPIConverter; -import org.semanticweb.owlapi.model.IRI; -import org.semanticweb.owlapi.model.OWLAnnotation; -import org.semanticweb.owlapi.model.OWLAnnotationProperty; -import org.semanticweb.owlapi.model.OWLDataFactory; -import org.semanticweb.owlapi.model.OWLEntity; -import org.semanticweb.owlapi.model.OWLLiteral; -import org.semanticweb.owlapi.model.OWLOntology; -import org.semanticweb.owlapi.model.OWLOntologyManager; -import org.semanticweb.owlapi.util.IRIShortFormProvider; -import org.semanticweb.owlapi.util.SimpleIRIShortFormProvider; -import org.semanticweb.owlapi.vocab.OWLRDFVocabulary; - -import uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl; - - -/** - * @author Lorenz Buehmann - * - */ -public class LabelEntityTextRetriever implements EntityTextRetriever{ - - private OWLOntology ontology; - private OWLOntologyManager manager; - private OWLDataFactory df = new OWLDataFactoryImpl(); - - private OWLAnnotationProperty label = df.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI()); - - private String language = "en"; - private double weight = 1d; - - private boolean useShortFormFallback = true; - private IRIShortFormProvider sfp = new SimpleIRIShortFormProvider(); - - public LabelEntityTextRetriever(OWLOntology ontology) { - this.ontology = ontology; - } - - public LabelEntityTextRetriever(OWLAPIOntology ontology) { - this.ontology = ontology.createOWLOntology(manager); - } - - /** - * @param language the language to set - */ - public void setLanguage(String language) { - this.language = language; - } - - /** - * Whether to use the short form of the IRI as fallback, if no label is given. - * @param useShortFormFallback the useShortFormFallback to set - */ - public void setUseShortFormFallback(boolean useShortFormFallback) { - this.useShortFormFallback = useShortFormFallback; - } - - /* (non-Javadoc) - * @see org.dllearner.algorithms.isle.EntityTextRetriever#getRelevantText(org.dllearner.core.owl.Entity) - */ - @Override - public Map<String, Double> getRelevantText(Entity entity) { - Map<String, Double> textWithWeight = new HashMap<String, Double>(); - - OWLEntity e = OWLAPIConverter.getOWLAPIEntity(entity); - - Set<OWLAnnotation> annotations = e.getAnnotations(ontology, label); - for (OWLAnnotation annotation : annotations) { - if (annotation.getValue() instanceof OWLLiteral) { - OWLLiteral val = (OWLLiteral) annotation.getValue(); - if (val.hasLang(language)) { - String label = val.getLiteral(); - textWithWeight.put(label, weight); - } - } - } - - if(textWithWeight.isEmpty() && useShortFormFallback){ - textWithWeight.put(sfp.getShortForm(IRI.create(entity.getURI())), weight); - } - - return textWithWeight; - } -} Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/OWLOntologyLuceneIndex.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/OWLOntologyLuceneIndex.java 2013-07-11 12:24:23 UTC (rev 4017) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/OWLOntologyLuceneIndex.java 2013-07-12 09:03:21 UTC (rev 4018) @@ -32,6 +32,7 @@ import uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl; /** + * Creates a Lucene Index for the labels if classes and properties. * @author Lorenz Buehmann * */ Deleted: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/PMIRelevance.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/PMIRelevance.java 2013-07-11 12:24:23 UTC (rev 4017) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/PMIRelevance.java 2013-07-12 09:03:21 UTC (rev 4018) @@ -1,108 +0,0 @@ -package org.dllearner.algorithms.isle; - - -import java.io.*; -import java.util.*; - -public class PMIRelevance { - - private LuceneSearcher m_searcher = null; - - private Set<String> m_classes; - private Set<String> m_individuals; - - - public static void main( String args[] ) throws Exception { - PMIRelevance relevance = new PMIRelevance( args[0], args[1] ); - relevance.printScores(); - } - - public void printScores() throws Exception { - for( String sInd: m_individuals ) - { - Map<String,Double> hmClass2Score = getClassRelevance( sInd ); - for( String sClass : hmClass2Score.keySet() ) - { - double dScore = hmClass2Score.get( sClass ); - if( dScore > 0 ){ - System.out.println( "PMI( "+ sInd +" , "+ sClass +" ) = "+ dScore ); - } - } - } - /* for( String sClass: m_classes ) - { - Map<String,Double> hmInd2Score = getIndividualRelevance( sClass ); - for( String sInd : hmInd2Score.keySet() ) - { - double dScore = hmInd2Score.get( sInd ); - if( dScore > 0 ){ - System.out.println( "P( "+ sClass +" | "+ sInd +" ) = "+ dScore ); - } - } - } */ - m_searcher.close(); - } - - public PMIRelevance( String sClasses, String sIndividuals ) throws Exception { - m_searcher = new LuceneSearcher(); - m_classes = read( sClasses ); - m_individuals = read( sIndividuals ); - } - - public Map<String,Double> getClassRelevance( String sIndividual ) throws Exception { - // computes relevance of classes for this individual - // conditional probability: P(I|C)=f(I,C)/f(C) - // PMI(I,C)=log( P(I|C) / P(I) ) - Map<String,Double> hmClass2Score = new HashMap<String,Double>(); - int iInd = m_searcher.count( sIndividual ); - int iAll = m_searcher.indexSize(); - double dPInd = (double) iInd / (double) iAll; - for( String sClass: m_classes ) - { - int iClass = m_searcher.count( sClass ); - int iIndClass = m_searcher.count( sIndividual +" AND "+ sClass ); - double dPIndClass = (double) iIndClass / (double)iClass; - double dPMI = Math.log( dPIndClass / dPInd ); - hmClass2Score.put( sClass, dPMI ); - } - return hmClass2Score; - } - - public Map<String,Double> getIndividualRelevance( String sClass ) throws Exception { - // computes relevance of individuals for this class - // conditional probability: P(C|I)=f(C,I)/f(I) - // PMI(C|I)=log( P(C|I) / P(C) ) - Map<String,Double> hmInd2Score = new HashMap<String,Double>(); - int iClass = m_searcher.count( sClass ); - int iAll = m_searcher.indexSize(); - double dPClass = (double) iClass / (double) iAll; - for( String sInd: m_individuals ) - { - int iInd = m_searcher.count( sInd ); - int iIndClass = m_searcher.count( sClass +" AND "+ sInd ); - double dPClassInd = (double) iIndClass / (double)iInd; - double dPMI = Math.log( dPClassInd / dPClass ); - hmInd2Score.put( sInd, dPMI ); - } - return hmInd2Score; - } - - private static Set<String> read( String sFile ) throws Exception { - File file = new File( sFile ); - Set<String> lines = new HashSet<String>(); - BufferedReader reader = null; - try { - reader = new BufferedReader( new FileReader( file ) ); - String sLine = null; - while( ( sLine = reader.readLine() ) != null ) { - lines.add( sLine.trim() ); - } - } - finally { - if( reader != null ) { - reader.close(); - } - } - return lines; - } -} \ No newline at end of file Deleted: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/PMIRelevances.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/PMIRelevances.java 2013-07-11 12:24:23 UTC (rev 4017) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/PMIRelevances.java 2013-07-12 09:03:21 UTC (rev 4018) @@ -1,165 +0,0 @@ -/** - * Copyright (C) 2007-2011, 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.algorithms.isle; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.semanticweb.owlapi.apibinding.OWLManager; -import org.semanticweb.owlapi.model.IRI; -import org.semanticweb.owlapi.model.OWLClass; -import org.semanticweb.owlapi.model.OWLEntity; -import org.semanticweb.owlapi.model.OWLNamedObject; -import org.semanticweb.owlapi.model.OWLOntology; -import org.semanticweb.owlapi.model.OWLOntologyManager; - - -public class PMIRelevances { - - private LuceneSearcher m_searcher = null; - - private OWLOntologyManager m_manager; - private OWLOntology m_ontology; - - private Set<OWLEntity> m_entities; - private Set<OWLClass> m_classes; - - - public static void main( String args[] ) throws Exception { - PMIRelevances relevances = new PMIRelevances( args[0] ); - relevances.printScores(); - } - - public void printScores() throws Exception { - for( OWLClass c: m_classes ) - { - Map<OWLEntity,Double> hmEntity2Score = getEntityRelevance(c); - // normalization per class? - hmEntity2Score = normalize( hmEntity2Score ); - for( OWLEntity e : hmEntity2Score.keySet() ) - { - double dScore = hmEntity2Score.get(e); - System.out.println( "P( "+ getLabel(c) +", "+ getLabel(e) +" ) = "+ dScore ); - } - } - m_searcher.close(); - } - - public PMIRelevances( String sOntologyURI ) throws Exception { - m_searcher = new LuceneSearcher(); - loadOntology( sOntologyURI ); - } - - public Map<OWLEntity,Double> normalize( Map<OWLEntity,Double> hmEntity2Score ){ - Map<OWLEntity,Double> hmEntity2Norm = new HashMap<OWLEntity,Double>(); - double dMin = Double.MAX_VALUE; - Double dMax = Double.MIN_VALUE; - for( OWLEntity e : hmEntity2Score.keySet() ) - { - double dValue = hmEntity2Score.get(e); - if( dValue < dMin ){ - dMin = dValue; - } - else if( dValue > dMax ){ - dMax = dValue; - } - } - // System.out.println( "min="+ dMin +" max="+ dMax ); - for( OWLEntity e : hmEntity2Score.keySet() ) - { - double dValue = hmEntity2Score.get(e); - double dNorm = 0; - if( dMin == dMax ){ - dNorm = dValue; - } - else { - dNorm = ( dValue - dMin ) / ( dMax - dMin ); - } - hmEntity2Norm.put( e, dNorm ); - } - return hmEntity2Norm; - } - - public Map<OWLEntity,Double> getEntityRelevance( OWLClass c ) throws Exception { - // computes relevance of entity for this class - // conditional probability: P(C,E)=f(C,E)/f(E) - // PMI(C,E)=log( P(C,E) / P(C) ) - Map<OWLEntity,Double> hmEntity2Score = new HashMap<OWLEntity,Double>(); - String sClass = getLabel(c); - int iClass = m_searcher.count( sClass ); - int iAll = m_searcher.indexSize(); - double dPClass = (double) iClass / (double) iAll; - for( OWLEntity e: m_entities ) - { - 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 dPClassEntity = (double) iEntityClass / (double)iEntity; - double dPMI = Math.log( dPClassEntity / dPClass ); - if( !Double.isNaN( dPMI ) && !Double.isInfinite( dPMI ) ){ - hmEntity2Score.put( e, dPMI ); - } - } - return hmEntity2Score; - } - - /* private String getLabel( OWLEntity e ){ - System.out.println( "getLabel: "+ e ); - OWLDataFactory factory = m_manager.getOWLDataFactory(); - OWLAnnotationProperty label = factory.getOWLAnnotationProperty( OWLRDFVocabulary.RDFS_LABEL.getIRI() ); - Set<OWLAnnotation> anns = e.getAnnotations( m_ontology, label ); - for( OWLAnnotation annotation: anns ) - { - System.out.println( "annotation="+ annotation ); - if( annotation.getValue() instanceof OWLLiteral ) - { - OWLLiteral val = (OWLLiteral) annotation.getValue(); - if( !val.isOWLTypedLiteral() ){ - if (val.asOWLStringLiteral().getLang().equals("en")) { - return val.getLiteral(); - } - } - return val.getLiteral(); - } - } - return null; - } */ - - private String getLabel( OWLEntity e ){ - if( e instanceof OWLNamedObject ){ - String sIRI = ((OWLNamedObject)e).getIRI().toString(); - return sIRI.substring( sIRI.indexOf( "#" )+1 ); - } - return null; - } - - private void loadOntology( String sOntologyURI ) throws Exception { - m_manager = OWLManager.createOWLOntologyManager(); - IRI ontologyIRI = IRI.create( sOntologyURI ); - m_ontology = m_manager.loadOntology( ontologyIRI ); - m_classes = m_ontology.getClassesInSignature(); - m_entities = m_ontology.getSignature(); - System.out.println( "classes="+ m_classes.size() +" entities="+ m_entities.size() ); - // m_manager.removeOntology( ontology ); - } -} \ No newline at end of file Added: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/RDFSCommentEntityTextRetriever.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/RDFSCommentEntityTextRetriever.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/RDFSCommentEntityTextRetriever.java 2013-07-12 09:03:21 UTC (rev 4018) @@ -0,0 +1,26 @@ +/** + * + */ +package org.dllearner.algorithms.isle; + +import org.dllearner.kb.OWLAPIOntology; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.vocab.OWLRDFVocabulary; + +import uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl; + + +/** + * @author Lorenz Buehmann + * + */ +public class RDFSCommentEntityTextRetriever extends AnnotationEntityTextRetriever{ + + public RDFSCommentEntityTextRetriever(OWLOntology ontology) { + super(ontology, new OWLDataFactoryImpl().getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_COMMENT.getIRI())); + } + + public RDFSCommentEntityTextRetriever(OWLAPIOntology ontology) { + super(ontology, new OWLDataFactoryImpl().getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_COMMENT.getIRI())); + } +} Added: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/RDFSLabelEntityTextRetriever.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/RDFSLabelEntityTextRetriever.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/RDFSLabelEntityTextRetriever.java 2013-07-12 09:03:21 UTC (rev 4018) @@ -0,0 +1,26 @@ +/** + * + */ +package org.dllearner.algorithms.isle; + +import org.dllearner.kb.OWLAPIOntology; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.vocab.OWLRDFVocabulary; + +import uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl; + + +/** + * @author Lorenz Buehmann + * + */ +public class RDFSLabelEntityTextRetriever extends AnnotationEntityTextRetriever{ + + public RDFSLabelEntityTextRetriever(OWLOntology ontology) { + super(ontology, new OWLDataFactoryImpl().getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI())); + } + + public RDFSLabelEntityTextRetriever(OWLAPIOntology ontology) { + super(ontology, new OWLDataFactoryImpl().getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI())); + } +} Modified: trunk/components-core/src/main/java/org/dllearner/core/owl/Entity.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/owl/Entity.java 2013-07-11 12:24:23 UTC (rev 4017) +++ trunk/components-core/src/main/java/org/dllearner/core/owl/Entity.java 2013-07-12 09:03:21 UTC (rev 4018) @@ -28,6 +28,10 @@ * */ public interface Entity extends NamedKBElement { + + public enum Type{ + CLASS, OBJECT_PROPERTY, DATA_PROPERTY; + } public URI getURI(); Modified: trunk/components-core/src/test/java/org/dllearner/algorithms/isle/ISLETest.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/algorithms/isle/ISLETest.java 2013-07-11 12:24:23 UTC (rev 4017) +++ trunk/components-core/src/test/java/org/dllearner/algorithms/isle/ISLETest.java 2013-07-12 09:03:21 UTC (rev 4018) @@ -3,15 +3,10 @@ */ package org.dllearner.algorithms.isle; -import static org.junit.Assert.*; - import java.io.File; import java.util.Map; -import java.util.Map.Entry; -import org.dllearner.core.AbstractLearningProblem; import org.dllearner.core.AbstractReasonerComponent; -import org.dllearner.core.ComponentInitException; import org.dllearner.core.KnowledgeSource; import org.dllearner.core.owl.Entity; import org.dllearner.core.owl.NamedClass; @@ -39,21 +34,28 @@ private LuceneSearcher searcher; private Relevance relevance; private String searchField = "label"; - + /** - * @throws java.lang.Exception + * */ - @Before - public void setUp() throws Exception { + public ISLETest() throws Exception{ manager = OWLManager.createOWLOntologyManager(); ontology = manager.loadOntologyFromOntologyDocument(new File("../examples/isle/father_labeled.owl")); cls = new NamedClass("http://example.com/father#father"); - textRetriever = new LabelEntityTextRetriever(ontology); + textRetriever = new RDFSLabelEntityTextRetriever(ontology); OWLOntologyLuceneIndex index = new OWLOntologyLuceneIndex(ontology, searchField); searcher = new LuceneSearcher(index.getDirectory(), searchField); relevance = new PMILuceneBasedRelevance(ontology, searcher, textRetriever); } + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception{ + + } + @Test public void testTextRetrieval() { System.out.println("Text for entity " + cls + ":"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |