Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 18f90960 authored by Jérôme David's avatar Jérôme David
Browse files

added :

	- methods Relation::compose (for EquivRelation, Subsum..Relation, and IncompatRelation)
	- methods Cell::compose

new implementation of Alignment::compose -> Now it works
parent 50939d28
No related branches found
No related tags found
No related merge requests found
Showing
with 108 additions and 46 deletions
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -8,12 +8,12 @@
* 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
......@@ -48,10 +48,10 @@ import org.semanticweb.owl.align.Parameters;
* NOTE(JE): hashtabale are indexed by URI.
* This is strange, but there might be a reason
* NOTE(JE): I do not think that this is the case anymore
*
*
* In version 3.0 this class is virtually abstract.
* But it cannot be declared abstract because it uses its own constructor.
*
*
* @author Jrme Euzenat, David Loup, Raphal Troncy
* @version $Id$
*/
......@@ -211,7 +211,7 @@ public class BasicAlignment implements Alignment {
return (String)namespaces.getParameter( label );
};
public Enumeration getElements() {
public Enumeration getElements() {
return new MEnumeration( hash1 );
}
......@@ -521,7 +521,21 @@ public class BasicAlignment implements Alignment {
*/
public Alignment compose(Alignment align) throws AlignmentException {
BasicAlignment result = new BasicAlignment();
result.init(onto1,onto2);
result.init(onto1,((BasicAlignment) align).getOntologyObject2());
// TODO type and level
// TODO extension
for ( Enumeration e = getElements() ; e.hasMoreElements(); ){
Cell c1 = (Cell) e.nextElement();
Set<Cell> cells2 = align.getAlignCells1(c1.getObject2());
if (cells2 !=null) {
for (Cell c2 : cells2) {
Cell newCell = c1.compose(c2);
if (newCell != null) {
result.addCell(newCell);
}
}
}
}
return result;
}
......
......@@ -7,19 +7,19 @@
* 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.impl;
package fr.inrialpes.exmo.align.impl;
import java.net.URI;
import java.util.Enumeration;
......@@ -33,10 +33,10 @@ import org.semanticweb.owl.align.Relation;
import org.semanticweb.owl.align.Parameters;
/**
* Represents an ontology alignment correspondence.
* Represents an ontology alignment correspondence.
*
* @author Jrme Euzenat
* @version $Id$
* @version $Id$
*/
public class BasicCell implements Cell, Comparable {
......@@ -50,11 +50,11 @@ public class BasicCell implements Cell, Comparable {
protected Object object2 = null;
protected Relation relation = null;
protected double strength = 0;
protected Parameters extensions = null;
protected Parameters extensions = null;
/** Creation **/
public BasicCell( String id, Object ob1, Object ob2, Relation rel, double m ) throws AlignmentException {
setId( id );
setId( id );
object1 = ob1;
object2 = ob2;
relation = rel;
......@@ -85,23 +85,23 @@ public class BasicCell implements Cell, Comparable {
public String getId(){ return id; };
public void setId( String id ){ this.id = id; };
public String getSemantics(){
public String getSemantics(){
if ( semantics != null ) { return semantics; }
else { return "first-order"; }
};
public void setSemantics( String sem ){ semantics = sem; };
public Object getObject1(){ return object1; };
public Object getObject2(){ return object2; };
public URI getObject1AsURI() throws AlignmentException {
public URI getObject1AsURI() throws AlignmentException {
if ( object1 instanceof URI ) {
return (URI)object1;
return (URI)object1;
} else {
throw new AlignmentException( "Cannot find URI for "+object1 );
}
}
public URI getObject2AsURI() throws AlignmentException {
public URI getObject2AsURI() throws AlignmentException {
if ( object2 instanceof URI ) {
return (URI)object2;
return (URI)object2;
} else {
throw new AlignmentException( "Cannot find URI for "+object2 );
}
......@@ -149,6 +149,14 @@ public class BasicCell implements Cell, Comparable {
return result;
}
public Cell compose(Cell c) throws AlignmentException {
if (!object2.equals(c.getObject1()) && relation.compose(c.getRelation())==null )
return null;
Cell result = (Cell)new BasicCell( (String)null, object1, c.getObject2(), relation.compose(c.getRelation()), strength*c.getStrength() );
// TODO : extension...
return result;
}
/** Housekeeping **/
public void dump( ContentHandler h ){};
......
......@@ -7,18 +7,18 @@
* 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.impl;
package fr.inrialpes.exmo.align.impl;
import fr.inrialpes.exmo.align.impl.rel.EquivRelation;
import fr.inrialpes.exmo.align.impl.rel.SubsumeRelation;
......@@ -39,7 +39,7 @@ import org.xml.sax.ContentHandler;
* Represents an ontology alignment relation.
*
* @author Jérôme Euzenat
* @version $Id$
* @version $Id$
*/
public class BasicRelation implements Relation
......@@ -95,6 +95,11 @@ public class BasicRelation implements Relation
return this;
}
/** By default...**/
public Relation compose(Relation r) {
return null;
}
/** Are the two relations equal **/
public boolean equals( Relation r ) {
if ( r instanceof BasicRelation ){
......
......@@ -6,21 +6,22 @@
* 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.impl.rel;
package fr.inrialpes.exmo.align.impl.rel;
import org.semanticweb.owl.align.AlignmentException;
import org.semanticweb.owl.align.AlignmentVisitor;
import org.semanticweb.owl.align.Relation;
import fr.inrialpes.exmo.align.impl.BasicRelation;
......@@ -28,7 +29,7 @@ import fr.inrialpes.exmo.align.impl.BasicRelation;
* Represents an OWL equivalence relation.
*
* @author Jérôme Euzenat
* @version $Id$
* @version $Id$
*/
public class EquivRelation extends BasicRelation
......@@ -45,6 +46,11 @@ public class EquivRelation extends BasicRelation
public EquivRelation(){
super("=");
}
public Relation compose(Relation r) {
return r;
}
}
......@@ -6,21 +6,22 @@
* 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.impl.rel;
package fr.inrialpes.exmo.align.impl.rel;
import org.semanticweb.owl.align.AlignmentException;
import org.semanticweb.owl.align.AlignmentVisitor;
import org.semanticweb.owl.align.Relation;
import fr.inrialpes.exmo.align.impl.BasicRelation;
......@@ -28,7 +29,7 @@ import fr.inrialpes.exmo.align.impl.BasicRelation;
* Represents an OWL equivalence relation.
*
* @author Jérôme Euzenat
* @version $Id$
* @version $Id$
*/
public class IncompatRelation extends BasicRelation
......@@ -45,6 +46,12 @@ public class IncompatRelation extends BasicRelation
public IncompatRelation(){
super("%");
}
public Relation compose(Relation r) {
if (r instanceof EquivRelation || r instanceof SubsumeRelation)
return this;
return null;
}
}
......@@ -47,6 +47,8 @@ public class NonTransitiveImplicationRelation extends BasicRelation
public NonTransitiveImplicationRelation(){
super("~>");
}
}
......@@ -6,29 +6,31 @@
* 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.impl.rel;
package fr.inrialpes.exmo.align.impl.rel;
import org.semanticweb.owl.align.AlignmentException;
import org.semanticweb.owl.align.AlignmentVisitor;
import org.semanticweb.owl.align.Relation;
import fr.inrialpes.exmo.align.impl.BasicRelation;
/**
* Represents an OWL subsumption relation.
*
* @author Jérôme Euzenat
* @version $Id$
* @version $Id$
*/
public class SubsumeRelation extends BasicRelation
......@@ -45,6 +47,13 @@ public class SubsumeRelation extends BasicRelation
public SubsumeRelation(){
super(">");
}
public Relation compose(Relation r) {
if (r.equals(this) || r instanceof EquivRelation)
return this;
return null;
}
}
......@@ -6,21 +6,22 @@
* 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.impl.rel;
package fr.inrialpes.exmo.align.impl.rel;
import org.semanticweb.owl.align.AlignmentException;
import org.semanticweb.owl.align.AlignmentVisitor;
import org.semanticweb.owl.align.Relation;
import fr.inrialpes.exmo.align.impl.BasicRelation;
......@@ -30,7 +31,7 @@ import java.io.PrintWriter;
* Represents an OWL subsumption relation.
*
* @author Jérôme Euzenat
* @version $Id$
* @version $Id$
*/
public class SubsumedRelation extends BasicRelation
......@@ -48,6 +49,14 @@ public class SubsumedRelation extends BasicRelation
super("<");
}
public Relation compose(Relation r) {
if (r.equals(this) || r instanceof EquivRelation)
return this;
else if (r instanceof IncompatRelation)
return r;
return null;
}
public void write( PrintWriter writer ) {
writer.print("&lt;");
}
......
......@@ -7,18 +7,18 @@
* 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 org.semanticweb.owl.align;
package org.semanticweb.owl.align;
import java.io.PrintStream;
import java.io.PrintWriter;
......@@ -36,7 +36,7 @@ import org.xml.sax.SAXException;
* about those objects.
*
* @author Jérôme Euzenat
* @version $Id$
* @version $Id$
*/
......@@ -72,6 +72,7 @@ public interface Cell
public void setExtension( String uri, String label, String value );
public Cell inverse() throws AlignmentException;
public Cell compose(Cell c) throws AlignmentException;
/** Housekeeping **/
public void dump(ContentHandler h);
......
......@@ -7,18 +7,18 @@
* 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 org.semanticweb.owl.align;
package org.semanticweb.owl.align;
import java.io.PrintWriter;
......@@ -27,7 +27,7 @@ import org.xml.sax.ContentHandler;
/**
*
* @author Jérôme Euzenat
* @version $Id$
* @version $Id$
*/
......@@ -37,6 +37,7 @@ public interface Relation
public void accept( AlignmentVisitor visitor ) throws AlignmentException;
public Relation inverse();
public Relation compose(Relation r);
public boolean equals( Relation r );
......
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