From 4b689a74e3088cdc58efcc7b37bf9bc6486bfdef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Euzenat?= <Jerome.Euzenat@inria.fr> Date: Tue, 18 Aug 2009 20:29:21 +0000 Subject: [PATCH] - add dropAlignments --- .../align/util/OntologyNetworkWeakener.java | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/fr/inrialpes/exmo/align/util/OntologyNetworkWeakener.java b/src/fr/inrialpes/exmo/align/util/OntologyNetworkWeakener.java index 80e0d275..ca809d3d 100644 --- a/src/fr/inrialpes/exmo/align/util/OntologyNetworkWeakener.java +++ b/src/fr/inrialpes/exmo/align/util/OntologyNetworkWeakener.java @@ -55,7 +55,7 @@ public class OntologyNetworkWeakener { * suppress n% of the correspondences at random in all 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 of by suppressing the n% of lower confidence + * 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 { if ( n < 0. || n > 1. ) @@ -95,4 +95,26 @@ public class OntologyNetworkWeakener { } 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 { + 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 ); + } + Set<Alignment> alignments = on.getAlignments(); + int size = alignments.size(); + ArrayList<Alignment> array = new ArrayList<Alignment>( size ); + Collections.shuffle( array ); + for ( int i = size - (int)(n*size); i > 0; i-- ) { + on.addAlignment( array.get( i ) ); + } + return newon; + } } -- GitLab