/* * $Id$ * * Copyright (C) INRIA, 2010 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** * JE: 05/08/2010 * This is an example for the computations in OMBook. * Exercise C9: AlignmentExtraction * It could implement different extraction strategies * */ package org.ontologymatching.book; import fr.inrialpes.exmo.align.impl.Similarity; import fr.inrialpes.exmo.align.impl.MatrixMeasure; import fr.inrialpes.exmo.align.impl.DistanceAlignment; import fr.inrialpes.exmo.align.impl.method.StringDistAlignment; import fr.inrialpes.exmo.ontowrap.LoadedOntology; import fr.inrialpes.exmo.ontowrap.OntowrapException; import fr.inrialpes.exmo.ontosim.string.StringDistances; import org.semanticweb.owl.align.Alignment; import org.semanticweb.owl.align.AlignmentProcess; import org.semanticweb.owl.align.AlignmentException; import java.util.Properties; /** * OMBook answer to exercise C.9 */ public class ExtractAlignment extends DistanceAlignment implements AlignmentProcess { /** Creation **/ public ExtractAlignment(){ setSimilarity( new MatrixMeasure() { // Never used because no call to compute() public double classMeasure( Object cl1, Object cl2 ) { return 0.; } public double propertyMeasure( Object pr1, Object pr2 ) { return 0.; } public double individualMeasure( Object id1, Object id2 ) { return 0.; } } ); setType("11"); }; /** Processing **/ public void align( Alignment alignment, Properties prop ) throws AlignmentException { loadInit( alignment ); Similarity sim = getSimilarity(); sim.initialize( ontology1(), ontology2(), alignment ); // Print matrix if asked prop.setProperty( "algName", getClass().toString() ); if ( prop.getProperty("printMatrix") != null ) printDistanceMatrix( prop ); // Extract alignment // The type attribute will determine what is extracted... extract( type, prop ); } }