diff --git a/html/edoal.html b/html/edoal.html index 03ace90a5fdb5d57b5f9179e671b6c540552ed8b..f94b74d3cd6ee10251a80db2e4c5472a2d121224 100644 --- a/html/edoal.html +++ b/html/edoal.html @@ -924,7 +924,7 @@ They obey the following grammar: <div class="grammar"> <u>val</u> ::= <value> <u>value</u> </value> -<u>value</u> ::= <Literal {edoal:type=" <u>URI</u> "} edoal:string=" <u>STRING</u> " /> +<u>value</u> ::= <Literal {edoal:type=" <u>URI</u> "} {edoal:lang=" <u>LANG</u> "} edoal:string=" <u>STRING</u> " /> <!-- | <Literal {edoal:type=" <u>URI</u> "}> <u>STRING</u> </Literal> --> | <u>instexpr</u> | <u>attrexpr</u> | <Apply edoal:operator=" <u>URI</u> "> <arguments rdf:parseType="Collection"><u>value</u>*</arguments> </Apply> @@ -945,6 +945,7 @@ Literal values: <div class="rdfxml">RDF/XML Syntax</div> <div class="rdfxml"> <Literal edoal:type="&xsd;integer" edoal:string="123" /> + <Literal edoal:lang="fr" edoal:string="Administration" /> <!-- <Literal edoal:type="&xsd;integer">123</Literal>--> </div></div> <div class="n3Div"><div class="n3">N3 Syntax</div> @@ -952,6 +953,9 @@ Literal values: [] a <http://ns.inria.org/edoal/1.0/Literal> ; edoal:type "http://www.w3.org/2001/XMLSchema#integer" ; edoal:string "123" . +[] a <http://ns.inria.org/edoal/1.0/Literal> ; + edoal:lang "fr" ; + edoal:string "Administration" . </div></div> <p> diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/PropertyId.java b/src/fr/inrialpes/exmo/align/impl/edoal/PropertyId.java index c152a9849df0c297f5c570ba0c20b35f34f0fc3a..53f81885b922d54ed117b68827e9a046e65d249f 100644 --- a/src/fr/inrialpes/exmo/align/impl/edoal/PropertyId.java +++ b/src/fr/inrialpes/exmo/align/impl/edoal/PropertyId.java @@ -3,7 +3,7 @@ * * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck * Sourceforge version 1.7 - 2006 -- then AttributeExpr.java - * Copyright (C) INRIA, 2009-2010, 2012, 2016 + * Copyright (C) INRIA, 2009-2010, 2012, 2016-2017 * * 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 @@ -45,7 +45,7 @@ public class PropertyId extends PropertyExpression implements Id { URI uri; - String lang; + String lang = null; /** * Creates an anonymous property pattern diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/Value.java b/src/fr/inrialpes/exmo/align/impl/edoal/Value.java index 4e05b35f616f4e49b547e35f6d05043b64da4499..9c5889ee9ade930d510e8de7ef2ba248d6685025 100644 --- a/src/fr/inrialpes/exmo/align/impl/edoal/Value.java +++ b/src/fr/inrialpes/exmo/align/impl/edoal/Value.java @@ -3,7 +3,7 @@ * * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck * Sourceforge version 1.2 - 2006 - * Copyright (C) INRIA, 2009-2010, 2012 + * Copyright (C) INRIA, 2009-2010, 2012, 2017 * * 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 @@ -42,7 +42,10 @@ public class Value implements ValueExpression { //implements Cloneable, Visitabl private String value; /** The eventual type of the value */ - private URI type; + private URI type = null; + + /** The eventual language */ + private String lang = null; /** * Constructs an object with the given value. @@ -62,16 +65,15 @@ public class Value implements ValueExpression { //implements Cloneable, Visitabl } public Value( final String value, final URI type ) { - if (value == null) { - throw new NullPointerException("The value should not be null"); - } - if (type == null) { - throw new NullPointerException("The type is null"); - } - this.value = value; + this( value ); this.type = type; } + public Value( final String value, final URI type, final String lg ) { + this( value, type ); + this.lang = lg; + } + public void accept( EDOALVisitor visitor ) throws AlignmentException { visitor.visit(this); } @@ -87,8 +89,12 @@ public class Value implements ValueExpression { //implements Cloneable, Visitabl return type; } + public String getLang() { + return lang; + } + public int hashCode() { - return 5*value.hashCode(); + return 5*value.hashCode(); /*+lang.hashCode()+type.hashCode()*/ } public boolean equals(final Object o) { @@ -98,7 +104,7 @@ public class Value implements ValueExpression { //implements Cloneable, Visitabl if (!(o instanceof Value)) { return false; } - Value s = (Value) o; + Value s = (Value)o; return value.equals(s.value); } /* @@ -119,4 +125,10 @@ public class Value implements ValueExpression { //implements Cloneable, Visitabl public String toString() { return value; } + public String toRDFString() { + String result = "\""+value+"\""; + if ( lang != null ) result += "@"+lang; + else if ( type != null ) result += "^^"+type; + return value; + } } diff --git a/src/fr/inrialpes/exmo/align/impl/eval/SemPRecEvaluator.java b/src/fr/inrialpes/exmo/align/impl/eval/SemPRecEvaluator.java index 821b58d2724cc3da0a1da42e45d84e9f03c4a5a7..05919807da9791395f99009b0140514a3cd48519 100644 --- a/src/fr/inrialpes/exmo/align/impl/eval/SemPRecEvaluator.java +++ b/src/fr/inrialpes/exmo/align/impl/eval/SemPRecEvaluator.java @@ -99,8 +99,8 @@ import java.net.URI; */ public class SemPRecEvaluator extends PRecEvaluator implements Evaluator { - final static Logger logger = LoggerFactory.getLogger( SemPRecEvaluator.class ); + private int nbfoundentailed = 0; // nb of returned cells entailed by the reference alignment private int nbexpectedentailed = 0; // nb of reference cells entailed by returned alignment diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/GraphPatternRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/GraphPatternRendererVisitor.java index 10357b0e188fb11ff34a9838d0ec6b8e024a6a05..24dec262773ee4d0bffb1253e779b5dc91d3b1ba 100644 --- a/src/fr/inrialpes/exmo/align/impl/renderer/GraphPatternRendererVisitor.java +++ b/src/fr/inrialpes/exmo/align/impl/renderer/GraphPatternRendererVisitor.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2012-2016 + * Copyright (C) INRIA, 2012-2017 * * 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 @@ -480,13 +480,16 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito String id = registerPrefix( e.getURI() ); String temp = obj; if ( valueRestriction != null && !inClassRestriction && op != Constructor.COMP && flagRestriction ) { - obj = "\"" + valueRestriction.toString() + "\""; + obj = valueRestriction.toString(); } if ( flagRestriction && inClassRestriction ) { objectsRestriction.add(obj); } // createVarName(); //JE2014! strBGP += sub + " " + id + " " + obj + " ." + NL; + if ( e.getLanguage() != null ) { + strBGP += "FILTER ( langMatches( lang( "+obj+" ), \""+e.getLanguage()+"\" ) )"+NL; + } obj = temp; } } @@ -496,7 +499,7 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito //System.err.println( "P: < "+sub+", "+op+", "+obj+" >" ); if (op == Constructor.OR) { if ( valueRestriction != null && !inClassRestriction ) { - obj = "\"" + valueRestriction.toString() + "\""; + obj = valueRestriction.toString(); } int size = e.getComponents().size(); for ( final PathExpression re : e.getComponents() ) { @@ -512,7 +515,7 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito objectsRestriction.add( obj ); } else if (op == Constructor.AND) { if ( valueRestriction != null && !inClassRestriction ) { - obj = "\"" + valueRestriction.toString() + "\""; + obj = valueRestriction.toString(); } String temp = obj; rel = false; @@ -546,7 +549,7 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito // next object if (size == 0) { // last step if (valueRestriction != null && !inClassRestriction) { - obj = "\"" + valueRestriction.toString() + "\""; + obj = valueRestriction.toString(); } else { obj = tempObj; } // otherwise, generating intermediate variables... @@ -565,7 +568,7 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito } else { // JE2015: Unclear here! if (valueRestriction != null && !inClassRestriction) { - obj = "\"" + valueRestriction.toString() + "\""; + obj = valueRestriction.toString(); } int size = e.getComponents().size(); for (final PathExpression re : e.getComponents()) { @@ -809,11 +812,11 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito } public void visit( final Value e ) throws AlignmentException { - value = e.getValue(); if ( e.getType() != null ) uriType = registerPrefix( e.getType() ); //if ( e.getType() != null ) uriType = decodeDatatype( e.getType().toString() ); // JE2015: Not sure that this is really useful //if ( uriType != null && uriType.equals("") ) uriType = "xsd:string"; + value = e.toRDFString(); } public void visit(final Apply e) throws AlignmentException { diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java index 65090878a5c69849365d3929fe6c3c4e541519f5..7e58a58b1abf52ae17592a11f1584b79186a640d 100644 --- a/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java +++ b/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java @@ -707,6 +707,9 @@ public class RDFRendererVisitor extends IndentedRendererVisitor implements Align if (e.getType() != null) { output(SyntaxElement.ETYPE.print(DEF) + "=\"" + e.getType() + "\" "); } + if (e.getLang() != null) { + output(SyntaxElement.LANG.print(DEF) + "=\"" + e.getLang() + "\" "); + } output(SyntaxElement.STRING.print(DEF) + "=\"" + e.getValue() + "\"/>"); } diff --git a/src/fr/inrialpes/exmo/align/parser/RDFParser.java b/src/fr/inrialpes/exmo/align/parser/RDFParser.java index 189dfaa8833fc082879c794154067527ec7956ea..1908dc7b37bf9eb2771bcb120a34ce0903a916dd 100644 --- a/src/fr/inrialpes/exmo/align/parser/RDFParser.java +++ b/src/fr/inrialpes/exmo/align/parser/RDFParser.java @@ -172,7 +172,7 @@ public class RDFParser { // Initialize the syntax description initSyntax(); // Get the statement including alignment resource as rdf:type - StmtIterator stmtIt = rdfmodel.listStatements(null, RDF.type, (Resource) SyntaxElement.getResource("Alignment")); + StmtIterator stmtIt = rdfmodel.listStatements(null, RDF.type, (Resource)SyntaxElement.getResource("Alignment")); // Take the first one if it exists if (!stmtIt.hasNext()) { throw new AlignmentException("There is no alignment in the RDF document"); @@ -248,19 +248,19 @@ public class RDFParser { alignment.setExtension(Namespace.ALIGNMENT.uri, Annotations.ID, id.toString()); } - StmtIterator stmtIt = node.listProperties((Property) SyntaxElement.MAPPING_SOURCE.resource); + StmtIterator stmtIt = node.listProperties((Property)SyntaxElement.MAPPING_SOURCE.resource); if (stmtIt.hasNext()) { source = parseOntology(stmtIt.nextStatement().getResource()); } else { throw new AlignmentException("Missing ontology " + "onto1"); } - stmtIt = node.listProperties((Property) SyntaxElement.MAPPING_TARGET.resource); + stmtIt = node.listProperties((Property)SyntaxElement.MAPPING_TARGET.resource); if (stmtIt.hasNext()) { target = parseOntology(stmtIt.nextStatement().getResource()); } else { throw new AlignmentException("Missing ontology " + "onto2"); } - stmtIt = node.listProperties((Property) SyntaxElement.LEVEL.resource); + stmtIt = node.listProperties((Property)SyntaxElement.LEVEL.resource); if (stmtIt.hasNext()) { final String level = stmtIt.nextStatement().getString(); if ((level != null) && (!level.equals(""))) { @@ -279,7 +279,7 @@ public class RDFParser { } else { throw new AlignmentException("Missing level "); } - stmtIt = node.listProperties((Property) SyntaxElement.TYPE.resource); + stmtIt = node.listProperties((Property)SyntaxElement.TYPE.resource); if ( stmtIt.hasNext() ) { final String arity = stmtIt.nextStatement().getString(); if ((arity != null) && (!arity.equals(""))) { @@ -288,14 +288,14 @@ public class RDFParser { } else { throw new AlignmentException("Missing type "); } - stmtIt = node.listProperties((Property) SyntaxElement.RELATION_CLASS.resource); + stmtIt = node.listProperties((Property)SyntaxElement.RELATION_CLASS.resource); if ( stmtIt.hasNext() ) { final String reltype = stmtIt.nextStatement().getString(); if ( ( reltype != null ) && ( !reltype.equals("") ) ) { alignment.setRelationType( reltype ); } } - stmtIt = node.listProperties((Property) SyntaxElement.CONFIDENCE_CLASS.resource); + stmtIt = node.listProperties((Property)SyntaxElement.CONFIDENCE_CLASS.resource); if ( stmtIt.hasNext() ) { final String conftype = stmtIt.nextStatement().getString(); if ( ( conftype != null ) && ( !conftype.equals("") ) ) { @@ -309,7 +309,7 @@ public class RDFParser { throw new IllegalArgumentException("Missing ontology description"); } - stmtIt = node.listProperties((Property) SyntaxElement.MAP.resource); + stmtIt = node.listProperties((Property)SyntaxElement.MAP.resource); while (stmtIt.hasNext()) { Statement stmt = stmtIt.nextStatement(); //logger.trace( " ---------------> {}", stmt ); @@ -375,10 +375,10 @@ public class RDFParser { throw new AlignmentException("The Ontology node must not be null"); } try { - Resource formu = node.getProperty((Property) SyntaxElement.FORMATT.resource).getResource(); - final String formalismName = formu.getProperty((Property) SyntaxElement.NAME.resource).getString(); - final String formalismUri = formu.getProperty((Property) SyntaxElement.URI.resource).getString(); - final Statement location = node.getProperty((Property) SyntaxElement.LOCATION.resource); + Resource formu = node.getProperty((Property)SyntaxElement.FORMATT.resource).getResource(); + final String formalismName = formu.getProperty((Property)SyntaxElement.NAME.resource).getString(); + final String formalismUri = formu.getProperty((Property)SyntaxElement.URI.resource).getString(); + final Statement location = node.getProperty((Property)SyntaxElement.LOCATION.resource); Ontology<Object> onto = new BasicOntology<Object>(); onto.setURI(new URI(node.getURI())); onto.setFormURI(new URI(formalismUri)); @@ -406,13 +406,13 @@ public class RDFParser { } try { // Get the relation - Statement st = node.getProperty((Property) SyntaxElement.RULE_RELATION.resource); + Statement st = node.getProperty((Property)SyntaxElement.RULE_RELATION.resource); if (st == null) { throw new AlignmentException("Correspondence must contain a relation" + node.getLocalName()); } final String relation = st.getString(); // Get the confidence - st = node.getProperty((Property) SyntaxElement.MEASURE.resource); + st = node.getProperty((Property)SyntaxElement.MEASURE.resource); if (st == null) { throw new AlignmentException("Correspondence must contain a measure" + node.getLocalName()); } @@ -421,7 +421,7 @@ public class RDFParser { final String id = node.getURI(); // parsing the entity1 and entity2 // Testing that there are several entities, allows to find duplicate ids - StmtIterator statements = node.listProperties((Property) SyntaxElement.ENTITY1.resource); + StmtIterator statements = node.listProperties((Property)SyntaxElement.ENTITY1.resource); if ( !statements.hasNext() ) throw new AlignmentException("Correspondence must contain one entity1" + node ); Resource entity1 = statements.nextStatement().getResource(); @@ -429,7 +429,7 @@ public class RDFParser { throw new AlignmentException("Correspondence must contain exactly one entity1" + node ); } - statements = node.listProperties((Property) SyntaxElement.ENTITY2.resource); + statements = node.listProperties((Property)SyntaxElement.ENTITY2.resource); if ( !statements.hasNext() ) { throw new AlignmentException("Correspondence must contain one entity2" + node ); } @@ -451,7 +451,7 @@ public class RDFParser { EDOALCell cell = alignment.addAlignCell( id, s, t, relation, m ); // Parse the possible transformations - StmtIterator stmtIt = node.listProperties((Property) SyntaxElement.TRANSFORMATION.resource); + StmtIterator stmtIt = node.listProperties((Property)SyntaxElement.TRANSFORMATION.resource); while (stmtIt.hasNext()) { Statement stmt = stmtIt.nextStatement(); try { @@ -463,7 +463,7 @@ public class RDFParser { } // Parse the linkkeys - stmtIt = node.listProperties((Property) SyntaxElement.LINKKEYS.resource); + stmtIt = node.listProperties((Property)SyntaxElement.LINKKEYS.resource); while (stmtIt.hasNext()) { Statement stmt = stmtIt.nextStatement(); //logger.trace( " ---------------> {}", stmt ); @@ -490,14 +490,14 @@ public class RDFParser { } try { // parsing type - Statement stmt = node.getProperty((Property) SyntaxElement.TRDIR.resource); + Statement stmt = node.getProperty((Property)SyntaxElement.TRDIR.resource); if (stmt == null) { throw new AlignmentException("Required " + SyntaxElement.TRDIR.print() + " property in Transformation"); } String type = stmt.getLiteral().toString(); // parsing entity1 and entity2 - Resource entity1 = node.getProperty((Property) SyntaxElement.TRENT1.resource).getResource(); - Resource entity2 = node.getProperty((Property) SyntaxElement.TRENT2.resource).getResource(); + Resource entity1 = node.getProperty((Property)SyntaxElement.TRENT1.resource).getResource(); + Resource entity2 = node.getProperty((Property)SyntaxElement.TRENT2.resource).getResource(); ValueExpression s = parseValue(entity1); ValueExpression t = parseValue(entity2); //logger.trace(" (Transf)s : {}", s); @@ -515,7 +515,7 @@ public class RDFParser { try { Linkkey linkkey = new Linkkey(); //Parsing bindings - StmtIterator stmtIt = node.listProperties((Property) SyntaxElement.LINKKEY_BINDING.resource); + StmtIterator stmtIt = node.listProperties((Property)SyntaxElement.LINKKEY_BINDING.resource); while (stmtIt.hasNext()) { Statement bindingStmt = stmtIt.nextStatement(); linkkey.addBinding(parseLinkkeyBinding(bindingStmt.getResource())); @@ -539,8 +539,8 @@ public class RDFParser { throw new NullPointerException("The node must not be null"); } try { - Statement property1Stmt = node.getProperty((Property) SyntaxElement.LINKEY_PROPERTY1.resource); - Statement property2Stmt = node.getProperty((Property) SyntaxElement.LINKEY_PROPERTY2.resource); + Statement property1Stmt = node.getProperty((Property)SyntaxElement.LINKEY_PROPERTY1.resource); + Statement property2Stmt = node.getProperty((Property)SyntaxElement.LINKEY_PROPERTY2.resource); if (property1Stmt == null || property2Stmt == null) { throw new AlignmentException("Required " + SyntaxElement.LINKEY_PROPERTY1.print() + " and " + SyntaxElement.LINKEY_PROPERTY2.print() + " properties in Linkkey binding corresp."); } @@ -585,7 +585,7 @@ public class RDFParser { throw new AlignmentException("There is no parser for entity " + rdfType.getLocalName()); } if (isPattern) { - StmtIterator stmtIt = node.listProperties((Property) SyntaxElement.VAR.resource); + StmtIterator stmtIt = node.listProperties((Property)SyntaxElement.VAR.resource); if (stmtIt.hasNext()) { final String varname = stmtIt.nextStatement().getString(); final Variable var = alignment.recordVariable(varname, result); @@ -609,16 +609,16 @@ public class RDFParser { // Using a List preserves the order... useful mostly for COMPOSE // Given the Jena encoding of Collection, LinkedList seems the best List<ClassExpression> clexpr = new LinkedList<ClassExpression>(); - if (node.hasProperty((Property) SyntaxElement.AND.resource)) { + if (node.hasProperty((Property)SyntaxElement.AND.resource)) { op = SyntaxElement.AND.getOperator(); // listProperties would give them all - stmt = node.getProperty((Property) SyntaxElement.AND.resource); - } else if (node.hasProperty((Property) SyntaxElement.OR.resource)) { + stmt = node.getProperty((Property)SyntaxElement.AND.resource); + } else if (node.hasProperty((Property)SyntaxElement.OR.resource)) { op = SyntaxElement.OR.getOperator(); - stmt = node.getProperty((Property) SyntaxElement.OR.resource); - } else if (node.hasProperty((Property) SyntaxElement.NOT.resource)) { + stmt = node.getProperty((Property)SyntaxElement.OR.resource); + } else if (node.hasProperty((Property)SyntaxElement.NOT.resource)) { op = SyntaxElement.NOT.getOperator(); - stmt = node.getProperty((Property) SyntaxElement.NOT.resource); + stmt = node.getProperty((Property)SyntaxElement.NOT.resource); } else { if (isPattern) { // not necessarily with a variable (real patterns) return new ClassId(); @@ -660,7 +660,7 @@ public class RDFParser { PathExpression pe; Comparator comp; // Find onAttribute - Statement stmt = node.getProperty((Property) SyntaxElement.ONPROPERTY.resource); + Statement stmt = node.getProperty((Property)SyntaxElement.ONPROPERTY.resource); if (stmt == null) { throw new AlignmentException("Required edoal:onAttribute property"); } @@ -668,19 +668,19 @@ public class RDFParser { if (rdfType.equals(SyntaxElement.TYPE_COND.resource)) { // Check that pe is a Property / Relation // ==> different treatment - stmt = node.getProperty((Property) SyntaxElement.EDATATYPE.resource); + stmt = node.getProperty((Property)SyntaxElement.EDATATYPE.resource); if (stmt == null) { throw new AlignmentException("Required " + SyntaxElement.EDATATYPE.print() + " property"); } return new ClassTypeRestriction(pe, parseDatatype(stmt.getObject())); } else if (rdfType.equals(SyntaxElement.DOMAIN_RESTRICTION.resource)) { - if ((stmt = node.getProperty((Property) SyntaxElement.TOCLASS.resource)) != null || (stmt = node.getProperty((Property) SyntaxElement.ALL.resource)) != null) { + if ((stmt = node.getProperty((Property)SyntaxElement.TOCLASS.resource)) != null || (stmt = node.getProperty((Property)SyntaxElement.ALL.resource)) != null) { RDFNode nn = stmt.getObject(); if (!nn.isResource()) { throw new AlignmentException("Incorrect class expression " + nn); } return new ClassDomainRestriction(pe, true, parseClass((Resource) nn)); - } else if ((stmt = node.getProperty((Property) SyntaxElement.EXISTS.resource)) != null) { + } else if ((stmt = node.getProperty((Property)SyntaxElement.EXISTS.resource)) != null) { RDFNode nn = stmt.getObject(); if (!nn.isResource()) { throw new AlignmentException("Incorrect class expression " + nn); @@ -691,7 +691,7 @@ public class RDFParser { } } else { // It is a Value or Occurence restruction // Find comparator - stmt = node.getProperty((Property) SyntaxElement.COMPARATOR.resource); + stmt = node.getProperty((Property)SyntaxElement.COMPARATOR.resource); if (stmt == null) { throw new AlignmentException("Required edoal:comparator property"); } @@ -702,7 +702,7 @@ public class RDFParser { throw new AlignmentException("edoal:comparator requires a URI"); } if (rdfType.equals(SyntaxElement.OCCURENCE_COND.resource)) { - stmt = node.getProperty((Property) SyntaxElement.VALUE.resource); + stmt = node.getProperty((Property)SyntaxElement.VALUE.resource); if (stmt == null) { throw new AlignmentException("Required edoal:value property"); } @@ -713,7 +713,7 @@ public class RDFParser { throw new AlignmentException("Bad occurence specification : " + nn); } } else if (rdfType.equals(SyntaxElement.VALUE_COND.resource)) { - stmt = node.getProperty((Property) SyntaxElement.VALUE.resource); + stmt = node.getProperty((Property)SyntaxElement.VALUE.resource); if (stmt == null) { throw new AlignmentException("Required edoal:value property"); } @@ -752,25 +752,25 @@ public class RDFParser { URI id = getNodeId(node); if (id != null) { PropertyId prop = new PropertyId(id); - if (node.hasProperty((Property) SyntaxElement.LANG.resource)) { + if (node.hasProperty((Property)SyntaxElement.LANG.resource)) { prop.setLanguage( node.getProperty((Property)SyntaxElement.LANG.resource).getLiteral().getString() ); } return prop; } else { Constructor op = null; List<PathExpression> clexpr = new LinkedList<PathExpression>(); - if (node.hasProperty((Property) SyntaxElement.AND.resource)) { + if (node.hasProperty((Property)SyntaxElement.AND.resource)) { op = SyntaxElement.AND.getOperator(); - stmt = node.getProperty((Property) SyntaxElement.AND.resource); - } else if (node.hasProperty((Property) SyntaxElement.OR.resource)) { + stmt = node.getProperty((Property)SyntaxElement.AND.resource); + } else if (node.hasProperty((Property)SyntaxElement.OR.resource)) { op = SyntaxElement.OR.getOperator(); - stmt = node.getProperty((Property) SyntaxElement.OR.resource); - } else if (node.hasProperty((Property) SyntaxElement.COMPOSE.resource)) { + stmt = node.getProperty((Property)SyntaxElement.OR.resource); + } else if (node.hasProperty((Property)SyntaxElement.COMPOSE.resource)) { op = SyntaxElement.COMPOSE.getOperator(); - stmt = node.getProperty((Property) SyntaxElement.COMPOSE.resource); - } else if (node.hasProperty((Property) SyntaxElement.NOT.resource)) { + stmt = node.getProperty((Property)SyntaxElement.COMPOSE.resource); + } else if (node.hasProperty((Property)SyntaxElement.NOT.resource)) { op = SyntaxElement.NOT.getOperator(); - stmt = node.getProperty((Property) SyntaxElement.NOT.resource); + stmt = node.getProperty((Property)SyntaxElement.NOT.resource); } else { if (isPattern) { // not necessarily with a variable (real patterns) return new PropertyId(); @@ -818,7 +818,7 @@ public class RDFParser { return new PropertyConstruction(op, clexpr); } } else if (rdfType.equals(SyntaxElement.PROPERTY_DOMAIN_COND.resource)) { - stmt = node.getProperty((Property) SyntaxElement.TOCLASS.resource); + stmt = node.getProperty((Property)SyntaxElement.TOCLASS.resource); if (stmt == null) { throw new AlignmentException("Required edoal:toClass property"); } @@ -829,14 +829,14 @@ public class RDFParser { throw new AlignmentException("Incorrect class expression " + nn); } } else if (rdfType.equals(SyntaxElement.PROPERTY_TYPE_COND.resource)) { - stmt = node.getProperty((Property) SyntaxElement.EDATATYPE.resource); + stmt = node.getProperty((Property)SyntaxElement.EDATATYPE.resource); if (stmt == null) { throw new AlignmentException("Required " + SyntaxElement.EDATATYPE.print() + " property"); } return new PropertyTypeRestriction(parseDatatype(stmt.getObject())); } else if (rdfType.equals(SyntaxElement.PROPERTY_VALUE_COND.resource)) { // Find comparator - stmt = node.getProperty((Property) SyntaxElement.COMPARATOR.resource); + stmt = node.getProperty((Property)SyntaxElement.COMPARATOR.resource); if (stmt == null) { throw new AlignmentException("Required edoal:comparator property"); } @@ -845,7 +845,7 @@ public class RDFParser { throw new AlignmentException("edoal:comparator requires and URI"); } Comparator comp = Comparator.getComparator(id); - stmt = node.getProperty((Property) SyntaxElement.VALUE.resource); + stmt = node.getProperty((Property)SyntaxElement.VALUE.resource); if (stmt == null) { throw new AlignmentException("Required edoal:value property"); } @@ -884,30 +884,30 @@ public class RDFParser { Constructor op = null; // Remains a PathExpression (that this is a relation is checked by typing) List<RelationExpression> clexpr = new LinkedList<RelationExpression>(); - if (node.hasProperty((Property) SyntaxElement.AND.resource)) { + if (node.hasProperty((Property)SyntaxElement.AND.resource)) { op = SyntaxElement.AND.getOperator(); - stmt = node.getProperty((Property) SyntaxElement.AND.resource); - } else if (node.hasProperty((Property) SyntaxElement.OR.resource)) { + stmt = node.getProperty((Property)SyntaxElement.AND.resource); + } else if (node.hasProperty((Property)SyntaxElement.OR.resource)) { op = SyntaxElement.OR.getOperator(); - stmt = node.getProperty((Property) SyntaxElement.OR.resource); - } else if (node.hasProperty((Property) SyntaxElement.COMPOSE.resource)) { + stmt = node.getProperty((Property)SyntaxElement.OR.resource); + } else if (node.hasProperty((Property)SyntaxElement.COMPOSE.resource)) { op = SyntaxElement.COMPOSE.getOperator(); - stmt = node.getProperty((Property) SyntaxElement.COMPOSE.resource); - } else if (node.hasProperty((Property) SyntaxElement.NOT.resource)) { + stmt = node.getProperty((Property)SyntaxElement.COMPOSE.resource); + } else if (node.hasProperty((Property)SyntaxElement.NOT.resource)) { op = SyntaxElement.NOT.getOperator(); - stmt = node.getProperty((Property) SyntaxElement.NOT.resource); - } else if (node.hasProperty((Property) SyntaxElement.INVERSE.resource)) { + stmt = node.getProperty((Property)SyntaxElement.NOT.resource); + } else if (node.hasProperty((Property)SyntaxElement.INVERSE.resource)) { op = SyntaxElement.INVERSE.getOperator(); - stmt = node.getProperty((Property) SyntaxElement.INVERSE.resource); - } else if (node.hasProperty((Property) SyntaxElement.REFLEXIVE.resource)) { + stmt = node.getProperty((Property)SyntaxElement.INVERSE.resource); + } else if (node.hasProperty((Property)SyntaxElement.REFLEXIVE.resource)) { op = SyntaxElement.REFLEXIVE.getOperator(); - stmt = node.getProperty((Property) SyntaxElement.REFLEXIVE.resource); - } else if (node.hasProperty((Property) SyntaxElement.SYMMETRIC.resource)) { + stmt = node.getProperty((Property)SyntaxElement.REFLEXIVE.resource); + } else if (node.hasProperty((Property)SyntaxElement.SYMMETRIC.resource)) { op = SyntaxElement.SYMMETRIC.getOperator(); - stmt = node.getProperty((Property) SyntaxElement.SYMMETRIC.resource); - } else if (node.hasProperty((Property) SyntaxElement.TRANSITIVE.resource)) { + stmt = node.getProperty((Property)SyntaxElement.SYMMETRIC.resource); + } else if (node.hasProperty((Property)SyntaxElement.TRANSITIVE.resource)) { op = SyntaxElement.TRANSITIVE.getOperator(); - stmt = node.getProperty((Property) SyntaxElement.TRANSITIVE.resource); + stmt = node.getProperty((Property)SyntaxElement.TRANSITIVE.resource); } else { if (isPattern) { // not necessarily with a variable (real patterns) return new RelationId(); @@ -944,7 +944,7 @@ public class RDFParser { return new RelationConstruction(op, clexpr); } } else if (rdfType.equals(SyntaxElement.RELATION_DOMAIN_COND.resource)) { - stmt = node.getProperty((Property) SyntaxElement.TOCLASS.resource); + stmt = node.getProperty((Property)SyntaxElement.TOCLASS.resource); if (stmt == null) { throw new AlignmentException("Required edoal:toClass property"); } @@ -955,7 +955,7 @@ public class RDFParser { throw new AlignmentException("Incorrect class expression " + nn); } } else if (rdfType.equals(SyntaxElement.RELATION_CODOMAIN_COND.resource)) { - stmt = node.getProperty((Property) SyntaxElement.TOCLASS.resource); + stmt = node.getProperty((Property)SyntaxElement.TOCLASS.resource); if (stmt == null) { throw new AlignmentException("Required edoal:toClass property"); } @@ -994,29 +994,29 @@ public class RDFParser { if (nodeType.equals(SyntaxElement.INSTANCE_EXPR.resource)) { return parseInstance((Resource) node); } else if (nodeType.equals(SyntaxElement.LITERAL.resource)) { - if (((Resource) node).hasProperty((Property) SyntaxElement.STRING.resource)) { + if (((Resource) node).hasProperty((Property)SyntaxElement.STRING.resource)) { URI u = null; - if (((Resource) node).hasProperty((Property) SyntaxElement.ETYPE.resource)) { + if (((Resource) node).hasProperty((Property)SyntaxElement.ETYPE.resource)) { try { - u = new URI(((Resource) node).getProperty((Property) SyntaxElement.ETYPE.resource).getLiteral().getString()); + u = new URI(((Resource) node).getProperty((Property)SyntaxElement.ETYPE.resource).getLiteral().getString()); } catch (URISyntaxException urisex) { //throw new AlignmentException( "Incorect URI for edoal:type : "+ ((Resource)node).getProperty( (Property)SyntaxElement.TYPE.resource ).getLiteral().getString() ); logger.debug("IGNORED Exception", urisex); } } - if (u != null) { - return new Value(((Resource) node).getProperty((Property) SyntaxElement.STRING.resource).getLiteral().getString(), u); - } else { - return new Value(((Resource) node).getProperty((Property) SyntaxElement.STRING.resource).getLiteral().getString()); - } - } else { + String lang = null; + if (((Resource) node).hasProperty((Property)SyntaxElement.LANG.resource)) { + lang = ((Resource) node).getProperty((Property)SyntaxElement.LANG.resource).getLiteral().getString(); + } + return new Value(((Resource) node).getProperty((Property)SyntaxElement.STRING.resource).getLiteral().getString(), u, lang); + } else { throw new AlignmentException("edoal:Literal requires a edoal:value"); } } else if (nodeType.equals(SyntaxElement.APPLY.resource)) { // Get the operation URI op; - if (((Resource) node).hasProperty((Property) SyntaxElement.OPERATOR.resource)) { - String operation = ((Resource) node).getProperty((Property) SyntaxElement.OPERATOR.resource).getLiteral().getString(); + if (((Resource) node).hasProperty((Property)SyntaxElement.OPERATOR.resource)) { + String operation = ((Resource) node).getProperty((Property)SyntaxElement.OPERATOR.resource).getLiteral().getString(); try { op = new URI(operation); } catch (URISyntaxException e) { @@ -1027,8 +1027,8 @@ public class RDFParser { } // Get all arguments List<ValueExpression> valexpr = new LinkedList<ValueExpression>(); - if (((Resource) node).hasProperty((Property) SyntaxElement.ARGUMENTS.resource)) { - Statement stmt = ((Resource) node).getProperty((Property) SyntaxElement.ARGUMENTS.resource); + if (((Resource) node).hasProperty((Property)SyntaxElement.ARGUMENTS.resource)) { + Statement stmt = ((Resource) node).getProperty((Property)SyntaxElement.ARGUMENTS.resource); Resource coll = stmt.getResource(); // MUSTCHECK while (!RDF.nil.getURI().equals(coll.getURI())) { valexpr.add(parseValue(coll.getProperty(RDF.first).getResource())); @@ -1039,8 +1039,8 @@ public class RDFParser { } else if (nodeType.equals(SyntaxElement.AGGREGATE.resource)) { // Get the operation URI op; - if (((Resource) node).hasProperty((Property) SyntaxElement.OPERATOR.resource)) { - String operation = ((Resource) node).getProperty((Property) SyntaxElement.OPERATOR.resource).getLiteral().getString(); + if (((Resource) node).hasProperty((Property)SyntaxElement.OPERATOR.resource)) { + String operation = ((Resource) node).getProperty((Property)SyntaxElement.OPERATOR.resource).getLiteral().getString(); try { op = new URI(operation); } catch (URISyntaxException e) { @@ -1051,8 +1051,8 @@ public class RDFParser { } // Get all arguments List<ValueExpression> valexpr = new LinkedList<ValueExpression>(); - if (((Resource) node).hasProperty((Property) SyntaxElement.ARGUMENTS.resource)) { - Statement stmt = ((Resource) node).getProperty((Property) SyntaxElement.ARGUMENTS.resource); + if (((Resource) node).hasProperty((Property)SyntaxElement.ARGUMENTS.resource)) { + Statement stmt = ((Resource) node).getProperty((Property)SyntaxElement.ARGUMENTS.resource); Resource coll = stmt.getResource(); // MUSTCHECK while (!RDF.nil.getURI().equals(coll.getURI())) { valexpr.add(parseValue(coll.getProperty(RDF.first).getResource())); diff --git a/test/input/intersects_people_1.rdf b/test/input/intersects_people_1.rdf index 8ec5a32b023c4a8ce957f0a7e94c7f3a60245f83..dbb5870b9130f05fd0402d7a52e036d74f9b8970 100644 --- a/test/input/intersects_people_1.rdf +++ b/test/input/intersects_people_1.rdf @@ -22,9 +22,9 @@ <!-- INTERSECTS + EQUALS for (nom, givenName) / Intersects for (connait, knows)--> <rdf:Description rdf:about="http://exmo.inrialpes.fr/connectors-data/people#alice_c1_1"> <rdf:type rdf:resource="&exmo;Personne"/> - <exmo:nom>AliceC1</exmo:nom> - <exmo:nom>AliceC1_1</exmo:nom> - <exmo:nom>AliceC1_2</exmo:nom> + <exmo:nom xml:lang="fr">AliceC1</exmo:nom> + <exmo:nom xml:lang="fr">AliceC1_1</exmo:nom> + <exmo:nom xml:lang="fr">AliceC1_2</exmo:nom> <exmo:connait>AliceC3_1_diff</exmo:connait> <exmo:connait>AliceC2_1_diff</exmo:connait> <exmo:boitemel>alice1@gmail.com</exmo:boitemel> @@ -34,9 +34,9 @@ <!-- INTERSECTS on AliceC2 for (nom, givenName) / Equals + INTERSECTS for (connait, knows)--> <rdf:Description rdf:about="http://exmo.inrialpes.fr/connectors-data/people#alice_c2_1"> <rdf:type rdf:resource="&exmo;Personne"/> - <exmo:nom>AliceC2</exmo:nom> - <exmo:nom>AliceC2_1</exmo:nom> - <exmo:nom>AliceC2_2</exmo:nom> + <exmo:nom xml:lang="fr">AliceC2</exmo:nom> + <exmo:nom xml:lang="fr">AliceC2_1</exmo:nom> + <exmo:nom xml:lang="fr">AliceC2_2</exmo:nom> <exmo:connait>AliceC3_1_diff</exmo:connait> <exmo:connait>AliceC4_1_diff</exmo:connait> <exmo:boitemel>alice1@gmail.com</exmo:boitemel> @@ -45,12 +45,12 @@ <rdf:Description rdf:about="http://exmo.inrialpes.fr/connectors-data/people#alice_c3_1"><!-- NOTHING --> <rdf:type rdf:resource="&exmo;Personne"/> - <exmo:nom>AliceC3_1</exmo:nom> - <exmo:nom>AliceC3_2</exmo:nom> - <exmo:nom>AliceC3_3</exmo:nom> - <exmo:nom>AliceC3_4</exmo:nom> - <exmo:nom>AliceC3_5</exmo:nom> - <exmo:nom>AliceC3_6</exmo:nom> + <exmo:nom xml:lang="fr">AliceC3_1</exmo:nom> + <exmo:nom xml:lang="fr">AliceC3_2</exmo:nom> + <exmo:nom xml:lang="fr">AliceC3_3</exmo:nom> + <exmo:nom xml:lang="fr">AliceC3_4</exmo:nom> + <exmo:nom xml:lang="fr">AliceC3_5</exmo:nom> + <exmo:nom xml:lang="fr">AliceC3_6</exmo:nom> <exmo:boitemel>alice1@gmail.com</exmo:boitemel> <exmo:boitemel>alice1@msn.com</exmo:boitemel> </rdf:Description> @@ -60,7 +60,7 @@ <rdf:Description rdf:about="http://exmo.inrialpes.fr/connectors-data/people#ivan_1"><!-- UNIQ --> <rdf:type rdf:resource="&exmo;Personne"/> - <exmo:nom>Ivan1</exmo:nom> + <exmo:nom xml:lang="fr">Ivan1</exmo:nom> <exmo:boitemel>ivan@gmail.com</exmo:boitemel> </rdf:Description> diff --git a/test/input/people_intersects_alignment.rdf b/test/input/people_intersects_alignment.rdf index e6f6a49e7ae473e291cf7938359c8f429f439039..aab5770115e3c231e89977f4586860912c2fd1ba 100644 --- a/test/input/people_intersects_alignment.rdf +++ b/test/input/people_intersects_alignment.rdf @@ -49,7 +49,7 @@ <edoal:binding> <edoal:Intersects> <edoal:property1> - <edoal:Property rdf:about="http://exmo.inrialpes.fr/connectors-core/nom" /> + <edoal:Property edoal:lang="fr" rdf:about="http://exmo.inrialpes.fr/connectors-core/nom" /> </edoal:property1> <edoal:property2> <edoal:Property rdf:about="http://xmlns.com/foaf/0.1/givenName" />