Commit bb4d9b55 authored by Bernd Kiefer's avatar Bernd Kiefer
Browse files

All test data now are in src/test/data

parent 2f174268
\begin{document}
\begin{table}
\begin{verbatim}
<query> ::= <select> <where> [<filter>] [<aggregate>] | ASK <groundtuple>
<select> ::= {"SELECT" | "SELECTALL"} ["DISTINCT"] {"*" | <var>^+}
<var> ::= "?"{a-zA-Z0-9}^+ | "?_"
<nwchar> ::= any NON-whitespace character
<where> ::= "WHERE" <tuple> {"&" <tuple>}^*
<tuple> ::= <literal>^+
<gtuple> ::= <constant>^+
<literal> ::= <var> | <constant>
<constant> ::= <uri> | <atom>
<uri> ::= "<" <nwchar>^+ ">"
<atom> ::= "\"" <char>^* "\"" [ "@" <langtag> | "^^" <xsdtype> ]
<char> ::= any character, incl. whitespaces, numbers, even '\"'
<langtag> ::= "de" | "en" | ...
<xsdtype> ::= "<xsd:int>" | "<xsd:long>" | "<xsd:float>" | "<xsd:double>" | "<xsd:dateTime>" |
"<xsd:string>" | "<xsd:boolean>" | "<xsd:date>" | "<xsd:gYear>" | "<xsd:gMonthDay>" |
"<xsd:gDay>" | "<xsd:gMonth>" | "<xsd:gYearMonth>" | "<xsd:duration>" | "<xsd:anyURI>" | ...
<filter> ::= "FILTER" <constr> {"&" <constr>}^*
<constr> ::= <ineq> | <predcall>
<ineq> ::= <var> "!=" <literal>
<predcall> ::= <predicate> <literal>^*
<predicate> ::= <nwchar>^+
<aggregate> ::= "AGGREGATE" <funcall> {"&" <funcall>}^*
<funcall> ::= <var>^+ "=" <function> <literal>^*
<function> ::= <nwchar>^+
\end{verbatim}
\caption{BNF for the hfc query syntax}
\end{table}
\textbf{Notes:}
\begin{itemize}
\item The reserved keywords ASK, SELECT, SELECTALL, DISTINCT, WHERE, FILTER, and
AGGREGATE need \emph{not} be written uppercase.
\item It is required that neither filter predicates nor aggregate functions have the same name as the above reserved keywords
\item \emph{don't-care} variables should be marked \emph{explicitly} by using
exactly the identifier \texttt{?\_}; this is especially important when using
\texttt{"*"} in a SELECT;
example:
\begin{verbatim}
SELECT DISTINCT WHERE ?s <rdf:type> ?_
SELECT WHERE ?s <rdf:type> ?o ?_ ?_
\end{verbatim}
when restricting the object position without projecting it, we explicitly
write down the selected vars:
\begin{verbatim}
SELECT ?s WHERE ?s <rdf:type> ?o ?_ ?_ FILTER ?o != <foo-class>
\end{verbatim}
\end{itemize}
\end{document}
\ No newline at end of file
......@@ -7,7 +7,7 @@
<groupId>de.dfki.lt.hfc</groupId>
<artifactId>hfc</artifactId>
<version>1.0.2-SNAPSHOT</version>
<version>1.0.3-SNAPSHOT</version>
<packaging>jar</packaging>
<inceptionYear>2015</inceptionYear>
......
......@@ -1077,7 +1077,7 @@ public final class TupleStore {
public Set<int[]> getTuples(int pos, int obj) {
final Set<int[]> result = this.index[pos].get(obj);
if (result == null)
return new THashSet<int[]>();
return Collections.emptySet();
else
return result;
}
......@@ -1091,7 +1091,7 @@ public final class TupleStore {
public Set<int[]> getTuples(int pos, String obj) {
final Set<int[]> result = this.index[pos].get(this.objectToId.get(obj));
if (result == null)
return new THashSet<int[]>();
return Collections.emptySet();
else
return result;
}
......
#
# this simulates OWLIM's owl-horst_partialRDFS_builtin.pie rule file that builds
# on the rule semantics for OWL as published by ter Horst which is based on Hayes'
# work for axiomatizing RDF Schema;
# I have split up rule $owl_FunctProp into $owl_FunctPropObject and
# $owl_FunctPropDatatype, since the nature of the object of the triple either
# leads to a owl:sameAs statement or to the bottom type owl:Nothing;
#
# NOTE: this file should only be used with HFC when the Boolean flag
# equivalenceClassReduction in class TupleStore is turned on (default = off);
# this file thus does NOT contain the rules copying over information
# from subject, predicate, and object position as originally specified by
# o $owl_sameAsCopySubj
# o $owl_equivalentPropertyCopyPred
# o $owl_sameAsCopyObj
#
# @see TupleStore.equivalenceClassReduction
#
# @author Hans-Ulrich Krieger
# @version Mon Jul 5 16:29:39 CEST 2010
#
# NOTE: $rdf1_rdfs4a_4b (= rdf1 & rdfs4a & rdfs4b) modified;
# not interested that ?s, ?p, and ?o are all of rdf:type rdfs:Resource;
# only add that ?p is of rdf:type rdf:Property
$rdf1_rdfs4a_4b
?_s ?p ?_o
->
?p <rdf:type> <rdf:Property>
$rdfs2
?s ?p ?_o
?p <rdfs:domain> ?dom
->
?s <rdf:type> ?dom
@test
?p != <rdf:type>
# added second clause (HUK)
$rdfs3
?_s ?p ?o
?p <rdf:type> <owl:ObjectProperty>
?p <rdfs:range> ?rng
->
?o <rdf:type> ?rng
# NOTE: redundant rule -- implemented through owl:TransitiveProperty
#$rdfs5
#?p <rdfs:subPropertyOf> ?q
#?q <rdfs:subPropertyOf> ?r
#->
#?p <rdfs:subPropertyOf> ?r
#@test
#?p != ?q
#?p != ?r
#?q != ?r
$rdfs6
?p <rdf:type> <rdf:Property>
->
?p <rdfs:subPropertyOf> ?p
$rdfs7
?s ?p ?o
?p <rdfs:subPropertyOf> ?q
->
?s ?q ?o
@test
?p != ?q
# replaced rdfs:Class by owl:Class;
# or we add a further axiom that owl:Class is a subclass of rdfs:Class as it is
# enforced for OWL Lite and OWL DL
# NOTE: this rule only implements rdfs10 (note that ?c is a subclass of rdfs:Resource)
$rdfs8_10
?c <rdf:type> <owl:Class>
->
?c <rdfs:subClassOf> ?c
# universal instantiation
$rdfs9
?i <rdf:type> ?c
?c <rdfs:subClassOf> ?d
->
?i <rdf:type> ?d
@test
?c != ?d
# NOTE: redundant rule -- implemented through owl:TransitiveProperty
# NOTE: no rule defined for rdfs:subPropertyOf -- again redundant through
# the characterization as being a transitive property
#$rdfs11
#?c <rdfs:subClassOf> ?d
#?d <rdfs:subClassOf> ?e
#->
#?c <rdfs:subClassOf> ?e
#@test
#?c != ?d
#?c != ?e
#?d != ?e
# NOTE: $rdfs12 omitted -- deals with rdfs:member
# will not fire for our OWL ontologies
# NOTE: $rdfs13 omitted -- deals with rdfs:Literal
# will not fire for our OWL ontologies
$owl_invOf
?s ?p ?o
?p <owl:inverseOf> ?q
->
?o ?q ?s
$owl_invOfBySymProp
?p <rdf:type> <owl:SymmetricProperty>
->
?p <owl:inverseOf> ?p
$owl_SymPropByInverse
?p <owl:inverseOf> ?p
->
?p <rdf:type> <owl:SymmetricProperty>
# original rule name is: rdfp3;
# rule was _not_ part of the OWLIM definition (why?)
$owl_SymmetricProperty
?p <rdf:type> <owl:SymmetricProperty>
?s ?p ?o
->
?o ?p ?s
$owl_TransProp
?p <rdf:type> <owl:TransitiveProperty>
?x ?p ?y
?y ?p ?z
->
?x ?p ?z
@test
?x != ?y
?y != ?z
# second clause has been added to guarantee proper application context
# note: rule will be automatically rewritten
$owl_FunctPropObject
?p <rdf:type> <owl:FunctionalProperty>
?p <rdf:type> <owl:ObjectProperty>
?x ?p ?y
?x ?p ?z
->
?y <owl:sameAs> ?z
@test
?y != ?z
?p != <rdf:type>
# NOT part of the original rule set, a kind of integrity constraint, deriving
# that an individual is of type owl:Nothing;
# NOTE: currently commented out !!!!!!!!!!!!!!
#$owl_FunctPropDatatype
#?p <rdf:type> <owl:FunctionalProperty>
#?p <rdf:type> <owl:DatatypeProperty>
#?x ?p ?y
#?x ?p ?z
#->
#?x <rdf:type> <owl:Nothing>
#@test
#?y != ?z
#?p != <rdf:type>
# holds for both datatype and object properties
# note: rule will be automatically rewritten
$owl_InvFunctProp
?p <rdf:type> <owl:InverseFunctionalProperty>
?y ?p ?x
?z ?p ?x
->
?y <owl:sameAs> ?z
@test
?y != ?z
?p != <rdf:type>
# note: rule will be automatically rewritten
$owl_EquivClassBySubClass
?x <rdfs:subClassOf> ?y
?y <rdfs:subClassOf> ?x
->
?x <owl:equivalentClass> ?y
@test
?x != ?y
# note: rule will be automatically rewritten
$owl_EquivPropBySubProp
?p <rdfs:subPropertyOf> ?q
?q <rdfs:subPropertyOf> ?p
->
?p <owl:equivalentProperty> ?q
@test
?p != ?q
$owl_typeByAllVal
?x <owl:onProperty> ?p
?u <rdf:type> ?x
?x <owl:allValuesFrom> ?y
?u ?p ?v
->
?v <rdf:type> ?y
$owl_typeByHasVal
?r <owl:onProperty> ?p
?r <owl:hasValue> ?v
?i ?p ?v
->
?i <rdf:type> ?r
$owl_AttrByHasVal
?x <owl:hasValue> ?y
?x <owl:onProperty> ?p
?u <rdf:type> ?x
->
?u ?p ?y
$owl_typeBySomeVal
?q <rdf:type> ?c
?r <owl:onProperty> ?p
?r <owl:someValuesFrom> ?c
?i ?p ?q
->
?i <rdf:type> ?r
$owl_subClassByInters1
?c <owl:intersectionOf> ?x
?x <rdf:first> ?y
->
?c <rdfs:subClassOf> ?x
?c <rdfs:subClassOf> ?y
$owl_subClassByInters2
?x <rdf:rest> ?y
?c <owl:intersectionOf> ?x
->
?x <owl:intersectionOf> ?y
@test
?y != <rdf:nil>
$owl_typeByIntersect_1
?b <rdf:first> ?c
?b <rdf:rest> <rdf:nil>
?z <owl:intersectionOf> ?b
?i <rdf:type> ?c
->
?i <rdf:type> ?b
$owl_typeByIntersect_2
?b <rdf:first> ?c
?i <rdf:type> ?c
?i <rdf:type> ?b
?n <owl:intersectionOf> ?b
->
?i <rdf:type> ?n
# short to long namespace name mappings: use &short2long directive
&short2long
xsd http://www.w3.org/2001/XMLSchema#
rdf http://www.w3.org/1999/02/22-rdf-syntax-ns#
rdfs http://www.w3.org/2000/01/rdf-schema#
owl http://www.w3.org/2002/07/owl#
test http://www.dfki.de/lt/onto/test.owl
# short namespace type URIs to HFC classes: use &type2class directive
# note: all (custom) type classes should be put in package
# de.dfki.lt.hfc.types
&type2class
xsd:boolean XsdBoolean
xsd:int XsdInt
xsd:long XsdLong
xsd:float XsdFloat
xsd:double XsdDouble
xsd:string XsdString
xsd:anyURI XsdAnyURI
xsd:duration XsdDuration
xsd:date XsdDate
xsd:dateTime XsdDateTime
xsd:gYear XsdGYear
xsd:gYearMonth XsdGYearMonth
xsd:gMonth XsdGMonth
xsd:gMonthDay XsdGMonthDay
xsd:gDay XsdGDay
#
# the below axiomatic triples can be found in ter Horst papers
# Herman J. ter Horst (2004). Extending the RDFS Entailment Lemma. Proceedings ISWC.
# Herman J. ter Horst (2005). Combining RDF and Part of OWL with Rules: Semantics,
# Decidability, Complexity. Proceedings ISWC.
# Herman J. ter Horst (2005). Completeness, decidability and complexity of entailment
# for RDF Schema and a semantic extension involving the OWL vocabulary. Journal of
# Web Semantics
# and are a straightforward extension of work done by Pat Hayes for RDF Schema in
# Patrick Hayes (2004). RDF Semantics. W3C.
#
# I have omitted the RDF-specific triples, since they do not have an effect on the
# soundness of the entailed triples;
# I have also added a few extensions to the set of axioms
#
# @author Hans-Ulrich Krieger
# @version Tue Jan 10 15:35:47 CET 2012
#
<rdf:type> <rdf:type> <rdf:Property> .
<rdf:subject> <rdf:type> <rdf:Property> .
<rdf:predicate> <rdf:type> <rdf:Property> .
<rdf:object> <rdf:type> <rdf:Property> .
<rdf:first> <rdf:type> <rdf:Property> .
<rdf:rest> <rdf:type> <rdf:Property> .
<rdf:nil> <rdf:type> <rdf:List> .
<owl:equivalentClass> <rdf:type> <owl:TransitiveProperty> .
<owl:equivalentClass> <rdf:type> <owl:SymmetricProperty> .
<owl:equivalentClass> <rdfs:subPropertyOf> <rdfs:subClassOf> .
<owl:equivalentProperty> <rdf:type> <owl:TransitiveProperty> .
<owl:equivalentProperty> <rdf:type> <owl:SymmetricProperty> .
<owl:equivalentProperty> <rdfs:subPropertyOf> <rdfs:subPropertyOf> .
<rdfs:subClassOf> <rdf:type> <owl:TransitiveProperty> .
<rdfs:subPropertyOf> <rdf:type> <owl:TransitiveProperty> .
<owl:disjointWith> <rdf:type> <owl:SymmetricProperty> .
<owl:inverseOf> <rdf:type> <owl:SymmetricProperty> .
<owl:FunctionalProperty> <rdfs:subClassOf> <rdf:Property> .
<owl:TransitiveProperty> <rdfs:subClassOf> <rdf:Property> .
<owl:SymmetricProperty> <rdfs:subClassOf> <rdf:Property> .
<owl:InverseFunctionalProperty> <rdfs:subClassOf> <rdf:Property> .
<owl:DatatypeProperty> <rdfs:subClassOf> <rdf:Property> .
<owl:ObjectProperty> <rdfs:subClassOf> <rdf:Property> .
<owl:AnnotationProperty> <rdfs:subClassOf> <rdf:Property> .
<owl:sameAs> <rdf:type> <owl:TransitiveProperty> .
<owl:sameAs> <rdf:type> <owl:SymmetricProperty> .
<owl:differentFrom> <rdf:type> <owl:SymmetricProperty> .
# I have added the four below triples
<owl:Thing> <rdf:type> <owl:Class> .
<owl:Nothing> <rdf:type> <owl:Class> .
<owl:Nothing> <rdfs:subClassOf> <owl:Thing> .
<owl:Thing> <owl:disjointWith> <owl:Nothing> .
<xsd:int> <rdf:type> <rdfs:Datatype> .
<xsd:long> <rdf:type> <rdfs:Datatype> .
<xsd:float> <rdf:type> <rdfs:Datatype> .
<xsd:double> <rdf:type> <rdfs:Datatype> .
<xsd:string> <rdf:type> <rdfs:Datatype> .
<xsd:boolean> <rdf:type> <rdfs:Datatype> .
<xsd:date> <rdf:type> <rdfs:Datatype> .
<xsd:dateTime> <rdf:type> <rdfs:Datatype> .
<xsd:gYear> <rdf:type> <rdfs:Datatype> .
<xsd:gYearMonth> <rdf:type> <rdfs:Datatype> .
<xsd:gMonth> <rdf:type> <rdfs:Datatype> .
<xsd:gMonthDay> <rdf:type> <rdfs:Datatype> .
<xsd:gDay> <rdf:type> <rdfs:Datatype> .
<xsd:duration> <rdf:type> <rdfs:Datatype> .
<xsd:anyURI> <rdf:type> <rdfs:Datatype> .
#<rdfs:Datatype> <rdfs:subClassOf> <rdfs:Class> .
#<owl:Class> <rdfs:subClassOf> <rdfs:Class> .
#<owl:Class> <owl:disjointWith> <rdfs:Datatype> .
#
# this simulates OWLIM's owl-horst_partialRDFS_builtin.pie rule file that builds
# on the rule semantics for OWL as published by ter Horst which is based on Hayes'
# work for axiomatizing RDF Schema;
# I have split up rule $owl_FunctProp into $owl_FunctPropObject and
# $owl_FunctPropDatatype, since the nature of the object of the triple either
# leads to a owl:sameAs statement or to the bottom type owl:Nothing;
#
# NOTE: this file should only be used with HFC when the Boolean flag
# equivalenceClassReduction in class TupleStore is turned on (default = off);
# this file thus does NOT contain the rules copying over information
# from subject, predicate, and object position as originally specified by
# o $owl_sameAsCopySubj
# o $owl_equivalentPropertyCopyPred
# o $owl_sameAsCopyObj
#
# @see TupleStore.equivalenceClassReduction
#
# @author Hans-Ulrich Krieger
# @version Mon Jul 5 16:29:39 CEST 2010
#
$CHECK_TEST
?s ?p ?o
->
?s ?s ?s
@test
?p != <rdf:type>
PrintSize ??(s o)
?s != ?o
PrintSize ??(s p) ??p ??(p o)
$PRINT_CONTENT
?s ?p ?o
->
<dontcare> <dontcare> <dontcare>
@test
PrintContent ??p
\ No newline at end of file
......@@ -7,9 +7,6 @@ import static de.dfki.lt.hfc.TestUtils.*;
import org.junit.Test;
import java.io.*;
import java.nio.file.Paths;
import java.util.*;
import de.dfki.lt.hfc.*;
/**
......@@ -23,10 +20,10 @@ public class AddSameAs {
throws FileNotFoundException, WrongFormatException, IOException {
ForwardChainer fc = new ForwardChainer(16,
false, false, eqRed, 3, 5, 100000, 500000,
getResource(eqRed ? "default.eqred.nt" : "default.nt"),
getResource(eqRed ? "default.eqred.rdl" : "default.rdl"),
getResource("default.sameAs.test.ns"));
fc.uploadTuples(getResource("ltworld.jena.nt"));
getTestResource(eqRed ? "default.eqred.nt" : "default.nt"),
getTestResource(eqRed ? "default.eqred.rdl" : "default.rdl"),
getTestResource("default.sameAs.test.ns"));
fc.uploadTuples(getTestResource("ltworld.jena.nt"));
fc.computeClosure();
return fc;
}
......
......@@ -31,6 +31,7 @@ public class AggregateRegistryTest {
BindingTable bt = new BindingTable(table1, nameToPos, nameToExternalName);
//what object to call evaluate on?
//?.evaluate("class", bt, nameToPos, nameToExternalName);
// TODO: ADD A TEST!
}
}
package de.dfki.lt.hfc;
import static de.dfki.lt.hfc.TestUtils.getResource;
import static de.dfki.lt.hfc.TestUtils.getTestResource;
import static org.junit.Assert.*;
import java.io.FileNotFoundException;
......@@ -154,9 +154,9 @@ public class BindingTableTest {
nameToPos.put(1, 1);
Map<Integer, String> nameToExternalName = new TreeMap<Integer, String>();
nameToExternalName.put(1, "value");
Namespace namespace = new Namespace(getResource("default.ns"));
Namespace namespace = new Namespace(getTestResource("default.ns"));
TupleStore ts = new TupleStore(true, true, true, 2, 5, 4, 2, namespace,
getResource("default.nt"));
getTestResource("default.nt"));
BindingTable bt = new BindingTable(table, nameToPos, nameToExternalName, ts);
//System.out.println("IF expand set to TRUE " + bt.toString(true));
assertEquals(bt.toString(true).substring(6, 11), "value");
......@@ -172,9 +172,9 @@ public class BindingTableTest {
nameToPos.put(1, 1);
Map<Integer, String> nameToExternalName = new TreeMap<Integer, String>();
nameToExternalName.put(1, "val");
Namespace namespace = new Namespace(getResource("default.ns"));
Namespace namespace = new Namespace(getTestResource("default.ns"));
TupleStore ts = new TupleStore(true, true, true, 2, 5, 4, 2, namespace,
getResource("default.nt"));
getTestResource("default.nt"));
BindingTable bt = new BindingTable(table, nameToPos, nameToExternalName, ts);
//System.out.println("IF expand set to FALSE, maxLength to 3 " + bt.toString(3, false));
assertEquals(bt.toString(3, false).substring(10, 13), "val");
......@@ -184,7 +184,7 @@ public class BindingTableTest {
assertEquals(bt.toString(5, false).substring(12, 15), "val");
//
TupleStore objfortest = new TupleStore(true, true, true, 2, 5, 4, 2, namespace,
getResource("default.nt"));
getTestResource("default.nt"));
int[] tuple = new int[3];
tuple[0] = 2;
tuple[1] = 2;
......@@ -228,7 +228,7 @@ public class BindingTableTest {
@Test
public void testVarsFilterStar() throws QueryParseException, FileNotFoundException, WrongFormatException, IOException {
TupleStore ts = new TupleStore(new Namespace(getResource("default.ns")));
TupleStore ts = new TupleStore(new Namespace(getTestResource("default.ns")));
Query q = new Query(ts);
String[] t = { "<rdf:a>", "<rdf:type>", "<rdf:b>" };
ts.addTuple(t);
......@@ -249,7 +249,7 @@ public class BindingTableTest {
@Test
public void testVarsFilter() throws QueryParseException, FileNotFoundException, WrongFormatException, IOException {
TupleStore ts = new TupleStore(new Namespace(getResource("default.ns")));
TupleStore ts = new TupleStore(new Namespace(getTestResource("default.ns")));
Query q = new Query(ts);
String[] t = { "<rdf:a>", "<rdf:type>", "<rdf:b>" };
ts.addTuple(t);
......@@ -270,7 +270,7 @@ public class BindingTableTest {
@Test
public void testVarsAggregate() throws QueryParseException, FileNotFoundException, WrongFormatException, IOException {
TupleStore ts = new TupleStore(new Namespace(getResource("default.ns")));
TupleStore ts = new TupleStore(new Namespace(getTestResource("default.ns")));
Query q = new Query(ts);
String[] t = { "<rdf:a>", "<rdf:type>", "<rdf:b>" };
ts.addTuple(t);
......@@ -295,7 +295,7 @@ public class BindingTableTest {
@Test
public void testVarsAggregateStar() throws QueryParseException, FileNotFoundException, WrongFormatException, IOException {
TupleStore ts = new TupleStore(new Namespace(