diff --git a/html/relnotes.html b/html/relnotes.html index 0aba8a1358b637714f85f4576ec2909c2edc9fe7..b92ca6540e2ed79df2bed62e82547b0ac696f381 100644 --- a/html/relnotes.html +++ b/html/relnotes.html @@ -68,10 +68,15 @@ with a warning: <!--h2>Version 4.9 (2xxx): ??/??/201X - Letraset</h2--> <!--h2>Version 4.8 (2xxx): ??/??/2015 - Antésine</h2--> +<p>The Alignment API is now compiled in Java 1.8.</p> + <p><ul compact="1"> <li>Added interface <tt>AlignmentRepairer</tt> (api)</tt> <li>Added some more SPARQL renderers (impl)</li> -<li>Added <tt>SPARQLLinkkerRendererVisitor</tt> generating SPARQL from link keys(impl)</li> +<li>Added CSV renderer (impl)</li> +<li>Added <tt>SPARQLLinkkerRendererVisitor</tt> generating SPARQL from link keys (impl)</li> +<li>Added alignment <tt>#version</tt> standard extension (format)</li> +<li>Added banner option to server (server)</li> <li>Fixed a bug in pull aggregation (impl)</li> <li>Improved error reporting (err500) when ontology is unknown (serv)</li> <li>Implemented <tt>AbstractRepairer</tt> (impl)</tt> diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/CSVRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/CSVRendererVisitor.java new file mode 100644 index 0000000000000000000000000000000000000000..58295c8aae053c2645ca765ab2cd000a6a0cd198 --- /dev/null +++ b/src/fr/inrialpes/exmo/align/impl/renderer/CSVRendererVisitor.java @@ -0,0 +1,88 @@ +/* + * $Id$ + * + * Copyright (C) INRIA, 2015 + * + * 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 fr.inrialpes.exmo.align.impl.renderer; + +import java.util.Properties; +import java.io.PrintWriter; +import java.net.URI; + +import org.semanticweb.owl.align.Alignment; +import org.semanticweb.owl.align.AlignmentVisitor; +import org.semanticweb.owl.align.AlignmentException; +import org.semanticweb.owl.align.Cell; +import org.semanticweb.owl.align.Relation; + +import fr.inrialpes.exmo.align.impl.URIAlignment; + +import fr.inrialpes.exmo.ontowrap.LoadedOntology; + +/** + * Renders an alignment in Comma-separated-value or Tab-separated-value + * + * - only works with URIAlignments + * + * @author Jérôme Euzenat + * @version $Id$ + */ + +public class CSVRendererVisitor extends GenericReflectiveVisitor implements AlignmentVisitor { + String sep = ","; + PrintWriter writer = null; + Alignment alignment = null; + Cell cell = null; + + public CSVRendererVisitor( PrintWriter writer ){ + this.writer = writer; + } + + public void init( Properties p ) { + if ( p.getProperty( "separator" ) != null + && !p.getProperty( "separator" ).equals("") ) sep = p.getProperty( "separator" ); + }; + + public void visit( Alignment align ) throws AlignmentException { + if ( subsumedInvocableMethod( this, align, Alignment.class ) ) return; + // default behaviour + alignment = align; + if ( ! (align instanceof URIAlignment) ) { + throw new AlignmentException( "Only URIAlignments can be rendered in CSV" ); + } + writer.print("\"id\""+sep+"\"object1\""+sep+"\"relation\""+sep+"\"strength\""+sep+"\"object2\"\n"); + for( Cell c : align ) { c.accept( this ); } + } + + public void visit( Cell cell ) throws AlignmentException { + if ( subsumedInvocableMethod( this, cell, Cell.class ) ) return; + this.cell = cell; + URI u1 = cell.getObject1AsURI( alignment ); + URI u2 = cell.getObject2AsURI( alignment ); + String id = ""; + if ( cell.getId() != null ) { id = cell.getId(); } + writer.print("\""+id+"\""+sep+"\""+u1+"\""+sep+"\"" ); + cell.getRelation().accept( this ); + writer.print("\""+sep+"\""+cell.getStrength()+"\""+sep+"\""+u2+"\"\n"); + } + + public void visit( Relation rel ) throws AlignmentException { + if ( subsumedInvocableMethod( this, rel, Relation.class ) ) return; + rel.write( writer ); + }; +}