Mentions légales du service

Skip to content
Snippets Groups Projects
Commit bc952b77 authored by Jérôme Euzenat's avatar Jérôme Euzenat
Browse files

- reengineered OntologyNetworkWeakener as an interface

- added OntologyNetworkGenerator
- added new weakeners
parent dd342943
No related branches found
No related tags found
No related merge requests found
...@@ -38,6 +38,7 @@ IDDN.FR. 001.050019 .000.S.P.2 011.000.2090 0 ...@@ -38,6 +38,7 @@ IDDN.FR. 001.050019 .000.S.P.2 011.000.2090 0
storage layer and the web service profile for the Alignment Server</dd> storage layer and the web service profile for the Alignment Server</dd>
<dt><a href="http://www.eurecom.fr/~troncy/">Raphaël Troncy</a></dt><dd>fixed the basic <dt><a href="http://www.eurecom.fr/~troncy/">Raphaël Troncy</a></dt><dd>fixed the basic
implementation of BasicAlignment for n:m alignments.</dd> implementation of BasicAlignment for n:m alignments.</dd>
<dt>Maria Rosoiu</dt><dd>developed the generator interface (gen).</dd>
<dt>Arun Sharma</dt><dd>Developed the query interface</dd> <dt>Arun Sharma</dt><dd>Developed the query interface</dd>
<dt><a href="http://www.scharffe.fr/">François Scharffe</a></dt><dd>developed the initial version of EDOAL</dd> <dt><a href="http://www.scharffe.fr/">François Scharffe</a></dt><dd>developed the initial version of EDOAL</dd>
<dt><a href="http://web.comlab.ox.ac.uk/isg/people/giorgos.stoilos/">Giorgos <dt><a href="http://web.comlab.ox.ac.uk/isg/people/giorgos.stoilos/">Giorgos
......
...@@ -52,26 +52,33 @@ The development of 4 versions continues. ...@@ -52,26 +52,33 @@ The development of 4 versions continues.
<li>Render alignments as module descriptions (impl)</li> <li>Render alignments as module descriptions (impl)</li>
<li>Implement extensive evaluation framework (impl)</li> <li>Implement extensive evaluation framework (impl)</li>
<li>Implement debug options with log4j</li> <li>Implement debug options with log4j</li>
<li>Matcher plugin for OpenII? (util)</li>
<li>Add more tests</li> <li>Add more tests</li>
</ul></p> </ul></p>
<h2>Current SVN trunk version</h2> <h2>Current SVN trunk version</h2>
<!--h2>Version 4.3 (): xx/xx/xxxx - Zimt</h2--> <!--h2>Version 4.3 (): xx/xx/xxxx - Zimt</h2-->
<!--h2>Version 4.2 (): xx/05/2011 - Tring</h2--> <!--h2>Version 4.2 (16xx): 29/05/2011 - Tring</h2-->
<p><ul compact="1"> <p><ul compact="1">
<li>Added minimal API implementation for embedded devices (android)</li>
<li>Added type checking to EDOAL parser (parser)</li> <li>Added type checking to EDOAL parser (parser)</li>
<li>Added <tt>WeightedPRecEvaluator</tt> weighting confidences (eval)</li> <li>Added <tt>WeightedPRecEvaluator</tt> weighting confidences (eval)</li>
<li>Added <tt>toURIAlignment</tt> and <tt>toEDOALAlignment</tt> for <tt>EDOALAlignment</tt> (edoal)</li> <li>Added <tt>toURIAlignment</tt> and <tt>toEDOALAlignment</tt> for <tt>EDOALAlignment</tt> (edoal)</li>
<li>Added matching test generator facility (gen)</li> <li>Added matching test generator facility (gen)</li>
<li>Added autoselecting <tt>BasicOntology.load()</tt> (ontowrap)</li> <li>Added autoselecting <tt>BasicOntology.load()</tt> (ontowrap)</li>
<li>Reengineered <tt>OntologyNetworkWeakener</tt> and added further weakening methods (gen)</li>
<!--li>Added <tt>SEALSAlignment</tt> for SEALS evaluation (impl)</li-->
<li>Added a few statistical primitives to BasicAlignment (impl)</li>
<li>Suppressed <tt>EDOALRelation</tt>: EDOAL uses <tt>BasicRelation</tt> (edoal)</li> <li>Suppressed <tt>EDOALRelation</tt>: EDOAL uses <tt>BasicRelation</tt> (edoal)</li>
<li>EDOAL default printout now uses pretty relations, i.e., &lt;, &gt;, =, % (edoal)</li> <li>EDOAL default printout now uses pretty relations, i.e., &lt;, &gt;, =, % (edoal)</li>
<li>Modified server answers so that namespaces are well placed in REST (server)</li>
<li>Changed order of display to precision/F-measure/recall (util)</li> <li>Changed order of display to precision/F-measure/recall (util)</li>
<li><span style="color: red;">Suppressed</span> incorrect computation of fallout (eval)</li> <li><span style="color: red;">Suppressed</span> incorrect computation of fallout (eval)</li>
<li>Upgraded to <span style="color: green">OntoSim 2.1??</span> (lib)</li> <li>Upgraded to <span style="color: green">OntoSim 2.1??</span> (lib)</li>
<li>Minor display changes in HTML display (server)</li> <li>Minor display changes in HTML display (server)</li>
<li>Suppressed <tt>PreAlignment</tt> (impl)</li>
</ul></p> </ul></p>
<h2>Version 4.1 (1534): 13/10/2010 - Napjakmandu</h2> <h2>Version 4.1 (1534): 13/10/2010 - Napjakmandu</h2>
......
/*
* $Id$
*
* Copyright (C) INRIA, 2009-2011
*
* 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.gen;
import org.semanticweb.owl.align.Alignment;
import org.semanticweb.owl.align.AlignmentException;
import org.semanticweb.owl.align.Cell;
import org.semanticweb.owl.align.OntologyNetwork;
import fr.inrialpes.exmo.align.impl.BasicOntologyNetwork;
import java.net.URI;
import java.util.Properties;
import java.util.Set;
import java.util.Collections;
import java.util.ArrayList;
/**
* NetworkAlignmentDropper
*
* randomly drops n% of all alignments
* n is a number between 0. and 1.
* Returns a brand new BasicOntologyNetwork (with the initial alignments)
*/
public class NetworkAlignmentDropper implements OntologyNetworkWeakener {
public OntologyNetwork weaken( OntologyNetwork on, double n, Properties p ) throws AlignmentException {
//System.err.println( " >>>> "+n );
if ( on == null ) throw new AlignmentException( "cannot weaken null ontology network" );
if ( n < 0. || n > 1. )
throw new AlignmentException( "Argument must be between 0 and 1.: "+n );
return weaken( on, (int)(n*(double)on.getAlignments().size()), p );
}
public OntologyNetwork weaken( OntologyNetwork on, int n, Properties p ) throws AlignmentException {
//System.err.println( " >>>> "+n );
if ( on == null ) throw new AlignmentException( "cannot weaken null ontology network" );
if ( n < 0 )
throw new AlignmentException( "Argument must be a positive integer: "+n );
OntologyNetwork newon = new BasicOntologyNetwork();
for ( URI ontouri : on.getOntologies() ){
newon.addOntology( ontouri );
}
Set<Alignment> alignments = on.getAlignments();
int size = alignments.size();
if ( n > size ) return newon;
ArrayList<Alignment> array = new ArrayList<Alignment>( size );
for ( Alignment al : alignments ){
array.add( al );
}
Collections.shuffle( array );
for ( int i = size - n -1; i >= 0; i-- ) {
newon.addAlignment( array.get( i ) );
}
return newon;
}
}
/*
* $Id$
*
* Copyright (C) INRIA, 2009-2011
*
* 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.gen;
import org.semanticweb.owl.align.Alignment;
import org.semanticweb.owl.align.AlignmentException;
import org.semanticweb.owl.align.Cell;
import org.semanticweb.owl.align.OntologyNetwork;
import fr.inrialpes.exmo.align.impl.BasicOntologyNetwork;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Properties;
import java.net.URI;
/**
* AlignmentWeakener
*
* suppress n% of the correspondences at random in each alignments
* n is a number between 0. and 1.
* Returns a brand new BasicOntologyNetwork (with new alignments and cells)
* the @threshold parameter tells if the corrrespondences are suppressed at random (false) of by suppressing the n% of lower confidence (true)
*/
public class NetworkAlignmentWeakener implements OntologyNetworkWeakener {
public OntologyNetwork weaken( OntologyNetwork on, int n, Properties p ) throws AlignmentException {
throw new AlignmentException( "Cannot weaken alignments by fixed number of correspondences" );
}
public OntologyNetwork weaken( OntologyNetwork on, double n, Properties p ) throws AlignmentException {
if ( on == null ) throw new AlignmentException( "cannot weaken null ontology network" );
if ( n < 0. || n > 1. )
throw new AlignmentException( "Argument must be between 0 and 1.: "+n );
boolean threshold = (p != null && p.getProperty("threshold") != null);
OntologyNetwork newon = new BasicOntologyNetwork();
for ( URI ontouri : on.getOntologies() ){
newon.addOntology( ontouri );
}
for ( Alignment al : on.getAlignments() ){
Alignment newal = (Alignment)al.clone();
if ( threshold ) {
newal.cut( "perc", 1.-n );
} else {
int size = newal.nbCells();
// --------------------------------------------------------------------
// JE: Here is a tricky one.
// Using collection schuffle randomly reorganises a list
// Then choosing the fist n% and destroying them in the Set is performed
// The complexity is O(copy=N)+O(shuffle=N)+n%*O(delete=N)
// That's not bad... (and also avoid checking if the same nb is drawn)
// But in practice other solutions may be better, like:
// Generating randomly n%*N numbers between 0 and N (util.Random)
// Ordering them
// Traversing the initial structure and deleting the choosen ones...
// This one (deleting when traversing) is tricky in Java.
// --------------------------------------------------------------------
ArrayList<Cell> array = new ArrayList<Cell>( size );
for ( Cell c : newal ) {
array.add( c );
}
Collections.shuffle( array );
for ( int i = (int)(n*size)-1; i >= 0; i-- ){
newal.remCell( array.get( i ) );
}
}
newon.addAlignment( newal );
}
return newon;
}
}
/*
* $Id$
*
* Copyright (C) INRIA, 2009-2011
*
* 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.gen;
import org.semanticweb.owl.align.Alignment;
import org.semanticweb.owl.align.AlignmentException;
import org.semanticweb.owl.align.Cell;
import org.semanticweb.owl.align.OntologyNetwork;
import fr.inrialpes.exmo.align.impl.BasicOntologyNetwork;
import java.net.URI;
import java.util.Collections;
import java.util.Collection;
import java.util.TreeSet;
import java.util.ArrayList;
import java.util.Properties;
/**
* NetworkCorrespondenceDropper
*
* suppress n% of the correspondences at random in all alignments (globally)
* n is a number between 0. and 1.
* Returns a brand new BasicOntologyNetwork (with new alignments and cells)
* the @threshold parameter tells if the corrrespondences are suppressed at random (false) of by suppressing the n% of lower confidence (true)
*/
public class NetworkCorrespondenceDropper implements OntologyNetworkWeakener {
public OntologyNetwork weaken( OntologyNetwork on, int n, Properties p ) throws AlignmentException {
throw new AlignmentException( "Cannot weaken alignments by fixed number of correspondences" );
}
public OntologyNetwork weaken( OntologyNetwork on, double n, Properties p ) throws AlignmentException {
if ( on == null ) throw new AlignmentException( "cannot weaken null ontology network" );
if ( n < 0. || n > 1. )
throw new AlignmentException( "Argument must be between 0 and 1.: "+n );
boolean threshold = (p != null && p.getProperty("threshold") != null);
OntologyNetwork newon = new BasicOntologyNetwork();
for ( URI ontouri : on.getOntologies() ){
newon.addOntology( ontouri );
}
// Put all the cell/alignment in a array
Collection<LCell> corresp = null;
if ( threshold ) {
corresp = new TreeSet<LCell>();
} else {
corresp = new ArrayList<LCell>();
}
for ( Alignment al : on.getAlignments() ) {
Alignment newal = (Alignment)al.clone();
for ( Cell c : newal ) {
corresp.add( new LCell( c, newal ) );
}
newon.addAlignment( newal );
}
// Select these correspondences to delete: either shuffle or order
//System.err.println( n+" * "+corresp.size()+" = "+n*(double)(corresp.size()) );
int q = (int)(n*(double)(corresp.size()));
if ( !threshold ) Collections.shuffle( (ArrayList)corresp );
// Suppress the n*size() last ones or those which are under threshold
for ( LCell c : corresp ) {
if ( q == 0 ) break;
q--;
//System.err.println( "Cell ["+c.getCell().getStrength()+"] : "+c );
c.getAlignment().remCell( c.getCell() );
}
// Cut
return newon;
}
}
class LCell implements Comparable<LCell> {
Alignment alignment = null;
Cell cell = null;
LCell( Cell c, Alignment al ) {
alignment = al;
cell = c;
}
/**
* This is not the standard required definition of compareTo
* But this is the one which works exactly here (we want the structure ordered,
* we do not want that two cells be equated (in case of 0)
*/
public int compareTo( LCell c ) {
if ( cell.getStrength() > c.getCell().getStrength() ) return 1;
else return -1;/*if ( cell.getStrength() < c.getCell().getStrength() ) return -1;
else return 0;*/
}
Alignment getAlignment() { return alignment; }
Cell getCell() { return cell; }
}
/*
* $Id$
*
* Copyright (C) INRIA, 2009-2011
*
* 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.gen;
import org.semanticweb.owl.align.Alignment;
import org.semanticweb.owl.align.AlignmentException;
import org.semanticweb.owl.align.Cell;
import org.semanticweb.owl.align.OntologyNetwork;
import fr.inrialpes.exmo.align.impl.BasicOntologyNetwork;
import java.util.Properties;
/**
* NetworkDeconnector
*
* suppress alignments in the ontology network so that it retain n-connectivity,
* i.e., any pairs of ontologies connected by less than n alignments
* are still connected through at most n alignments.
* JE: this is an interesting graph theoretic problem and I do not know where
* to find it.
*
* NOT IMPLEMENTED
*/
public class NetworkDeconnector implements OntologyNetworkWeakener {
public OntologyNetwork weaken( OntologyNetwork on, int n, Properties p ) throws AlignmentException {
if ( on == null ) throw new AlignmentException( "cannot weaken null ontology network" );
return on;
}
public OntologyNetwork weaken( OntologyNetwork on, double n, Properties p ) throws AlignmentException {
if ( on == null ) throw new AlignmentException( "cannot weaken null ontology network" );
if ( n < 0. || n > 1. )
throw new AlignmentException( "Argument must be between 0 and 1.: "+n );
return on;
}
}
/*
* $Id$
*
* Copyright (C) INRIA, 2011
*
* 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.gen;
import org.semanticweb.owl.align.OntologyNetwork;
import fr.inrialpes.exmo.ontowrap.Ontology;
import java.util.Properties;
/**
* OntologyNetworkGenerator
*
* An interface for generating an ontology network from an ontology or an ontology generator.
*
*/
public interface OntologyNetworkGenerator {
/**
* Returns an ontology network of size n (the number of ontologies)
* starting from an ontology o.
* Parameters may further specify the requirements.
*/
public OntologyNetwork generate( int n, Ontology o, Properties params );
/**
* Returns an ontology network of size n (the number of ontologies)
* with ontologies generated by the generator g.
* Parameters may further specify the requirements.
*/
//public OntologyNetwork generate( int n, OntologyGenerator o, Properties params );
}
...@@ -21,113 +21,29 @@ ...@@ -21,113 +21,29 @@
package fr.inrialpes.exmo.align.gen; package fr.inrialpes.exmo.align.gen;
import org.semanticweb.owl.align.Alignment;
import org.semanticweb.owl.align.AlignmentException; import org.semanticweb.owl.align.AlignmentException;
import org.semanticweb.owl.align.Cell;
import org.semanticweb.owl.align.OntologyNetwork; import org.semanticweb.owl.align.OntologyNetwork;
import fr.inrialpes.exmo.align.impl.BasicOntologyNetwork; import java.util.Properties;
import java.net.URI;
import java.util.Set;
import java.util.Collections;
import java.util.ArrayList;
/** /**
* OntologyNetworkWeakener * OntologyNetworkWeakener
* *
* A class which alters ontology networks, usually by altering alignments * A interface which alters ontology networks.
* NOTE: These two primitives would benefit from the hability to declare static in ineterfaces...
* Now we have to create instances of the implementing classes.
*
*/ */
public class OntologyNetworkWeakener { public interface OntologyNetworkWeakener {
/** /**
* suppress alignments in the ontology network so that it retain n-connectivity, * Weakens the ontology network of n units
* i.e., any pairs of ontologies connected by less than n alignments
* are still connected through at most n alignments.
* JE: this is an interesting graph theoretic problem and I do not know where
* to find it.
*/ */
public static OntologyNetwork unconnect( OntologyNetwork on, int n ){ public OntologyNetwork weaken( OntologyNetwork on, int n, Properties p ) throws AlignmentException;
return on;
}
/** /**
* suppress n% of the correspondences at random in all alignments * Weakens the ontology network of n%
* n is a number between 0. and 1.
* Returns a brand new BasicOntologyNetwork (with new alignments and cells)
* the @threshold parameter tells if the corrrespondences are suppressed at random (false) of by suppressing the n% of lower confidence (true)
*/ */
public static OntologyNetwork weakenAlignments( OntologyNetwork on, double n, boolean threshold ) throws AlignmentException { public OntologyNetwork weaken( OntologyNetwork on, double n, Properties p ) throws AlignmentException;
if ( n < 0. || n > 1. )
throw new AlignmentException( "Argument must be between 0 and 1.: "+n );
OntologyNetwork newon = new BasicOntologyNetwork();
for ( URI ontouri : on.getOntologies() ){
newon.addOntology( ontouri );
}
for ( Alignment al : on.getAlignments() ){
Alignment newal = (Alignment)al.clone();
if ( threshold ) {
newal.cut( "perc", 1.-n );
} else {
int size = newal.nbCells();
// --------------------------------------------------------------------
// JE: Here is a tricky one.
// Using collection schuffle randomly reorganises a list
// Then choosing the fist n% and destroying them in the Set is performed
// The complexity is O(copy=N)+O(shuffle=N)+n%*O(delete=N)
// That's not bad... (and also avoid checking if the same nb is drawn)
// But in practice other solutions may be better, like:
// Generating randomly n%*N numbers between 0 and N (util.Random)
// Ordering them
// Traversing the initial structure and deleting the choosen ones...
// This one (deleting when traversing) is tricky in Java.
// --------------------------------------------------------------------
ArrayList<Cell> array = new ArrayList<Cell>( size );
for ( Cell c : newal ) {
array.add( c );
}
Collections.shuffle( array );
for ( int i = (int)(n*size)-1; i >= 0; i-- ){
newal.remCell( array.get( i ) );
}
}
newon.addAlignment( newal );
}
return newon;
}
/**
* randomly drops n% of all alignments
* n is a number between 0. and 1.
* Returns a brand new BasicOntologyNetwork (with the initial alignments)
*/
public static OntologyNetwork dropAlignments( OntologyNetwork on, double n ) throws AlignmentException {
//System.err.println( " >>>> "+n );
if ( n < 0. || n > 1. )
throw new AlignmentException( "Argument must be between 0 and 1.: "+n );
return dropAlignments( on, (int)(n*on.getAlignments().size()) );
}
public static OntologyNetwork dropAlignments( OntologyNetwork on, int n ) throws AlignmentException {
//System.err.println( " >>>> "+n );
if ( n < 0 || n > on.getAlignments().size() )
throw new AlignmentException( "Argument must be a positive integer: "+n );
OntologyNetwork newon = new BasicOntologyNetwork();
for ( URI ontouri : on.getOntologies() ){
newon.addOntology( ontouri );
}
Set<Alignment> alignments = on.getAlignments();
int size = alignments.size();
ArrayList<Alignment> array = new ArrayList<Alignment>( size );
for ( Alignment al : alignments ){
array.add( al );
}
Collections.shuffle( array );
for ( int i = size - (int)(n*size); i > 0; i-- ) {
newon.addAlignment( array.get( i ) );
}
return newon;
}
} }
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment