From: <jen...@us...> - 2013-09-03 16:09:31
|
Revision: 4039 http://sourceforge.net/p/dl-learner/code/4039 Author: jenslehmann Date: 2013-09-03 16:09:27 +0000 (Tue, 03 Sep 2013) Log Message: ----------- implemented random WSD as baseline method Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SemanticAnnotation.java Added Paths: ----------- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/RandomWordSenseDisambiguation.java Added: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/RandomWordSenseDisambiguation.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/RandomWordSenseDisambiguation.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/RandomWordSenseDisambiguation.java 2013-09-03 16:09:27 UTC (rev 4039) @@ -0,0 +1,59 @@ +/** + * Copyright (C) 2007-2013, 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.Random; +import java.util.Set; + +import org.dllearner.algorithms.isle.index.Annotation; +import org.dllearner.algorithms.isle.index.SemanticAnnotation; +import org.dllearner.core.owl.Entity; +import org.semanticweb.owlapi.model.OWLOntology; + +/** + * Disambiguation by randomly selecting one of the candidates (baseline method). + * + * @author Jens Lehmann + * + */ +public class RandomWordSenseDisambiguation extends WordSenseDisambiguation { + + private Random random; + + public RandomWordSenseDisambiguation(OWLOntology ontology) { + super(ontology); + random = new Random(); + } + + @Override + public SemanticAnnotation disambiguate(Annotation annotation, + Set<Entity> candidateEntities) { + int pos = random.nextInt(candidateEntities.size()); + int i = 0; + for(Entity e : candidateEntities) + { + if (i == pos) { + return new SemanticAnnotation(annotation, e); + } + i++; + } + return null; + } + +} Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SemanticAnnotation.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SemanticAnnotation.java 2013-09-03 15:55:04 UTC (rev 4038) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/SemanticAnnotation.java 2013-09-03 16:09:27 UTC (rev 4039) @@ -13,6 +13,11 @@ private Entity entity; + public SemanticAnnotation(Annotation annotation, Entity entity) { + super(annotation.getGetReferencedDocument(), annotation.getOffset(), annotation.getLength()); + this.entity = entity; + } + public SemanticAnnotation(Document getReferencedDocument, Entity entity, int offset, int length) { super(getReferencedDocument, offset, length); this.entity = entity; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |