diff --git a/examples/omwg/total.xml b/examples/omwg/total.xml index 46029d50c835e4ed13c05e10b5f34aa64bccfe33..eeb79e094fe52a15f08940826ed1bae2dea14330 100644 --- a/examples/omwg/total.xml +++ b/examples/omwg/total.xml @@ -33,10 +33,8 @@ <onto1> <Ontology rdf:about="&wine;"> <formalism> - <Formalism> - <uri>http://www.w3.org/TR/owl-guide/</uri> - <name>owl</name> - </Formalism> + <Formalism align:uri="http://www.w3.org/TR/owl-guide/" + align:name="owl" /> </formalism> </Ontology> </onto1> diff --git a/examples/omwg/wine.xml b/examples/omwg/wine.xml index d5213261b859369c1f514305fbd32c8335e395b3..3233f1ed6242a909d1bc55c3fa90e319f2d37157 100644 --- a/examples/omwg/wine.xml +++ b/examples/omwg/wine.xml @@ -32,10 +32,8 @@ <onto1> <Ontology rdf:about="&wine;"> <formalism> - <Formalism> - <uri>http://www.w3.org/TR/owl-guide/</uri> - <name>owl</name> - </Formalism> + <Formalism align:uri="http://www.w3.org/TR/owl-guide/" + align:name="owl" /> </formalism> </Ontology> </onto1> diff --git a/examples/rdf/bibref.owl b/examples/rdf/bibref.owl index 44ce6aec322f6f2bd55289c1e1218f492dff2e00..da89351b1fe77fcae328e450a4442e66dc2728d5 100644 --- a/examples/rdf/bibref.owl +++ b/examples/rdf/bibref.owl @@ -19,218 +19,280 @@ <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#TechReport'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#Techreport'/> <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#InBook'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#Inbook'/> <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#Misc'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#Misc'/> <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#Book'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#Book'/> <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#InCollection'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#Incollection'/> <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#MastersThesis'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#Mastersthesis'/> <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#PhdThesis'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#Phdthesis'/> <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#InProceedings'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#Inproceedings'/> <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#Proceedings'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#Proceedings'/> <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> <!-- HERE ARE THE PROPERTIES --> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#title'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#hasTitle'/> <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#editor'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#hasEditor'/> <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#edition'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#hasEdition'/> <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#series'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#hasSeries'/> <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#volume'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#hasVolume'/> <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#note'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#hasNote'/> <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#organization'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#hasOrganization'/> <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#booktitle'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#hasBooktitle'/> <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#type'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#hasType'/> <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#keyword'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#hasKeywords'/> <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#softCopyURI'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#hasURL'/> <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#softCopySize'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#hasSize'/> <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#author'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#hasAuthor'/> <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#publisher'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#hasPublisher'/> <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#chapter'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#hasChapter'/> <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#pages'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#hasPages'/> <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#number'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#hasNumber'/> <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#address'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#hasAddress'/> <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#journal'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#hasJournal'/> <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#school'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#hasSchool'/> <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#institution'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#hasInstitution'/> <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>1.0</measure> <relation>=</relation> </Cell> + </map> + <map> <Cell> <entity1 rdf:resource='http://ebiquity.umbc.edu/v2.1/ontology/publication.owl#abstract'/> <entity2 rdf:resource='file://localhost/Volumes/Phata/JAVA/ontoalign/samples/rdf/edu.mit.visus.bibtex.owl#hasAbstract'/> diff --git a/examples/rdf/newsample.rdf b/examples/rdf/newsample.rdf index f00dce61045ea3eb2bf2abd022d6e7c8f9990494..4e9cb3545b3d93ee3c84e39f46f0b657597b6541 100644 --- a/examples/rdf/newsample.rdf +++ b/examples/rdf/newsample.rdf @@ -35,7 +35,7 @@ <entity2 rdf:resource='http://www.example.org/ontology2#journalarticle'/> <relation>=</relation> <kha:myCorrespondenceTag>Testing tags in correspondences</kha:myCorrespondenceTag> - <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>0.4666666666666667</measure> + <measure rdf:datatype='http://www.w3.org/2001/XMLSchema#float'>46.66666666666667E-2</measure> <!--invalidTag>This tag would be ignored</invalidTag--> </Cell> </map> diff --git a/src/fr/inrialpes/exmo/align/parser/XMLParser.java b/src/fr/inrialpes/exmo/align/parser/XMLParser.java index 459f0bb1a2f87f0ad900d90eef85e90dc1a9628c..2c26e142b6604fc925950f8dc3bcfaf6923f3cb7 100644 --- a/src/fr/inrialpes/exmo/align/parser/XMLParser.java +++ b/src/fr/inrialpes/exmo/align/parser/XMLParser.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2003-2005, 2007-2011 + * Copyright (C) INRIA, 2003-2005, 2007-2012 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -310,11 +310,11 @@ public class XMLParser extends DefaultHandler { } else if (pName.equals( SyntaxElement.FORMALISM.name )) { if ( atts.getValue( SyntaxElement.URI.name ) != null ) try { - curronto.setFormURI( new URI(atts.getValue("uri")) ); + curronto.setFormURI( new URI(atts.getValue( SyntaxElement.URI.name )) ); } catch ( URISyntaxException e ) { - throw new SAXException("Malformed URI"+atts.getValue("uri"), e ); + throw new SAXException("Malformed URI"+atts.getValue( SyntaxElement.URI.name ), e ); }; - if ( atts.getValue("name") != null ) + if ( atts.getValue( SyntaxElement.NAME.name ) != null ) curronto.setFormalism( atts.getValue( SyntaxElement.NAME.name ) ); } else if (pName.equals( SyntaxElement.FORMATT.name )) { } else if (pName.equals( SyntaxElement.LOCATION.name )) { @@ -371,39 +371,31 @@ public class XMLParser extends DefaultHandler { /** * Put the content in a variable - */ public void characters(char ch[], int start, int length) { content = new String( ch, start, length ); if(debugMode > 2) System.err.println("content XMLParser : " + content); } - - /* - // Patch proposed by Sabine Massmann - // If to be integrated, then put it in the proper place - // There is no reasons to test for Double in characters - public void characters(char ch[], int start, int length) { - String oldContent = "" + content; - content = new String( ch, start, length ); - if ( content != null && !content.equals("\n") - && !content.startsWith("\n ") - // && oldContent.contains(".") - && oldContent.indexOf('.',0) != -1 - ){ - oldContent = oldContent.concat(content); - try { - double test = Double.parseDouble(oldContent); - content = oldContent; - } catch (NumberFormatException e) { - // TODO Auto-generated catch block - // e.printStackTrace(); - } - } - if(debugMode > 2) - System.err.println("content XMLParser : " + content); - } */ + /* From a patch proposed by Sabine Massmann + * Get around some nasty double parsing bug. Sometimes it parses + * 6.925955630686735E-4 as + * content XMLParser : 6.925955630686735 + * content XMLParser : E-4 + */ + public void characters( char ch[], int start, int length ) { + String newContent = new String( ch, start, length ); + if ( content != null && content.indexOf('.',0) != -1 // a float + && newContent != null && !newContent.startsWith("\n ") + ) { + content += newContent; + } else { + content = newContent; + } + if ( debugMode > 2 ) System.err.println("content XMLParser : " + content); + } + /** * Called by the XML parser at the end of an element. * @@ -440,7 +432,11 @@ public class XMLParser extends DefaultHandler { } else if ( measure == null || relation == null ){ cell = alignment.addAlignCell( cl1, cl2); } else { - cell = alignment.addAlignCell( cl1, cl2, relation, Double.parseDouble(measure) );} + // This test must be revised for more generic confidence (which should then be strings) + double conf = Double.parseDouble( measure ); + if ( conf > 1. || conf < 0. ) + throw new SAXException( "Bad confidence value : "+conf+" (should belong to [0. 1.])" ); + cell = alignment.addAlignCell( cl1, cl2, relation, conf );} if ( id != null ) cell.setId( id ); if ( sem != null ) cell.setSemantics( sem ); if ( extensions != null ) ((BasicCell)cell).setExtensions( extensions ); @@ -493,7 +489,7 @@ public class XMLParser extends DefaultHandler { //if ( content.equals("no") ) // { throw new SAXException("Cannot parse non XML alignments"); } } else if (pName.equals( SyntaxElement.ALIGNMENT.name )) { - parseLevel = alignLevel; // restore level²< + parseLevel = alignLevel; // restore level< alignLevel = -1; } else { if ( namespaceURI.equals( Namespace.ALIGNMENT.uri+"#" ) ) namespaceURI = Namespace.ALIGNMENT.uri; @@ -523,6 +519,7 @@ public class XMLParser extends DefaultHandler { extensions.setExtension( namespaceURI, pName, content ); } else if ( !embedded ) throw new SAXException("[XMLParser] Unknown namespace : "+namespaceURI); } + content = null; // JE2012: set it for the character patch parseLevel--; } //end endElement diff --git a/test/src/IOTest.java b/test/src/IOTest.java index b557a4fd39148935df01779226bfaaa10a6096d1..1a249d41cdd7572d078c8b5dabc4a732424a862d 100644 --- a/test/src/IOTest.java +++ b/test/src/IOTest.java @@ -28,6 +28,7 @@ import org.testng.annotations.Test; import org.semanticweb.owl.align.AlignmentVisitor; import org.semanticweb.owl.align.AlignmentException; import org.semanticweb.owl.align.Alignment; +import org.semanticweb.owl.align.Cell; import fr.inrialpes.exmo.align.parser.AlignmentParser; import fr.inrialpes.exmo.align.impl.URIAlignment; @@ -108,6 +109,15 @@ public class IOTest { assertNotNull( alignment ); assertTrue( alignment instanceof URIAlignment ); assertEquals( alignment.nbCells(), 2 ); + double min = 1.; + double max = 0.; + for ( Cell c : alignment ) { + double v = c.getStrength(); + if ( v < min ) min = v; + if ( v > max ) max = v; + } + assertEquals( min, 0.4666666666666667 ); + assertEquals( max, 1. ); } @Test(groups = { "full", "io", "raw" }, dependsOnMethods = {"loadSOAPStringErrorTest"}) diff --git a/test/src/RendererTest.java b/test/src/RendererTest.java index 44e1388f909ba5c0f7b8a6d76ba345b92703b121..50589ef5ad1f6bdc01b30553135bfd5b23b4b27b 100644 --- a/test/src/RendererTest.java +++ b/test/src/RendererTest.java @@ -69,7 +69,7 @@ public class RendererTest { AlignmentParser aparser = new AlignmentParser( 0 ); assertNotNull( aparser ); aparser.initAlignment( null ); - alignment = aparser.parse( "test/output/bibref2.rdf" ); + alignment = aparser.parse( "file:test/output/bibref2.rdf" ); assertNotNull( alignment ); assertEquals( alignment.nbCells(), 32); oalignment = ObjectAlignment.toObjectAlignment( (URIAlignment)alignment );