Mentions légales du service

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

- Added new tests

parent f3c241a5
No related branches found
No related tags found
No related merge requests found
...@@ -38,6 +38,12 @@ Building: ...@@ -38,6 +38,12 @@ Building:
--------- ---------
$ ant jar $ ant jar
(or ant compileall; ant jar)
Testing
-------
$ ant test
Running: Running:
-------- --------
......
/*
* $Id$
*
* Copyright (C) INRIA Rhne-Alpes, 2008
*
* 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 test.com.acme.dona.dep;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Configuration;
import org.testng.annotations.Test;
//import org.testng.annotations.*;
import org.semanticweb.owl.align.AlignmentVisitor;
import org.semanticweb.owl.align.AlignmentException;
import org.semanticweb.owl.align.Alignment;
import org.semanticweb.owl.align.AlignmentProcess;
import org.semanticweb.owl.align.Parameters;
import fr.inrialpes.exmo.align.impl.renderer.RDFRendererVisitor;
import fr.inrialpes.exmo.align.impl.BasicParameters;
import fr.inrialpes.exmo.align.ling.JWNLAlignment;
import java.io.ByteArrayOutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.net.URI;
import java.net.URISyntaxException;
/**
* These tests corresponds to the JWNL test of the README file in the main directory
*/
public class JWNLTest {
private AlignmentProcess alignment = null;
@Test(groups = { "full", "ling" })
public void routineJWNLTest() throws Exception {
/*
$ setenv WNDIR
$ java -jar lib/alignwn.jar -D=$WNDIR file://$CWD/examples/rdf/ file://$CWD/examples/rdf/ -i fr.inrialpes.exmo.align.ling.JWNLAlignment -o examples/rdf/JWNL.rdf
*/
Parameters params = new BasicParameters();
//System.getenv("WNDIR");
params.setParameter( "wndict", "../WordNet-2.0/dict" );
alignment = new JWNLAlignment();
assertNotNull( alignment, "ObjectAlignment should not be null" );
assertEquals( alignment.nbCells(), 0 );
alignment.init( new URI("file:examples/rdf/edu.umbc.ebiquity.publication.owl"), new URI("file:examples/rdf/edu.mit.visus.bibtex.owl"));
alignment.align( (Alignment)null, params );
assertEquals( alignment.nbCells(), 43 );
ByteArrayOutputStream stream = new ByteArrayOutputStream();
//FileOutputStream stream = new FileOutputStream("result.rdf");
PrintWriter writer = new PrintWriter (
new BufferedWriter(
new OutputStreamWriter( stream, "UTF-8" )), true);
AlignmentVisitor renderer = new RDFRendererVisitor( writer );
alignment.render( renderer );
writer.flush();
writer.close();
assertEquals( stream.toString().length(), 14037, "Rendered differently" );
alignment.cut( "hard", 0.4 );
assertEquals( alignment.nbCells(), 35 );
}
}
/*
* $Id$
*
* Copyright (C) INRIA Rhne-Alpes, 2008
*
* 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 test.com.acme.dona.dep;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Configuration;
import org.testng.annotations.Test;
//import org.testng.annotations.*;
import org.semanticweb.owl.align.AlignmentVisitor;
import org.semanticweb.owl.align.AlignmentException;
import org.semanticweb.owl.align.Alignment;
import fr.inrialpes.exmo.align.impl.renderer.RDFRendererVisitor;
import fr.inrialpes.exmo.align.parser.AlignmentParser;
import java.io.ByteArrayOutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.io.FileOutputStream;
/**
* These tests corresponds to the tests presented in the examples/omwg directory
*/
public class OMWGTest {
private Alignment alignment = null;
private AlignmentParser aparser1 = null;
@Test(groups = { "full", "omwg" })
public void loadPrintTest() throws Exception {
/*
java -cp ../../lib/procalign.jar fr.inrialpes.exmo.align.util.ParserPrinter wine.xml > wine2.xml
*/
aparser1 = new AlignmentParser( 0 );
assertNotNull( aparser1 );
alignment = aparser1.parse( "examples/omwg/wine.xml" );
assertNotNull( alignment );
//assertTrue( alignment instanceof OMWGAlignment );
FileOutputStream stream = new FileOutputStream("examples/omwg/wine2.xml");
PrintWriter writer = new PrintWriter (
new BufferedWriter(
new OutputStreamWriter( stream, "UTF-8" )), true);
AlignmentVisitor renderer = new RDFRendererVisitor( writer );
alignment.render( renderer );
writer.flush();
writer.close();
}
@Test(groups = { "full", "omwg" }, dependsOnMethods = {"loadPrintTest"})
public void roundTripTest() throws Exception {
/*
java -cp ../../lib/procalign.jar fr.inrialpes.exmo.align.util.ParserPrinter wine2.xml > wine3.xml
*/
alignment = aparser1.parse( "examples/omwg/wine2.xml" );
assertNotNull( alignment );
FileOutputStream stream = new FileOutputStream("examples/omwg/wine3.xml");
PrintWriter writer = new PrintWriter (
new BufferedWriter(
new OutputStreamWriter( stream, "UTF-8" )), true);
AlignmentVisitor renderer = new RDFRendererVisitor( writer );
alignment.render( renderer );
writer.flush();
writer.close();
}
@Test(groups = { "full", "omwg" }, dependsOnMethods = {"roundTripTest"})
public void diffTest() throws Exception {
/*
diff wine2.xml wine3.xml
*/
Alignment oldal = aparser1.parse( "examples/omwg/wine2.xml" );
alignment = aparser1.parse( "examples/omwg/wine3.xml" );
assertNotNull( alignment );
ByteArrayOutputStream stream = new ByteArrayOutputStream();
PrintWriter writer = new PrintWriter (
new BufferedWriter(
new OutputStreamWriter( stream, "UTF-8" )), true);
AlignmentVisitor renderer = new RDFRendererVisitor( writer );
oldal.render( renderer );
writer.flush();
writer.close();
String wine2 = stream.toString();
stream = new ByteArrayOutputStream();
writer = new PrintWriter (
new BufferedWriter(
new OutputStreamWriter( stream, "UTF-8" )), true);
renderer = new RDFRendererVisitor( writer );
alignment.render( renderer );
writer.flush();
writer.close();
assertEquals( wine2, stream.toString() );
}
}
...@@ -43,15 +43,21 @@ import fr.inrialpes.exmo.align.impl.BasicParameters; ...@@ -43,15 +43,21 @@ import fr.inrialpes.exmo.align.impl.BasicParameters;
import fr.inrialpes.exmo.align.impl.URIAlignment; import fr.inrialpes.exmo.align.impl.URIAlignment;
import fr.inrialpes.exmo.align.onto.OntologyCache; import fr.inrialpes.exmo.align.onto.OntologyCache;
import fr.inrialpes.exmo.align.parser.AlignmentParser; import fr.inrialpes.exmo.align.parser.AlignmentParser;
import fr.inrialpes.exmo.align.util.NullStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.OutputStream;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
/**
* These tests corresponds to the README file in the main directory
*/
public class READMETest { public class READMETest {
private AlignmentProcess alignment = null; private AlignmentProcess alignment = null;
...@@ -194,33 +200,24 @@ $ java -cp lib/procalign.jar fr.inrialpes.exmo.align.util.EvalAlign -i fr.inrial ...@@ -194,33 +200,24 @@ $ java -cp lib/procalign.jar fr.inrialpes.exmo.align.util.EvalAlign -i fr.inrial
assertNotNull( align2 ); assertNotNull( align2 );
Parameters params = new BasicParameters(); Parameters params = new BasicParameters();
assertNotNull( params ); assertNotNull( params );
Evaluator eval = new PRecEvaluator( align1, align2 ); PRecEvaluator eval = new PRecEvaluator( align1, align2 );
assertNotNull( eval ); assertNotNull( eval );
eval.eval( params ) ; eval.eval( params ) ;
/*
stream = new FileOutputStream(filename); // This only output the result to check that this is possible
} OutputStream stream = new NullStream();
writer = new PrintWriter ( PrintWriter writer = new PrintWriter (
new BufferedWriter( new BufferedWriter(
new OutputStreamWriter( stream, "UTF-8" )), true); new OutputStreamWriter( stream, "UTF-8" )), true);
eval.write( writer ); eval.write( writer );
writer.flush(); writer.flush();
*/ writer.close();
/* assertEquals( eval.getPrecision(), 0.7441860465116279 );
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' assertEquals( eval.getRecall(), 1.0 );
xmlns:map='http://www.atl.external.lmco.com/projects/ontology/ResultsOntology.n3#'> assertEquals( eval.getFallout(), 0.2558139534883721 );
<map:output rdf:about=''> assertEquals( eval.getFmeasure(), 0.8533333333333333 );
<map:input1 rdf:resource="http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#publication"/> assertEquals( eval.getOverall(), 0.65625 );
<map:input2 rdf:resource="file:examples/rdf/edu.mit.visus.bibtex.owl"/> //assertEquals( eval.getResult(), 1.34375 );
<map:precision>0.8372093023255814</map:precision>
<map:recall>1.0</map:recall>
<fallout>0.16279069767441862</fallout>
<map:fMeasure>0.9113924050632911</map:fMeasure>
<map:oMeasure>0.8055555555555556</map:oMeasure>
<result>1.1944444444444444</result>
</map:output>
</rdf:RDF>
*/
} }
@Test(groups = { "full", "impl" }) @Test(groups = { "full", "impl" })
......
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