diff --git a/docs/user_manual/configuration_file/index.md b/docs/user_manual/configuration_file/index.md
index 9c3a0692b..bca1aea05 100644
--- a/docs/user_manual/configuration_file/index.md
+++ b/docs/user_manual/configuration_file/index.md
@@ -65,6 +65,27 @@ Optional properties can be set to segment the requested dataset.
* The graph of the endpoint can be specified directly ofter the `ENDPOINT` tag using the `GRAPH` tag.
* The limits of the query can be set with the `MINOFFSET` and `MAXOFFSET` tags directly after the `PAGESIZE` tag. The resulting query will ask about the statements in the interval [`MINOFFSET`, `MAXOFFSET`]. Note that `MINOFFSET` must be smaller than `MAXOFFSET`! If both `SOURCE` and `TARGET` are restricted, a warning is generated.
+Please note that LIMES does not allow namespace IRIs to be used in the `PROPERTY`, `RESTRICTION`, and `OPTIONAL_PROPERTY` tag. Please use namespace prefixes and reference the namespace IRI using a prefix. Example: Do not use
+```
+
+```
+instead use the following
+```
+
+ http://xmlns.com/foaf/0.1/
+
+
+
+```
+
### Preprocessing Functions
#### Simple
diff --git a/docs/user_manual/running_limes.md b/docs/user_manual/running_limes.md
index 41e6832b3..b42f6b782 100644
--- a/docs/user_manual/running_limes.md
+++ b/docs/user_manual/running_limes.md
@@ -136,7 +136,8 @@ The Prefixes component consists of two parts:
The Data source and data target consists of the two similar components, which include three input fields:
* *Sparql endpoint/Local file*: One of two options can be chosen. Sparql endpoint means that the user will select the endpont from the list. Local file means that the file should be provided as an endpoint.
-* *Endpoint*: A dropdown list of available endpoints. Moreover, the user can try to search for the endpoint, typing it in the input field or write your own endpoint. After clicking on the endpoint from the list or writing it by hand and press the Enter, the user will get the list of restriction classes according to this endpoint.
+* *Endpoint*: A dropdown list of available endpoints. Moreover, the user can try to search for the endpoint, typing it in the input field or write your own endpoint. After clicking on the endpoint from the list or writing it by hand and press the Enter, the user will get the list of restriction classes according to this endpoint.
+ In case you want to upload a configuration file as well as a data source and a target file, you must upload the configuration file prior to uploading the data source and target files.
* *Restriction*: Contains of three parameters splitted by space (?s rdf:type some:Type). The third parameter will be changed automatically after changing the restriction class.
* *Restriction class*: A dropdown list of restriction classes according to the endpoint. You can start typing the name of the class and the list will be filtered automatically. After choosing the restriction class, you will get all the properties related to this class.
diff --git a/limes-core/pom.xml b/limes-core/pom.xml
index 0d4f63754..f5a633bc3 100644
--- a/limes-core/pom.xml
+++ b/limes-core/pom.xml
@@ -16,7 +16,7 @@
org.aksw.limeslimes-full
- 1.8.0-SNAPSHOT
+ 1.8.1-SNAPSHOT4.0.0
diff --git a/limes-core/src/main/java/org/aksw/limes/core/io/config/reader/AConfigurationReader.java b/limes-core/src/main/java/org/aksw/limes/core/io/config/reader/AConfigurationReader.java
index 24ff38715..e5cdb484f 100644
--- a/limes-core/src/main/java/org/aksw/limes/core/io/config/reader/AConfigurationReader.java
+++ b/limes-core/src/main/java/org/aksw/limes/core/io/config/reader/AConfigurationReader.java
@@ -18,6 +18,9 @@
package org.aksw.limes.core.io.config.reader;
import org.aksw.limes.core.io.config.Configuration;
+import org.aksw.limes.core.io.config.KBInfo;
+
+import java.util.*;
/**
* @author Mohamed Sherif (sherif@informatik.uni-leipzig.de)
@@ -48,5 +51,78 @@ public void setConfiguration(Configuration configuration) {
this.configuration = configuration;
}
+ /**
+ * This method replaces any URIs used in the kbInfo with their prefixes
+ * @param info
+ */
+ public static void replaceURIsWithPrefixes(KBInfo info) {
+ Map prefixes = info.getPrefixes();
+ HashMap rev = new HashMap<>();
+ for(Map.Entry entry : prefixes.entrySet()) {
+ rev.put(entry.getValue(), entry.getKey());
+ }
+ info.setProperties(replaceURIsWithPrefixes(info.getProperties(), rev));
+ info.setOptionalProperties(replaceURIsWithPrefixes(info.getOptionalProperties(), rev));
+ info.setRestrictions(replaceURIsWithPrefixes(info.getRestrictions(), rev));
+ info.setFunctions(replaceURIsWithPrefixes(info.getFunctions(), rev));
+ }
+
+ private static ArrayList replaceURIsWithPrefixes(Collection props, HashMap rev) {
+ ArrayList replacements = new ArrayList<>();
+ for (String property : props) {
+ String originalProp = property;
+ for (Map.Entry prefixEntry : rev.entrySet()) {
+ if(property.contains(prefixEntry.getKey())){
+ property = property.replace(prefixEntry.getKey(), prefixEntry.getValue() + ":");
+ }
+ }
+ replacements.add(property);
+
+ if(property.contains("://")){
+ throw new IllegalArgumentException("LIMES does not support using URIs in the properties, optionalProperties, restrictions, or functions in the configuration file. " +
+ "Please define a prefix and use the prefix for the following URI: " + originalProp);
+ }
+ }
+ return replacements;
+ }
+
+ private static LinkedHashMap> replaceURIsWithPrefixes(Map> funcs, HashMap rev) {
+ LinkedHashMap> replacements = new LinkedHashMap<>();
+ for (Map.Entry> entry : funcs.entrySet()) {
+ String property = entry.getKey();
+ String originalProp = property;
+
+ //Replace key of function
+ for (Map.Entry prefixEntry : rev.entrySet()) {
+ if(property.contains(prefixEntry.getKey())){
+ property = property.replace(prefixEntry.getKey(), prefixEntry.getValue() + ":");
+ }
+ }
+ if(property.contains("://")){
+ throw new IllegalArgumentException("LIMES does not support using namespace IRIs in the properties, optionalProperties, restrictions, or functions in the configuration file. " +
+ "Please define a prefix and use the prefix for the namespace of the following IRI: " + originalProp);
+ }
+
+ //Replace value map
+ Map intermediateReplacement = new HashMap<>();
+ for (Map.Entry stringEntry : entry.getValue().entrySet()) {
+ String subKey = stringEntry.getKey();
+ String origSubKey = subKey;
+ for (Map.Entry prefixEntry : rev.entrySet()) {
+ subKey = subKey.replace(prefixEntry.getKey(), prefixEntry.getValue() + ":");
+ }
+ intermediateReplacement.put(subKey, stringEntry.getValue());
+ if(subKey.contains("://")){
+ throw new IllegalArgumentException("LIMES does not support using namespace IRIs in the properties, optionalProperties, restrictions, or functions in the configuration file. " +
+ "Please define a prefix and use the prefix for the namespace of the following IRI: " + origSubKey);
+ }
+
+ }
+
+ replacements.put(property, intermediateReplacement);
+ }
+ return replacements;
+ }
+
}
diff --git a/limes-core/src/main/java/org/aksw/limes/core/io/config/reader/rdf/RDFConfigurationReader.java b/limes-core/src/main/java/org/aksw/limes/core/io/config/reader/rdf/RDFConfigurationReader.java
index 63a972452..07feaf946 100644
--- a/limes-core/src/main/java/org/aksw/limes/core/io/config/reader/rdf/RDFConfigurationReader.java
+++ b/limes-core/src/main/java/org/aksw/limes/core/io/config/reader/rdf/RDFConfigurationReader.java
@@ -166,6 +166,15 @@ public Configuration read(Model configurationModel) {
configuration.setOutputFormat(output.toString());
}
+ // 10. Check for invalid config because of URIs without prefixes
+ if(configuration.getSourceInfo() != null){
+ replaceURIsWithPrefixes(configuration.getSourceInfo());
+ }
+ if(configuration.getTargetInfo() != null){
+ replaceURIsWithPrefixes(configuration.getTargetInfo());
+ }
+
+
return configuration;
}
diff --git a/limes-core/src/main/java/org/aksw/limes/core/io/config/reader/xml/XMLConfigurationReader.java b/limes-core/src/main/java/org/aksw/limes/core/io/config/reader/xml/XMLConfigurationReader.java
index 6ddfe4005..97c746e03 100644
--- a/limes-core/src/main/java/org/aksw/limes/core/io/config/reader/xml/XMLConfigurationReader.java
+++ b/limes-core/src/main/java/org/aksw/limes/core/io/config/reader/xml/XMLConfigurationReader.java
@@ -513,6 +513,15 @@ public InputSource resolveEntity(String publicId, String systemId) throws SAXExc
children = list.item(0).getChildNodes();
configuration.setOutputFormat(getText(list.item(0)));
}
+
+ // 10. Check for invalid config because of URIs without prefixes
+ if(configuration.getSourceInfo() != null){
+ replaceURIsWithPrefixes(configuration.getSourceInfo());
+ }
+ if(configuration.getTargetInfo() != null){
+ replaceURIsWithPrefixes(configuration.getTargetInfo());
+ }
+
}
} catch (Exception e) {
logger.warn(e.getMessage());
diff --git a/limes-core/src/main/java/org/aksw/limes/core/io/preprocessing/PreprocessingFunctionFactory.java b/limes-core/src/main/java/org/aksw/limes/core/io/preprocessing/PreprocessingFunctionFactory.java
index 987f52c22..fa2100f78 100644
--- a/limes-core/src/main/java/org/aksw/limes/core/io/preprocessing/PreprocessingFunctionFactory.java
+++ b/limes-core/src/main/java/org/aksw/limes/core/io/preprocessing/PreprocessingFunctionFactory.java
@@ -44,10 +44,10 @@ public class PreprocessingFunctionFactory {
public static final String REMOVE_NON_ALPHANUMERIC = "regularalphabet";
public static final String URI_AS_STRING = "uriasstring";
public static final String SPLIT = "split";
- public static final String TO_WKT_POINT = "toWktPoint";
+ public static final String TO_WKT_POINT = "towktpoint"; //toWktPoint
public static PreprocessingFunctionType getPreprocessingType(String expression){
- switch(expression.trim()){
+ switch(expression.trim().toLowerCase()){
case(CLEAN_IRI):
return PreprocessingFunctionType.CLEAN_IRI;
case(CLEAN_NUMBER):
diff --git a/limes-core/src/main/java/org/aksw/limes/core/io/query/SparqlQueryModule.java b/limes-core/src/main/java/org/aksw/limes/core/io/query/SparqlQueryModule.java
index a9e8144fe..49a76aeb3 100644
--- a/limes-core/src/main/java/org/aksw/limes/core/io/query/SparqlQueryModule.java
+++ b/limes-core/src/main/java/org/aksw/limes/core/io/query/SparqlQueryModule.java
@@ -258,6 +258,7 @@ else if (q[ql].contains("^")) {
if (kb.getRestrictions().size() > 0) {
query = query + "}";
}
+
logger.info("Query issued is \n" + query);
return query;
}
diff --git a/limes-core/src/test/java/org/aksw/limes/core/io/config/reader/xml/AConfigurationReaderTest.java b/limes-core/src/test/java/org/aksw/limes/core/io/config/reader/xml/AConfigurationReaderTest.java
new file mode 100644
index 000000000..3288daa47
--- /dev/null
+++ b/limes-core/src/test/java/org/aksw/limes/core/io/config/reader/xml/AConfigurationReaderTest.java
@@ -0,0 +1,137 @@
+package org.aksw.limes.core.io.config.reader.xml;
+
+import org.aksw.limes.core.io.config.Configuration;
+import org.aksw.limes.core.io.config.KBInfo;
+import org.aksw.limes.core.io.config.reader.AConfigurationReader;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertThrows;
+
+import java.util.*;
+
+public class AConfigurationReaderTest {
+ Map prefixes;
+ LinkedHashMap> functions;
+ KBInfo sourceInfo, targetInfo;
+ Configuration testConf;
+
+ @Before
+ public void init() {
+ prefixes = new HashMap<>();
+ prefixes.put("geos", "http://www.opengis.net/ont/geosparql#");
+ prefixes.put("lgdo", "http://linkedgeodata.org/ontology/");
+ prefixes.put("geom", "http://geovocab.org/geometry#");
+ prefixes.put("rdfs", "http://www.w3.org/2000/01/rdf-schema#");
+ prefixes.put("limes", "http://limes.sf.net/ontology/");
+
+ functions = new LinkedHashMap<>();
+ Map f = new LinkedHashMap<>();
+ f.put("polygon", null);
+ functions.put("geom:geometry/geos:asWKT", f);
+
+ sourceInfo = new KBInfo(
+ "linkedgeodata", //String id
+ "http://linkedgeodata.org/sparql", //String endpoint
+ null, //String graph
+ "?x", //String var
+ new ArrayList<>(Arrays.asList("geom:geometry/geos:asWKT")), //List properties
+ new ArrayList<>(), //List optionalProperties
+ new ArrayList<>(Arrays.asList("?x a lgdo:RelayBox")), //ArrayList restrictions
+ functions, //LinkedHashMap> functions
+ prefixes, //Map prefixes
+ 2000, //int pageSize
+ "sparql", //String type
+ -1, //int minOffset
+ -1 //int maxoffset
+ );
+
+ targetInfo = new KBInfo(
+ "linkedgeodata", //String id
+ "http://linkedgeodata.org/sparql", //String endpoint
+ null, //String graph
+ "?y", //String var
+ new ArrayList<>(Arrays.asList("geom:geometry/geos:asWKT")), //List properties
+ new ArrayList<>(), //List optionalProperties
+ new ArrayList<>(Arrays.asList("?y a lgdo:RelayBox")), //ArrayList restrictions
+ functions, //LinkedHashMap> functions
+ prefixes, //Map prefixes
+ 2000, //int pageSize
+ "sparql", //String type
+ -1, //int minOffset
+ -1 //int maxoffset
+ );
+
+ testConf = new Configuration();
+ testConf.setPrefixes(prefixes);
+ testConf.setSourceInfo(sourceInfo);
+ testConf.setTargetInfo(targetInfo);
+
+ }
+
+ @Test
+ public void testReplaceWithPrefixProp() {
+ testConf.getSourceInfo().addProperty("http://www.opengis.net/ont/geosparql#test");
+ AConfigurationReader.replaceURIsWithPrefixes(testConf.getSourceInfo());
+ assertTrue(testConf.getSourceInfo().getProperties().contains("geos:test"));
+ }
+
+ @Test
+ public void testReplaceWithPrefixOptionalProp() {
+ testConf.getSourceInfo().addOptionalProperty("http://www.opengis.net/ont/geosparql#test");
+ AConfigurationReader.replaceURIsWithPrefixes(testConf.getSourceInfo());
+ assertTrue(testConf.getSourceInfo().getOptionalProperties().contains("geos:test"));
+ }
+
+ @Test
+ public void testReplaceWithPrefixRestriction() {
+ testConf.getSourceInfo().addRestriction("http://www.opengis.net/ont/geosparql#test");
+ AConfigurationReader.replaceURIsWithPrefixes(testConf.getSourceInfo());
+ assertTrue(testConf.getSourceInfo().getRestrictions().contains("geos:test"));
+ }
+
+ @Test
+ public void testReplaceWithPrefixFunc() {
+ LinkedHashMap> x = testConf.getSourceInfo().getFunctions();
+ HashMap y = new HashMap<>();
+ y.put("http://www.opengis.net/ont/geosparql#test", "toLower");
+ x.put("http://www.opengis.net/ont/geosparql#test", y);
+ testConf.getSourceInfo().setFunctions(x);
+ AConfigurationReader.replaceURIsWithPrefixes(testConf.getSourceInfo());
+ assertTrue(testConf.getSourceInfo().getFunctions().containsKey("geos:test"));
+ }
+
+ @Test
+ public void testReplaceWithPrefixPropError() {
+ testConf.getPrefixes().remove("geos");
+ testConf.getSourceInfo().addProperty("http://www.opengis.net/ont/geosparql#test");
+ assertThrows(IllegalArgumentException.class, () -> AConfigurationReader.replaceURIsWithPrefixes(testConf.getSourceInfo()));
+ }
+
+ @Test
+ public void testReplaceWithPrefixOptionalPropError() {
+ testConf.getPrefixes().remove("geos");
+ testConf.getSourceInfo().addOptionalProperty("http://www.opengis.net/ont/geosparql#test");
+ assertThrows(IllegalArgumentException.class, () -> AConfigurationReader.replaceURIsWithPrefixes(testConf.getSourceInfo()));
+ }
+
+ @Test
+ public void testReplaceWithPrefixRestrictionError() {
+ testConf.getPrefixes().remove("geos");
+ testConf.getSourceInfo().addRestriction("http://www.opengis.net/ont/geosparql#test");
+ assertThrows(IllegalArgumentException.class, () -> AConfigurationReader.replaceURIsWithPrefixes(testConf.getSourceInfo()));
+ }
+
+ @Test
+ public void testReplaceWithPrefixFuncError() {
+ testConf.getPrefixes().remove("geos");
+ LinkedHashMap> x = testConf.getSourceInfo().getFunctions();
+ HashMap y = new HashMap<>();
+ y.put("http://www.opengis.net/ont/geosparql#test", "toLower");
+ x.put("http://www.opengis.net/ont/geosparql#test", y);
+ testConf.getSourceInfo().setFunctions(x);
+ assertThrows(IllegalArgumentException.class, () -> AConfigurationReader.replaceURIsWithPrefixes(testConf.getSourceInfo()));
+ }
+
+}
diff --git a/limes-debian-cli/pom.xml b/limes-debian-cli/pom.xml
index 0a199fc14..9d62c0733 100644
--- a/limes-debian-cli/pom.xml
+++ b/limes-debian-cli/pom.xml
@@ -19,7 +19,7 @@
org.aksw.limeslimes-full
- 1.8.0-SNAPSHOT
+ 1.8.1-SNAPSHOTlimes-debian-cli
diff --git a/pom.xml b/pom.xml
index f81329608..abc4e82b7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,7 +26,7 @@
org.aksw.limeslimes-full
- 1.8.0-SNAPSHOT
+ 1.8.1-SNAPSHOTLIMESLIMES – Link Discovery Framework for Metric Spaces.https://aksw.org/Projects/LIMES