/* * $Id$ * * Copyright (C) INRIA, 2011 * * Modifications to the initial code base are copyright of their * respective authors, or their employers as appropriate. Authorship * of the modifications may be determined from the ChangeLog placed at * the end of this file. * * 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. */ package org.ontologymatching.book; // Alignment API classes import org.semanticweb.owl.align.Cell; import org.semanticweb.owl.align.Alignment; import org.semanticweb.owl.align.AlignmentException; import org.semanticweb.owl.align.AlignmentProcess; // Alignment API implementation classes import fr.inrialpes.exmo.align.impl.ObjectAlignment; // Java standard classes import java.util.Properties; /** * ComposedAlignment * * Solves the C.10 exercise of the book by assembling matchers. * In fact, most of it has been done, it is only necessary to * - run AggregateAlignment on the ontologies * - extract an alignment from this * The second is achieved by using ExtractAlignment however, this * is in fact not necessary because, ExtractAlignment is a simple * subclass of DistanceAlignment, that AggregateAlignment is too. */ public class ComposedAlignment extends ObjectAlignment implements AlignmentProcess { AggregateAlignment matcher = null; ExtractAlignment extractor = null; /** Creation **/ public ComposedAlignment() { matcher = new AggregateAlignment(); extractor = new ExtractAlignment(); setType("**"); } public void init( Object onto1, Object onto2 ) throws AlignmentException { super.init( onto1, onto2 ); matcher.init( this.onto1, this.onto2 ); extractor.init( this.onto1, this.onto2 ); } /** Processing */ public void align( Alignment alignment, Properties params ) throws AlignmentException { // Call AggregateAlignment matcher.align( alignment, params ); // Call ExtractAlignment... that only do extraction from matcher extractor.align( matcher, params ); // Extract alignment for ( Cell c : extractor ) { // copy the cell... addCell( c ); } } }