From: <lor...@us...> - 2013-09-03 15:44:29
|
Revision: 4036 http://sourceforge.net/p/dl-learner/code/4036 Author: lorenz_b Date: 2013-09-03 15:44:26 +0000 (Tue, 03 Sep 2013) Log Message: ----------- Added linguistic annotator. Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SemanticAnnotator.java Added Paths: ----------- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/EntityCandidateGenerator.java trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/LinguisticAnnotator.java Added: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/EntityCandidateGenerator.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/EntityCandidateGenerator.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/EntityCandidateGenerator.java 2013-09-03 15:44:26 UTC (rev 4036) @@ -0,0 +1,25 @@ +/** + * + */ +package org.dllearner.algorithms.isle; + +import java.util.Set; + +import org.dllearner.algorithms.isle.index.Annotation; +import org.dllearner.core.owl.Entity; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * @author Lorenz Buehmann + * + */ +public abstract class EntityCandidateGenerator { + + private OWLOntology ontology; + + public EntityCandidateGenerator(OWLOntology ontology) { + this.ontology = ontology; + } + + public abstract Set<Entity> getCandidates(Annotation annotation); +} Added: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/LinguisticAnnotator.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/LinguisticAnnotator.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/LinguisticAnnotator.java 2013-09-03 15:44:26 UTC (rev 4036) @@ -0,0 +1,16 @@ +/** + * + */ +package org.dllearner.algorithms.isle.index; + +import java.util.Set; + +/** + * @author Lorenz Buehmann + * + */ +public interface LinguisticAnnotator { + + Set<Annotation> annotate(Document document); + +} Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SemanticAnnotator.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SemanticAnnotator.java 2013-09-03 15:26:18 UTC (rev 4035) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SemanticAnnotator.java 2013-09-03 15:44:26 UTC (rev 4036) @@ -1,5 +1,11 @@ package org.dllearner.algorithms.isle.index; +import java.util.HashSet; +import java.util.Set; + +import org.dllearner.algorithms.isle.EntityCandidateGenerator; +import org.dllearner.algorithms.isle.WordSenseDisambiguation; +import org.dllearner.core.owl.Entity; import org.semanticweb.owlapi.model.OWLOntology; /** @@ -9,15 +15,23 @@ */ public class SemanticAnnotator { - OWLOntology ontology; + private OWLOntology ontology; + private WordSenseDisambiguation wordSenseDisambiguation; + private EntityCandidateGenerator entityCandidateGenerator; + private LinguisticAnnotator linguisticAnnotator; + /** * Initialize this semantic annotator to use the entities from the provided ontology. * * @param ontology the ontology to use entities from */ - public SemanticAnnotator(OWLOntology ontology) { + public SemanticAnnotator(OWLOntology ontology, WordSenseDisambiguation wordSenseDisambiguation, + EntityCandidateGenerator entityCandidateGenerator, LinguisticAnnotator linguisticAnnotator) { this.ontology = ontology; + this.wordSenseDisambiguation = wordSenseDisambiguation; + this.entityCandidateGenerator = entityCandidateGenerator; + this.linguisticAnnotator = linguisticAnnotator; } /** @@ -26,7 +40,16 @@ * @param document the document to annotate * @return the given document extended with annotations */ - public AnnotatedDocument processDocument(Document document){ - return null; + public AnnotatedDocument processDocument(TextDocument document){ + Set<Annotation> annotations = linguisticAnnotator.annotate(document); + Set<SemanticAnnotation> semanticAnnotations = new HashSet<SemanticAnnotation>(); + for (Annotation annotation : annotations) { + Set<Entity> candidateEntities = entityCandidateGenerator.getCandidates(annotation); + SemanticAnnotation semanticAnnotation = wordSenseDisambiguation.disambiguate(annotation, candidateEntities); + semanticAnnotations.add(semanticAnnotation); + + } + AnnotatedDocument annotatedDocument = new AnnotatedTextDocument(document, semanticAnnotations); + return annotatedDocument; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |