diff --git a/src/fr/inrialpes/exmo/align/impl/eval/PRGraphEvaluator.java b/src/fr/inrialpes/exmo/align/impl/eval/PRGraphEvaluator.java index ee8ffa9cdc1a76aa34304dce3c573a6fc477dbfc..f3224f1ffb52fcaa4c5d2376dd75aaba887b8e43 100644 --- a/src/fr/inrialpes/exmo/align/impl/eval/PRGraphEvaluator.java +++ b/src/fr/inrialpes/exmo/align/impl/eval/PRGraphEvaluator.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA Rhône-Alpes, 2004-2005, 2007-2009 + * Copyright (C) INRIA, 2004-2005, 2007-2009 * * 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 @@ -148,16 +148,15 @@ public class PRGraphEvaluator extends BasicEvaluator { ); // Set the found cells in the sorted structure - for (Enumeration e = align2.getElements(); e.hasMoreElements();) { - cellSet.add( (Cell)e.nextElement() ); + for ( Cell c : align2 ) { + cellSet.add( c ); } // Collect the points that change recall // (the other provide lower precision from the same recall and are not considered) points.add( new Pair( 0., 1. ) ); // [R=0%] - for( Iterator it = cellSet.iterator(); it.hasNext(); ){ + for( Cell c2 : cellSet ){ nbfound++; - Cell c2 = (Cell)it.next(); Set s1 = (Set)align1.getAlignCells1( c2.getObject1() ); if( s1 != null ){ // for all cells matching our first entity for( Iterator it1 = s1.iterator(); it1.hasNext() && c2 != null; ){ diff --git a/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java b/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java index 9336063926a29a47fd7b5e60b70b03731f62c113..829d5914a9288773ed818ccf6a3fb7189794dc24 100644 --- a/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java +++ b/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java @@ -61,6 +61,7 @@ import java.net.JarURLConnection; import java.util.Hashtable; import java.util.Set; import java.util.HashSet; +import java.util.Collection; import java.util.Enumeration; import java.util.Iterator; import java.util.StringTokenizer; @@ -156,9 +157,14 @@ public class AServProtocolManager { return evaluators; } + /* public Enumeration alignments(){ return alignmentCache.listAlignments(); } + */ + public Collection<Alignment> alignments() { + return alignmentCache.alignments(); + } public String query( String query ){ //return alignmentCache.query( query ); @@ -215,7 +221,9 @@ public class AServProtocolManager { Message result = null; Parameters p = mess.getParameters(); // These are added to the parameters wich are in the message - for (Enumeration<String> e = commandLineParams.getNames(); e.hasMoreElements();) { + //for ( String key : commandLineParams ) { + // Unfortunately non iterable + for ( Enumeration<String> e = commandLineParams.getNames(); e.hasMoreElements();) { String key = e.nextElement(); if ( p.getParameter( key ) == null ){ p.setParameter( key , commandLineParams.getParameter( key ) ); @@ -271,10 +279,9 @@ public class AServProtocolManager { // Try to retrieve first Set alignments = alignmentCache.getAlignments( onto1.getURI(), onto2.getURI() ); */ - Set alignments = alignmentCache.getAlignments( uri1, uri2 ); + Set<Alignment> alignments = alignmentCache.getAlignments( uri1, uri2 ); if ( alignments != null && params.getParameter("force") == null ) { - for ( Iterator it = alignments.iterator(); it.hasNext() ; ){ - Alignment al = ((Alignment)it.next()); + for ( Alignment al: alignments ){ if ( al.getExtension( Annotations.ALIGNNS, Annotations.METHOD ).equals(method) ) { return new AlignmentId(newId(),mess,myId,mess.getSender(), al.getExtension( Annotations.ALIGNNS, Annotations.ID ),(Parameters)null, @@ -815,6 +822,7 @@ public class AServProtocolManager { // in the path or at the local place? //classPath += File.pathSeparator+file.getParent()+File.separator + path.replaceAll("[ \t]+",File.pathSeparator+file.getParent()+File.separator); // This replaces the replaceAll which is not tolerant on Windows in having "\" as a separator + // Is there a way to make it iterable??? for( StringTokenizer token = new StringTokenizer(path," \t"); token.hasMoreTokens(); ) classPath += File.pathSeparator+file.getParent()+File.separator+token.nextToken(); } diff --git a/src/fr/inrialpes/exmo/align/service/CacheImpl.java b/src/fr/inrialpes/exmo/align/service/CacheImpl.java index e0c7d1e7aeaabe404ed3bdc2be027ef8d7454264..d8da7434ab2e04d8d28ebc34ffa5178848cc0a39 100644 --- a/src/fr/inrialpes/exmo/align/service/CacheImpl.java +++ b/src/fr/inrialpes/exmo/align/service/CacheImpl.java @@ -282,7 +282,6 @@ public class CacheImpl { protected Alignment retrieveAlignment( String id, Alignment alignment ) throws SQLException, AlignmentException, URISyntaxException { String query; URI ent1 = null, ent2 = null; - Cell cell = null; Statement st = createStatement(); @@ -296,15 +295,14 @@ public class CacheImpl { ent1 = new URI(rs.getString("uri1")); ent2 = new URI(rs.getString("uri2")); if(ent1 == null || ent2 == null) break; - cell = alignment.addAlignCell(ent1, ent2, rs.getString("relation"), Double.parseDouble(rs.getString("measure"))); + Cell cell = alignment.addAlignCell(ent1, ent2, rs.getString("relation"), Double.parseDouble(rs.getString("measure"))); cell.setId(rs.getString("cell_id")); cell.setSemantics(rs.getString("semantics")); } // JE: I must now retrieve all the extensions of the cells - for( Enumeration e = alignment.getElements() ; e.hasMoreElements(); ){ - cell = (Cell)e.nextElement(); + for ( Cell cell: alignment ){ String cid = cell.getId(); if ( cid != null && !cid.equals("") ){ query = "SELECT * FROM extension WHERE id = '" + cid + "'"; @@ -591,8 +589,7 @@ public class CacheImpl { st.executeUpdate(query); } - for( Enumeration e = alignment.getElements() ; e.hasMoreElements(); ){ - Cell c = (Cell)e.nextElement(); + for( Cell c : alignment ) { String cellid = null; if ( c.getObject1() != null && c.getObject2() != null ){ cellid = c.getId(); diff --git a/src/fr/inrialpes/exmo/align/service/HTMLAServProfile.java b/src/fr/inrialpes/exmo/align/service/HTMLAServProfile.java index d158d8a1460b55fa15c6b4894ee3651406cfe2fd..157bf40267fa4d35d38811b4dfca903740c72f39 100644 --- a/src/fr/inrialpes/exmo/align/service/HTMLAServProfile.java +++ b/src/fr/inrialpes/exmo/align/service/HTMLAServProfile.java @@ -403,8 +403,7 @@ public class HTMLAServProfile implements AlignmentServiceProfile { String msg = ""; if ( perf.equals("listalignments") ){ msg = "<h1>Available alignments</h1><ul compact=\"1\">"; - for( Enumeration e = manager.alignments(); e.hasMoreElements(); ){ - Alignment al = (Alignment)e.nextElement(); + for ( Alignment al : manager.alignments() ) { String id = al.getExtension( Annotations.ALIGNNS, Annotations.ID ); String pid = al.getExtension( Annotations.ALIGNNS, Annotations.PRETTY ); if ( pid == null ) pid = id; else pid = id+" ("+pid+")"; @@ -496,11 +495,11 @@ public class HTMLAServProfile implements AlignmentServiceProfile { msg = "<h1>Store an alignment</h1><form action=\"store\">"; msg += "Alignment id: <select name=\"id\">"; // JE: only those non stored please (retrieve metadata + stored) - for( Enumeration e = manager.alignments(); e.hasMoreElements(); ){ - String id = ((Alignment)e.nextElement()).getExtension( Annotations.ALIGNNS, Annotations.ID); + for ( Alignment al : manager.alignments() ) { + String id = al.getExtension( Annotations.ALIGNNS, Annotations.ID); params.setParameter("id", id); if ( !manager.storedAlignment( new Message(newId(),(Message)null,myId,serverId,"", params ) ) ){ - String pid = ((Alignment)e.nextElement()).getExtension( Annotations.ALIGNNS, Annotations.PRETTY ); + String pid = al.getExtension( Annotations.ALIGNNS, Annotations.PRETTY ); if ( pid == null ) pid = id; else pid = id+" ("+pid+")"; msg += "<option value=\""+id+"\">"+pid+"</option>"; } @@ -532,8 +531,7 @@ public class HTMLAServProfile implements AlignmentServiceProfile { String sel = (String)params.getParameter("id"); msg ="<h1>Trim alignments</h1><form action=\"cut\">"; msg += "Alignment id: <select name=\"id\">"; - for( Enumeration e = manager.alignments(); e.hasMoreElements(); ){ - Alignment al = (Alignment)e.nextElement(); + for( Alignment al: manager.alignments() ){ String id = al.getExtension( Annotations.ALIGNNS, Annotations.ID); String pid = al.getExtension( Annotations.ALIGNNS, Annotations.PRETTY ); if ( pid == null ) pid = id; else pid = id+" ("+pid+")"; @@ -560,8 +558,7 @@ public class HTMLAServProfile implements AlignmentServiceProfile { } else if ( perf.equals("prminv") ) { msg ="<h1>Invert alignment</h1><form action=\"inv\">"; msg += "Alignment id: <select name=\"id\">"; - for( Enumeration e = manager.alignments(); e.hasMoreElements(); ){ - Alignment al = (Alignment)e.nextElement(); + for( Alignment al: manager.alignments() ){ String id = al.getExtension( Annotations.ALIGNNS, Annotations.ID); String pid = al.getExtension( Annotations.ALIGNNS, Annotations.PRETTY ); if ( pid == null ) pid = id; else pid = id+" ("+pid+")"; @@ -596,8 +593,7 @@ public class HTMLAServProfile implements AlignmentServiceProfile { msg += "<option value=\""+id+"\">"+id+"</option>"; } msg += "</select><br />Initial alignment id: <select name=\"id\"><option value=\"\" selected=\"1\"></option>"; - for( Enumeration e = manager.alignments(); e.hasMoreElements(); ){ - Alignment al = (Alignment)e.nextElement(); + for( Alignment al: manager.alignments() ){ String id = al.getExtension( Annotations.ALIGNNS, Annotations.ID); String pid = al.getExtension( Annotations.ALIGNNS, Annotations.PRETTY ); if ( pid == null ) pid = id; else pid = id+" ("+pid+")"; @@ -630,8 +626,7 @@ public class HTMLAServProfile implements AlignmentServiceProfile { String sel = (String)params.getParameter("id"); msg = "<h1>Retrieve alignment</h1><form action=\"retrieve\">"; msg += "Alignment id: <select name=\"id\">"; - for( Enumeration e = manager.alignments(); e.hasMoreElements(); ){ - Alignment al = (Alignment)e.nextElement(); + for( Alignment al: manager.alignments() ){ String id = al.getExtension( Annotations.ALIGNNS, Annotations.ID); String pid = al.getExtension( Annotations.ALIGNNS, Annotations.PRETTY ); if ( pid == null ) pid = id; else pid = id+" ("+pid+")"; @@ -660,8 +655,7 @@ public class HTMLAServProfile implements AlignmentServiceProfile { } else if ( perf.equals("prmmetadata") ) { msg = "<h1>Retrieve alignment metadata</h1><form action=\"metadata\">"; msg += "Alignment id: <select name=\"id\">"; - for( Enumeration e = manager.alignments(); e.hasMoreElements(); ){ - Alignment al = (Alignment)e.nextElement(); + for( Alignment al: manager.alignments() ){ String id = al.getExtension( Annotations.ALIGNNS, Annotations.ID); String pid = al.getExtension( Annotations.ALIGNNS, Annotations.PRETTY ); if ( pid == null ) pid = id; else pid = id+" ("+pid+")"; @@ -706,8 +700,7 @@ public class HTMLAServProfile implements AlignmentServiceProfile { } else if ( perf.equals("prmtranslate") ) { msg = "<h1>Translate query</h1><form action=\"translate\">"; msg += "Alignment id: <select name=\"id\">"; - for( Enumeration e = manager.alignments(); e.hasMoreElements(); ){ - Alignment al = (Alignment)e.nextElement(); + for( Alignment al: manager.alignments() ){ String id = al.getExtension( Annotations.ALIGNNS, Annotations.ID); String pid = al.getExtension( Annotations.ALIGNNS, Annotations.PRETTY ); if ( pid == null ) pid = id; else pid = id+" ("+pid+")"; @@ -729,8 +722,7 @@ public class HTMLAServProfile implements AlignmentServiceProfile { } else if ( perf.equals("prmmetadata") ) { msg = "<h1>Retrieve alignment metadata</h1><form action=\"metadata\">"; msg += "Alignment id: <select name=\"id\">"; - for( Enumeration e = manager.alignments(); e.hasMoreElements(); ){ - Alignment al = (Alignment)e.nextElement(); + for( Alignment al: manager.alignments() ){ String id = al.getExtension( Annotations.ALIGNNS, Annotations.ID); String pid = al.getExtension( Annotations.ALIGNNS, Annotations.PRETTY ); if ( pid == null ) pid = id; else pid = id+" ("+pid+")"; @@ -752,8 +744,7 @@ public class HTMLAServProfile implements AlignmentServiceProfile { msg ="<h1>Evaluate alignment</h1><form action=\"eval\">"; msg += "Alignment to evaluate: "; msg += "<select name=\"id\">"; - for( Enumeration e = manager.alignments(); e.hasMoreElements(); ){ - Alignment al = (Alignment)e.nextElement(); + for( Alignment al: manager.alignments() ){ String id = al.getExtension( Annotations.ALIGNNS, Annotations.ID); String pid = al.getExtension( Annotations.ALIGNNS, Annotations.PRETTY ); if ( pid == null ) pid = id; else pid = id+" ("+pid+")"; @@ -762,8 +753,7 @@ public class HTMLAServProfile implements AlignmentServiceProfile { msg += "</select><br />"; msg +="Reference alignment: "; msg += "<select name=\"ref\">"; - for( Enumeration e = manager.alignments(); e.hasMoreElements(); ){ - Alignment al = (Alignment)e.nextElement(); + for( Alignment al: manager.alignments() ){ String id = al.getExtension( Annotations.ALIGNNS, Annotations.ID); String pid = al.getExtension( Annotations.ALIGNNS, Annotations.PRETTY ); if ( pid == null ) pid = id; else pid = id+" ("+pid+")"; diff --git a/src/fr/inrialpes/exmo/align/service/QueryMediator.java b/src/fr/inrialpes/exmo/align/service/QueryMediator.java index 572dbc35bdccda2594f8c055ea9a13219d28f75c..c4fc23d7fe1ad1ba88e50fc6248103e73380e5ee 100644 --- a/src/fr/inrialpes/exmo/align/service/QueryMediator.java +++ b/src/fr/inrialpes/exmo/align/service/QueryMediator.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA Rhône-Alpes, 2006-2008 + * Copyright (C) INRIA, 2006-2009 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -186,8 +186,7 @@ public class QueryMediator implements QueryProcessor { } } else mainQuery = aQuery; // The second part replaces the named items by their counterparts - for( Enumeration e = align.getElements() ; e.hasMoreElements(); ){ - Cell cell = (Cell)e.nextElement(); + for( Cell cell : align ){ mainQuery = mainQuery.replaceAll( cell.getObject1AsURI(align).toString(), cell.getObject2AsURI(align).toString() ); diff --git a/src/fr/inrialpes/exmo/align/service/WSAServProfile.java b/src/fr/inrialpes/exmo/align/service/WSAServProfile.java index d1ac5210ed955f16a37754511356bc7f0f42b542..61a9081464ec8737117882fefe2af129d5f25380 100644 --- a/src/fr/inrialpes/exmo/align/service/WSAServProfile.java +++ b/src/fr/inrialpes/exmo/align/service/WSAServProfile.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2007-2008. + * Copyright (C) INRIA, 2007-2009 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -231,29 +231,28 @@ public class WSAServProfile implements AlignmentServiceProfile { msg += wsdlAnswer(); } else if ( method.equals("listalignmentsRequest") || method.equals("listalignments") ) { msg += " <listalignmentsResponse>\n <alignmentList>"; - for( Enumeration e = manager.alignments(); e.hasMoreElements(); ){ - String id = ((Alignment)e.nextElement()).getExtension(Annotations.ALIGNNS, Annotations.ID); + for( Alignment al: manager.alignments() ){ + String id = al.getExtension(Annotations.ALIGNNS, Annotations.ID); msg += " <alid>"+id+"</alid>\n"; } msg += " </alignmentList>\n </listalignmentsResponse>\n"; // -> List of URI } else if ( method.equals("listmethodsRequest") || method.equals("listmethods") ) { // -> List of String msg += " <listmethodsResponse>\n <classList>\n"; - for( Iterator it = manager.listmethods().iterator(); it.hasNext(); ) { - String mt = (String) it.next(); + for( String mt: manager.listmethods() ) { msg += " <method>"+mt+"</method>\n"; } msg += " </classList>\n </listmethodsResponse>\n"; } else if ( method.equals("listrenderersRequest") || method.equals("listrenderers") ) { // -> List of String msg += " <listrenderersResponse>\n <classList>\n"; - for( Iterator it = manager.listrenderers().iterator(); it.hasNext(); ) { - msg += " <renderer>"+it.next()+"</renderer>\n"; + for( String m: manager.listrenderers() ) { + msg += " <renderer>"+m+"</renderer>\n"; } msg += " </classList>\n </listrenderersResponse>\n"; } else if ( method.equals("listservicesRequest") || method.equals("listservices") ) { // -> List of String msg += " <listservicesResponse>\n <classList>\n"; - for( Iterator it = manager.listservices().iterator(); it.hasNext(); ) { - msg += " <service>"+it.next()+"</service>\n"; + for( String m: manager.listservices() ) { + msg += " <service>"+m+"</service>\n"; } msg += " </classList>\n </listservicesResponse>\n"; } else if ( method.equals("storeRequest") || method.equals("store") ) { // URI -> URI diff --git a/src/fr/inrialpes/exmo/align/util/ExtGroupEval.java b/src/fr/inrialpes/exmo/align/util/ExtGroupEval.java index 271ea4c6fe007f63f14b5bf5c501f67c0f5cb08a..fe0dd1ea5c5373d019c9eb61f44f69fc1b68692d 100644 --- a/src/fr/inrialpes/exmo/align/util/ExtGroupEval.java +++ b/src/fr/inrialpes/exmo/align/util/ExtGroupEval.java @@ -3,7 +3,7 @@ * * Copyright (C) 2003 The University of Manchester * Copyright (C) 2003 The University of Karlsruhe - * Copyright (C) 2003-2005, 2007-2008 INRIA + * Copyright (C) 2003-2005, 2007-2009 INRIA * Copyright (C) 2004, Université de Montréal * * This program is free software; you can redistribute it and/or @@ -192,8 +192,8 @@ public class ExtGroupEval { print( iterateDirectories() ); } - public Vector<Object> iterateDirectories (){ - Vector<Object> result = null; + public Vector<Vector> iterateDirectories (){ + Vector<Vector> result = null; File [] subdir = null; try { if (ontoDir == null) { @@ -207,14 +207,14 @@ public class ExtGroupEval { } int size = subdir.length; Arrays.sort(subdir); - result = new Vector<Object>(size); + result = new Vector<Vector>(size); int i = 0; for ( int j=0 ; j < size; j++ ) { if( subdir[j].isDirectory() ) { if ( debug > 0 ) System.err.println("\nEntering directory "+subdir[j]); // eval the alignments in a subdirectory // store the result - Object vect = (Object)iterateAlignments( subdir[j] ); + Vector vect = (Vector)iterateAlignments( subdir[j] ); if ( vect != null ){ result.add(i, vect); i++; @@ -229,14 +229,15 @@ public class ExtGroupEval { Vector<Object> result = new Vector<Object>(); boolean ok = false; result.add(0,(Object)dir.getName().toString()); - int i = 1; + int i = 0; // for all alignments there, - for ( Enumeration<String> e = listAlgo.elements() ; e.hasMoreElements() ; i++) { + for ( String m : listAlgo ) { + i++; // call eval // store the result in a record // return the record. if ( debug > 1) System.err.println(" Considering result "+i); - Evaluator evaluator = (Evaluator)eval( prefix+reference, prefix+e.nextElement()+".rdf"); + Evaluator evaluator = (Evaluator)eval( prefix+reference, prefix+m+".rdf"); if ( evaluator != null ) ok = true; result.add( i, evaluator ); } @@ -280,7 +281,7 @@ public class ExtGroupEval { /** * This does not only print the results but compute the average as well */ - public void print( Vector result ) { + public void print( Vector<Vector> result ) { // variables for computing iterative harmonic means int expected = 0; // expected so far int foundVect[]; // found so far @@ -301,18 +302,18 @@ public class ExtGroupEval { writer.println("<table border='2' frame='sides' rules='groups'>"); writer.println("<colgroup align='center' />"); // for each algo <td spancol='2'>name</td> - for ( Enumeration<String> e = listAlgo.elements() ; e.hasMoreElements() ;e.nextElement()) { + for ( String m : listAlgo ) { writer.println("<colgroup align='center' span='"+fsize+"' />"); } // For each file do a writer.println("<thead valign='top'><tr><th>algo</th>"); // for each algo <td spancol='2'>name</td> - for ( Enumeration<String> e = listAlgo.elements() ; e.hasMoreElements() ;) { - writer.println("<th colspan='"+(fsize+1)+"'>"+e.nextElement()+"</th>"); + for ( String m : listAlgo ) { + writer.println("<th colspan='"+(fsize+1)+"'>"+m+"</th>"); } writer.println("</tr></thead><tbody><tr><td>test</td>"); // for each algo <td>Prec.</td><td>Rec.</td> - for ( Enumeration<String> e = listAlgo.elements() ; e.hasMoreElements() ;e.nextElement()) { + for ( String m : listAlgo ) { for ( int i = 0; i < fsize; i++){ if ( format.charAt(i) == 's' ) { writer.println("<td colspan='2'>Symmetric</td>"); @@ -334,9 +335,8 @@ public class ExtGroupEval { // </tr> // For each directory <tr> boolean colored = false; - for ( Enumeration e = result.elements() ; e.hasMoreElements() ;) { + for ( Vector test : result ) { int nexpected = -1; - Vector test = (Vector)e.nextElement(); if ( colored == true && color != null ){ colored = false; writer.println("<tr bgcolor=\""+color+"\">"); @@ -392,8 +392,7 @@ public class ExtGroupEval { } writer.print("<tr bgcolor=\"yellow\"><td>H-mean</td>"); int k = 0; - for ( Enumeration<String> e = listAlgo.elements() ; e.hasMoreElements() ; k++) { - e.nextElement(); + for ( String m : listAlgo ) { if ( foundVect[k] != -1 ){ double precision = (double)correctVect[k]/foundVect[k]; double recall = (double)correctVect[k]/expected; @@ -407,6 +406,7 @@ public class ExtGroupEval { writer.println("<td colspan='2'><center>Error</center></td>"); } //}; + k++; } writer.println("</tr>"); writer.println("</tbody></table>"); diff --git a/src/fr/inrialpes/exmo/align/util/GenPlot.java b/src/fr/inrialpes/exmo/align/util/GenPlot.java index 952320faf2759d3f168e63178dd58856f118ee8c..0e9cde8dd022adce44c59050ebb8293f65440100 100644 --- a/src/fr/inrialpes/exmo/align/util/GenPlot.java +++ b/src/fr/inrialpes/exmo/align/util/GenPlot.java @@ -3,7 +3,7 @@ * * Copyright (C) 2003 The University of Manchester * Copyright (C) 2003 The University of Karlsruhe - * Copyright (C) 2003-2008, INRIA + * Copyright (C) 2003-2009, INRIA * Copyright (C) 2004, Université de Montréal * * This program is free software; you can redistribute it and/or @@ -224,8 +224,7 @@ public class GenPlot { if( debug > 0 ) System.err.println("Directory : "+dir); // for all alignments there, - for ( Enumeration e = listAlgo.elements() ; e.hasMoreElements() ; i++) { - String algo = (String)e.nextElement(); + for ( String algo : listAlgo ) { // call eval if ( debug > 0 ) System.err.println(" Considering result "+algo+" ("+i+")"); PRGraphEvaluator evaluator = eval( prefix+"refalign.rdf", prefix+algo+".rdf"); @@ -235,6 +234,7 @@ public class GenPlot { result[i][j] = result[i][j] + evaluator.getPrecision(j); } } + i++; } // Unload the ontologies. OntologyFactory.clear(); @@ -303,23 +303,24 @@ public class GenPlot { output.println("\\draw (-0.3,5) node[rotate=90] {$precision$}; "); output.println("\\draw (-0.3,10) node {1.}; "); output.println("% Plots"); - for ( Enumeration e = listAlgo.elements() ; e.hasMoreElements() ; i++) { - output.println("\\draw["+colortable[i%7]+"] plot[mark="+marktable[i%19]+",smooth] file {"+(String)e.nextElement()+".table};"); + for ( String m : listAlgo ) { + output.println("\\draw["+colortable[i%7]+"] plot[mark="+marktable[i%19]+",smooth] file {"+m+".table};"); + i++; } // And a legend output.println("% Legend"); i = 0; - for ( Enumeration e = listAlgo.elements() ; e.hasMoreElements() ; i++) { + for ( String m : listAlgo ) { output.println("\\draw["+colortable[i%7]+"] plot[mark="+marktable[i%19]+",smooth] coordinates {("+((i%3)*3+1)+","+(-(i/3)*.8-1)+") ("+((i%3)*3+3)+","+(-(i/3)*.8-1)+")};"); - output.println("\\draw["+colortable[i%7]+"] ("+((i%3)*3+2)+","+(-(i/3)*.8-.8)+") node {"+(String)e.nextElement()+"};"); + output.println("\\draw["+colortable[i%7]+"] ("+((i%3)*3+2)+","+(-(i/3)*.8-.8)+") node {"+m+"};"); + i++; } output.println("\\end{tikzpicture}"); output.println(); output.println("\\end{document}"); i = 0; - for ( Enumeration e = listAlgo.elements() ; e.hasMoreElements() ; i++) { - String algo = (String)e.nextElement(); + for ( String algo : listAlgo ) { // Open one file PrintWriter writer; try { @@ -346,13 +347,14 @@ public class GenPlot { writer.close(); } catch (Exception ex) { ex.printStackTrace(); } // UnsupportedEncodingException + FileNotFoundException + i++; } } public void printTSV( double[][] result ) { // Print first line - for ( Enumeration e = listAlgo.elements() ; e.hasMoreElements() ; ) { - output.print("\t"+(String)e.nextElement() ); + for ( String m : listAlgo ) { + output.print("\t"+m ); } output.println(); diff --git a/src/fr/inrialpes/exmo/align/util/GroupEval.java b/src/fr/inrialpes/exmo/align/util/GroupEval.java index 0ef5540ed289b8f9546e24097ab5372526141be0..51cb486b283e81b5072c0067e38eda20fe0a6ae7 100644 --- a/src/fr/inrialpes/exmo/align/util/GroupEval.java +++ b/src/fr/inrialpes/exmo/align/util/GroupEval.java @@ -226,14 +226,15 @@ public class GroupEval { Vector<Object> result = new Vector<Object>(); boolean ok = false; result.add(0,(Object)dir.getName().toString()); - int i = 1; + int i = 0; // for all alignments there, - for ( Enumeration<String> e = listAlgo.elements() ; e.hasMoreElements() ; i++) { + for ( String m: listAlgo ) { + i++; // call eval // store the result in a record // return the record. if ( debug > 2) System.err.println(" Considering result "+i); - Evaluator evaluator = (Evaluator)eval( prefix+reference, prefix+(String)e.nextElement()+".rdf"); + Evaluator evaluator = (Evaluator)eval( prefix+reference, prefix+m+".rdf"); if ( evaluator != null ) ok = true; result.add( i, evaluator ); } @@ -282,7 +283,7 @@ public class GroupEval { else if ( type.equals("triangle") ) printTRIANGLE( result ); } - public void printTRIANGLE( Vector result ) { + public void printTRIANGLE( Vector<Vector> result ) { // variables for computing iterative harmonic means int expected = 0; // expected so far int foundVect[]; // found so far @@ -296,10 +297,10 @@ public class GroupEval { correctVect[k] = 0; timeVect[k] = 0; } - for ( Enumeration e = result.elements() ; e.hasMoreElements() ;) { + for ( Vector test : result ) { int nexpected = -1; - Vector test = (Vector)e.nextElement(); Enumeration f = test.elements(); + // Too bad the first element must be skipped f.nextElement(); for( int k = 0 ; f.hasMoreElements() ; k++) { PRecEvaluator eval = (PRecEvaluator)f.nextElement(); @@ -338,7 +339,7 @@ public class GroupEval { //System.out.println("\\draw (10,-0.3) node {1.}; "); System.out.println("% Plots"); int k = 0; - for ( Enumeration<String> e = listAlgo.elements() ; e.hasMoreElements() ; k++) { + for ( String m: listAlgo ) { double precision = (double)correctVect[k]/foundVect[k]; double recall = (double)correctVect[k]/expected; double prec2 = precision*precision; @@ -346,7 +347,8 @@ public class GroupEval { double b = java.lang.Math.sqrt( prec2 - (a*a) ); a = a*10; b = b*10; //for printing scale 10. System.out.println("\\draw plot[mark=+,] coordinates {("+a+","+b+")};"); - System.out.println("\\draw ("+(a+.01)+","+(b+.01)+") node[anchor=south west] {"+(String)e.nextElement()+"};"); + System.out.println("\\draw ("+(a+.01)+","+(b+.01)+") node[anchor=south west] {"+m+"};"); + k++; } System.out.println("\\end{tikzpicture}"); System.out.println(); @@ -402,7 +404,7 @@ and which the program does... */ - public void printHTML( Vector result ) { + public void printHTML( Vector<Vector> result ) { // variables for computing iterative harmonic means int expected = 0; // expected so far int foundVect[]; // found so far @@ -426,18 +428,18 @@ which the program does... writer.println("<table border='2' frame='sides' rules='groups'>"); writer.println("<colgroup align='center' />"); // for each algo <td spancol='2'>name</td> - for ( Enumeration<String> e = listAlgo.elements() ; e.hasMoreElements() ;e.nextElement()) { + for ( String m : listAlgo ) { writer.println("<colgroup align='center' span='"+fsize+"' />"); } // For each file do a writer.println("<thead valign='top'><tr><th>algo</th>"); // for each algo <td spancol='2'>name</td> - for ( Enumeration<String> e = listAlgo.elements() ; e.hasMoreElements() ;) { - writer.println("<th colspan='"+fsize+"'>"+e.nextElement()+"</th>"); + for ( String m : listAlgo ) { + writer.println("<th colspan='"+fsize+"'>"+m+"</th>"); } writer.println("</tr></thead><tbody><tr><td>test</td>"); // for each algo <td>Prec.</td><td>Rec.</td> - for ( Enumeration<String> e = listAlgo.elements() ; e.hasMoreElements() ;e.nextElement()) { + for ( String m : listAlgo ) { for ( int i = 0; i < fsize; i++){ writer.print("<td>"); if ( format.charAt(i) == 'p' ) { @@ -469,9 +471,8 @@ which the program does... // </tr> // For each directory <tr> boolean colored = false; - for ( Enumeration e = result.elements() ; e.hasMoreElements() ;) { + for ( Vector test : result ) { int nexpected = -1; - Vector test = (Vector)e.nextElement(); if ( colored == true && color != null ){ colored = false; writer.println("<tr bgcolor=\""+color+"\">"); @@ -530,8 +531,8 @@ which the program does... // here we use the real values, i.e., add 0 to both correctVect and // foundVect, so this is OK for computing the average. int k = 0; - for ( Enumeration<String> e = listAlgo.elements() ; e.hasMoreElements() ; k++) { - e.nextElement(); + // ??? + for ( String m : listAlgo ) { double precision = (double)correctVect[k]/foundVect[k]; double recall = (double)correctVect[k]/expected; for ( int i = 0 ; i < fsize; i++){ @@ -555,6 +556,7 @@ which the program does... } writer.println("</td>"); }; + k++; } writer.println("</tr>"); writer.println("</tbody></table>"); diff --git a/src/fr/inrialpes/exmo/align/util/GroupOutput.java b/src/fr/inrialpes/exmo/align/util/GroupOutput.java index dd26188bf58a6f5f1a2d5bd76104d27f6da244ba..11f27109e49fb4de1ee0f931b28c05f0fe3421c5 100644 --- a/src/fr/inrialpes/exmo/align/util/GroupOutput.java +++ b/src/fr/inrialpes/exmo/align/util/GroupOutput.java @@ -3,7 +3,7 @@ * * Copyright (C) 2003 The University of Manchester * Copyright (C) 2003 The University of Karlsruhe - * Copyright (C) 2003-2008, INRIA + * Copyright (C) 2003-2009, INRIA * Copyright (C) 2004, Université de Montréal * * This program is free software; you can redistribute it and/or @@ -217,8 +217,7 @@ public class GroupOutput { public void iterateAlgorithm(){ // for all alignments there, - for ( Enumeration e = listAlgo.elements() ; e.hasMoreElements() ; ) { - String algo = (String)e.nextElement(); + for ( String algo : listAlgo ) { if ( debug > 0 ) System.err.println("Algorithm: "+algo); // type if ( type.equals("tex") ) {