Java Code Examples for com.bigdata.rdf.store.AbstractTripleStore#getVocabulary()
The following examples show how to use
com.bigdata.rdf.store.AbstractTripleStore#getVocabulary() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestRuleOwlHasValue.java From database with GNU General Public License v2.0 | 4 votes |
/** * Test where the data satisifies the rule exactly once. * * <pre> * (x rdf:type a), (a rdf:type owl:Restriction), (a owl:onProperty p), (a owl:hasValue v) -> (x p v) * </pre> * @throws Exception */ public void test_OwlHasValue() throws Exception { AbstractTripleStore store = getStore(); try { URI A = new URIImpl("http://www.foo.org/A"); URI X = new URIImpl("http://www.foo.org/X"); URI P = new URIImpl("http://www.foo.org/P"); URI V = new URIImpl("http://www.foo.org/V"); IStatementBuffer buffer = new StatementBuffer(store, 100/* capacity */); buffer.add(A, RDF.TYPE, X); buffer.add(X, RDF.TYPE, OWL.RESTRICTION); buffer.add(X, OWL.ONPROPERTY, P); buffer.add(X, OWL.HASVALUE, V); // write on the store. buffer.flush(); // verify statement(s). assertTrue(store.hasStatement(A, RDF.TYPE, X)); assertTrue(store.hasStatement(X, RDF.TYPE, OWL.RESTRICTION)); assertTrue(store.hasStatement(X, OWL.ONPROPERTY, P)); assertTrue(store.hasStatement(X, OWL.HASVALUE, V)); final long nbefore = store.getStatementCount(); final Vocabulary vocab = store.getVocabulary(); final Rule r = new RuleOwlHasValue(store.getSPORelation() .getNamespace(), vocab); // apply the rule. applyRule(store, r, -1/*solutionCount*/,1/*mutationCount*/); /* * validate the state of the primary store. */ // told assertTrue(store.hasStatement(A, RDF.TYPE, X)); assertTrue(store.hasStatement(X, RDF.TYPE, OWL.RESTRICTION)); assertTrue(store.hasStatement(X, OWL.ONPROPERTY, P)); assertTrue(store.hasStatement(X, OWL.HASVALUE, V)); // entailed assertTrue(store.hasStatement(A, P, V)); // final #of statements in the store. assertEquals(nbefore + 1, store.getStatementCount()); } finally { store.__tearDownUnitTest(); } }
Example 2
Source File: TestVocabulary.java From database with GNU General Public License v2.0 | 4 votes |
public void test_NoVocabulary() { final Properties properties = getProperties(); // override the default. properties.setProperty(Options.VOCABULARY_CLASS, NoVocabulary.class .getName()); properties.setProperty(Options.AXIOMS_CLASS, NoAxioms.class .getName()); AbstractTripleStore store = getStore(properties); try { final Vocabulary vocab = store.getVocabulary(); assertTrue(vocab instanceof NoVocabulary); final int nvalues = vocab.size(); // the vocabulary should be empty. assertEquals(0, nvalues); // verify (de-)serialization. doRoundTripTest(vocab); // lookup/add some values. final BigdataValueFactory f = store.getValueFactory(); // Must be using the same namespace. assertTrue(vocab.getNamespace()==f.getNamespace()); final BigdataURI rdfType = f.asValue(RDF.TYPE); final BigdataURI rdfProperty = f.asValue(RDF.PROPERTY); final BigdataURI unknownURI = f.createURI("http://www.bigdata.com/unknown"); // resolve term ids. store.addTerms(new BigdataValue[] { rdfType, rdfProperty, unknownURI }); // point tests for unknown values (there are no known values). assertNull(vocab.get(RDF.TYPE)); // try { // // vocab.get(RDF.TYPE); // // fail("Expecting: " + IllegalArgumentException.class); // // } catch (IllegalArgumentException ex) { // // log.info("Ignoring expected exception: " + ex); // // } assertNull(vocab.get(RDF.PROPERTY)); // try { // // vocab.get(RDF.PROPERTY); // // fail("Expecting: " + IllegalArgumentException.class); // // } catch (IllegalArgumentException ex) { // // log.info("Ignoring expected exception: " + ex); // // } assertNull(vocab.get(unknownURI)); // try { // // vocab.get(unknownURI); // // fail("Expecting: " + IllegalArgumentException.class); // // } catch (IllegalArgumentException ex) { // // log.info("Ignoring expected exception: " + ex); // // } if (store.isStable()) { store = reopenStore(store); final Vocabulary vocab2 = store.getVocabulary(); assertSameVocabulary(vocab, vocab2); } } finally { store.__tearDownUnitTest(); } }
Example 3
Source File: TestRuleFastClosure_11_13.java From database with GNU General Public License v2.0 | 4 votes |
/** * Tests {@link RuleFastClosure13} with the minimum data required to compute * a single entailment. * @throws Exception */ public void test_RuleFastForwardClosure13() throws Exception { AbstractTripleStore store = getStore(); try { final BigdataValueFactory f = store.getValueFactory(); final IV a = store.addTerm(f.createURI("http://www.bigdata.com/a")); final IV b = store.addTerm(f.createURI("http://www.bigdata.com/b")); final IV y = store.addTerm(f.createURI("http://www.bigdata.com/y")); final IV x = store.addTerm(f.createURI("http://www.bigdata.com/x")); final IV z = store.addTerm(f.createURI("http://www.bigdata.com/z")); final Vocabulary vocab = store.getVocabulary(); // told: { SPO[] told = new SPO[] { // new SPO(x, y, z, StatementEnum.Explicit), // new SPO(y, vocab.get(RDFS.SUBPROPERTYOF), a, StatementEnum.Explicit), // new SPO(a, vocab.get(RDFS.RANGE), b, StatementEnum.Explicit) }; store.addStatements(told, told.length); } // entails: // store.addStatement(z, inf.rdfType.get(), b); // store.commit(); if (log.isInfoEnabled()) log.info("\n" + store.dumpStore()); /* * (?x, ?y, ?z), (?y, rdfs:subPropertyOf, ?a), (?a, rdfs:domain, ?b) -> * (?z, rdf:type, ?b). */ RuleFastClosure13 rule = new RuleFastClosure13(store .getSPORelation().getNamespace(), vocab); /* * Test run the rule. */ applyRule(store, rule, 1/*solutionCount*/, 1/*mutationCount*/); // check entailments. assertTrue(store.hasStatement(z, vocab.get(RDF.TYPE), b)); // store.commit(); } finally { store.__tearDownUnitTest(); } }
Example 4
Source File: TestRuleOwlTransitiveProperty.java From database with GNU General Public License v2.0 | 4 votes |
/** * Test where the data satisifies the rule exactly once. * * <pre> * (a rdf:type owl:TransitiveProperty), (x a y), (y a z) -> (x a z) * </pre> * @throws Exception */ public void test_OwlTranstitiveProperty1() throws Exception { AbstractTripleStore store = getStore(); try { URI A = new URIImpl("http://www.foo.org/A"); URI X = new URIImpl("http://www.foo.org/X"); URI Y = new URIImpl("http://www.foo.org/Y"); URI Z = new URIImpl("http://www.foo.org/Z"); IStatementBuffer buffer = new StatementBuffer(store, 100/* capacity */); buffer.add(A, RDF.TYPE, OWL.TRANSITIVEPROPERTY); buffer.add(X, A, Y); buffer.add(Y, A, Z); // write on the store. buffer.flush(); // verify statement(s). assertTrue(store.hasStatement(A, RDF.TYPE, OWL.TRANSITIVEPROPERTY)); assertTrue(store.hasStatement(X, A, Y)); assertTrue(store.hasStatement(Y, A, Z)); final long nbefore = store.getStatementCount(); final Vocabulary vocab = store.getVocabulary(); final Rule r = new RuleOwlTransitiveProperty1(store.getSPORelation() .getNamespace(), vocab); // apply the rule. applyRule(store, r, -1/*solutionCount*/,1/*mutationCount*/); /* * validate the state of the primary store. */ // told assertTrue(store.hasStatement(A, RDF.TYPE, OWL.TRANSITIVEPROPERTY)); assertTrue(store.hasStatement(X, A, Y)); assertTrue(store.hasStatement(Y, A, Z)); // entailed assertTrue(store.hasStatement(X, A, Z)); // final #of statements in the store. assertEquals(nbefore + 1, store.getStatementCount()); } finally { store.__tearDownUnitTest(); } }
Example 5
Source File: TestRuleOwlFunctionalProperty.java From database with GNU General Public License v2.0 | 4 votes |
public void test_RuleOwlInverseFunctionalProperty() throws Exception { AbstractTripleStore store = getStore(); try { URI john = new URIImpl("http://www.foo.org/john"); URI paul = new URIImpl("http://www.foo.org/paul"); URI mary = new URIImpl("http://www.foo.org/mary"); URI wife = new URIImpl("http://www.foo.org/wife"); IStatementBuffer buffer = new StatementBuffer(store, 100/* capacity */); buffer.add(wife, RDF.TYPE, OWL.INVERSEFUNCTIONALPROPERTY); buffer.add(john, wife, mary); // write on the store. buffer.flush(); // verify statement(s). assertTrue(store.hasStatement(wife, RDF.TYPE, OWL.INVERSEFUNCTIONALPROPERTY)); assertTrue(store.hasStatement(john, wife, mary)); final long nbefore = store.getStatementCount(); final Vocabulary vocab = store.getVocabulary(); final Rule r = new RuleOwlInverseFunctionalProperty(store.getSPORelation() .getNamespace(), vocab); // apply the rule. applyRule(store, r, -1/*solutionCount*/,0/*mutationCount*/); /* * validate the state of the primary store. */ // told assertTrue(store.hasStatement(wife, RDF.TYPE, OWL.INVERSEFUNCTIONALPROPERTY)); assertTrue(store.hasStatement(john, wife, mary)); // final #of statements in the store. assertEquals(nbefore, store.getStatementCount()); // add another S for the inverse functional property buffer.add(paul, wife, mary); buffer.flush(); applyRule(store, r, -1/*solutionCount*/, 2/*mutationCount*/); assertTrue(store.hasStatement(john, OWL.SAMEAS, paul)); assertTrue(store.hasStatement(paul, OWL.SAMEAS, john)); // final #of statements in the store. assertEquals(nbefore+3, store.getStatementCount()); // try { // // // apply the rule. // applyRule(store, r, -1/*solutionCount*/,0/*mutationCount*/); // // fail("should have violated the inverse functional property"); // // } catch (Exception ex) { // // if (!InnerCause.isInnerCause(ex, // ConstraintViolationException.class)) { // fail("Expected: " + ConstraintViolationException.class); // } //// final ExecutionExceptions ex2 = (ExecutionExceptions) //// InnerCause.getInnerCause(ex, ExecutionExceptions.class); //// //// Throwable t = ex2.causes().get(0); //// while (t.getCause() != null) //// t = t.getCause(); //// //// if (!(t instanceof ConstraintViolationException)) //// fail("inner cause should be a ConstraintViolationException"); // // } } finally { store.__tearDownUnitTest(); } }
Example 6
Source File: TestRuleOwlFunctionalProperty.java From database with GNU General Public License v2.0 | 4 votes |
public void test_RuleOwlFunctionalProperty() throws Exception { AbstractTripleStore store = getStore(); try { URI john = new URIImpl("http://www.foo.org/john"); URI mary = new URIImpl("http://www.foo.org/mary"); URI susie = new URIImpl("http://www.foo.org/susie"); URI wife = new URIImpl("http://www.foo.org/wife"); IStatementBuffer buffer = new StatementBuffer(store, 100/* capacity */); buffer.add(wife, RDF.TYPE, OWL.FUNCTIONALPROPERTY); buffer.add(john, wife, mary); // write on the store. buffer.flush(); // verify statement(s). assertTrue(store.hasStatement(wife, RDF.TYPE, OWL.FUNCTIONALPROPERTY)); assertTrue(store.hasStatement(john, wife, mary)); final long nbefore = store.getStatementCount(); final Vocabulary vocab = store.getVocabulary(); final Rule r = new RuleOwlFunctionalProperty(store.getSPORelation() .getNamespace(), vocab); // apply the rule. applyRule(store, r, -1/*solutionCount*/,0/*mutationCount*/); /* * validate the state of the primary store. */ // told assertTrue(store.hasStatement(wife, RDF.TYPE, OWL.FUNCTIONALPROPERTY)); assertTrue(store.hasStatement(john, wife, mary)); // final #of statements in the store. assertEquals(nbefore, store.getStatementCount()); // add another value for the functional property buffer.add(john, wife, susie); buffer.flush(); applyRule(store, r, -1/*solutionCount*/, 2/*mutationCount*/); assertTrue(store.hasStatement(mary, OWL.SAMEAS, susie)); assertTrue(store.hasStatement(susie, OWL.SAMEAS, mary)); // final #of statements in the store. assertEquals(nbefore+3, store.getStatementCount()); // try { // // // apply the rule. // applyRule(store, r, -1/*solutionCount*/,0/*mutationCount*/); // // fail("should have violated the functional property"); // // } catch (Exception ex) { // // if (!InnerCause.isInnerCause(ex, // ConstraintViolationException.class)) { // fail("Expected: " + ConstraintViolationException.class); // } // //// final ExecutionExceptions ex2 = (ExecutionExceptions) //// InnerCause.getInnerCause(ex, ExecutionExceptions.class); //// //// Throwable t = ex2.causes().get(0); //// while (t.getCause() != null) //// t = t.getCause(); //// //// if (!(t instanceof ConstraintViolationException)) //// fail("inner cause should be a ConstraintViolationException"); // // } } finally { store.__tearDownUnitTest(); } }
Example 7
Source File: TestMappedProgram.java From database with GNU General Public License v2.0 | 3 votes |
/** * */ public void testMappedRuleWithOneTail() { final AbstractTripleStore store = getStore(); try { final Vocabulary vocab = store.getVocabulary(); final boolean parallel = false; // actual value should not matter. final boolean closure = false; // actual value should not matter, // will map the rule across the database and the focusStore. final MappedProgram program = new MappedProgram(getName(), focusStore, parallel, closure); final IRule rule = new RuleOwlEquivalentProperty(database, vocab); log.info("\n"+rule); program.addStep(rule); log.info("\n"+program); } finally { store.__tearDownUnitTest(); } }
Example 8
Source File: TestMappedProgram.java From database with GNU General Public License v2.0 | 3 votes |
public void testClosureOfMappedRuleWithTwoTails() { final AbstractTripleStore store = getStore(); try { final Vocabulary vocab = store.getVocabulary(); final boolean parallel = false; // actual value should not matter. final boolean closure = false; // actual value should not matter, // will map the rule across the database and the focusStore. final MappedProgram program = new MappedProgram(getName(), focusStore, parallel, closure); final IRule rule = new RuleRdfs09(database,vocab); log.info("\n"+rule); program.addClosureOf(rule); log.info("\n"+program); } finally { store.__tearDownUnitTest(); } }
Example 9
Source File: BaseClosure.java From database with GNU General Public License v2.0 | 3 votes |
/** * * @param db * The database whose configuration will determine which * entailments are to be maintained and which of those * entailments are computed by forward closure vs * backchained. * * @throws IllegalArgumentException * if the <i>db</i> is <code>null</code>. */ protected BaseClosure(AbstractTripleStore db) { if (db == null) throw new IllegalArgumentException(); this.db = db; final InferenceEngine inf = db.getInferenceEngine(); axioms = db.getAxioms(); vocab = db.getVocabulary(); rdfsOnly = axioms.isRdfSchema() && !axioms.isOwlSameAs(); forwardChainRdfTypeRdfsResource = inf.forwardChainRdfTypeRdfsResource; forwardChainOwlSameAsClosure = inf.forwardChainOwlSameAsClosure; forwardChainOwlSameAsProperties = inf.forwardChainOwlSameAsProperties; forwardChainOwlEquivalentProperty = inf.forwardChainOwlEquivalentProperty; forwardChainOwlEquivalentClass = inf.forwardChainOwlEquivalentClass; forwardChainOwlTransitiveProperty = inf.forwardChainOwlTransitiveProperty; forwardChainOwlInverseOf = inf.forwardChainOwlInverseOf; forwardChainOwlHasValue = inf.forwardChainOwlHasValue; forwardChainOwlSymmetricProperty = inf.forwardChainOwlSymmetricProperty; enableOwlFunctionalAndInverseFunctionalProperty = inf.enableOwlFunctionalAndInverseFunctionalProperty; }
Example 10
Source File: TestMappedProgram.java From database with GNU General Public License v2.0 | 3 votes |
public void testMappedRuleWithTwoTails() { final AbstractTripleStore store = getStore(); try { final Vocabulary vocab = store.getVocabulary(); final boolean parallel = false; // actual value should not matter. final boolean closure = false; // actual value should not matter, // will map the rule across the database and the focusStore. final MappedProgram program = new MappedProgram(getName(), focusStore, parallel, closure); final IRule rule = new RuleRdfs09(database,vocab); log.info("\n"+rule); program.addStep(rule); log.info("\n"+program); } finally { store.__tearDownUnitTest(); } }
Example 11
Source File: TestRuleOwlInverseOf.java From database with GNU General Public License v2.0 | 2 votes |
/** * Test where the data satisifies the rule exactly once. * * <pre> * owl:InverseOf2 : (a owl:inverseOf b), (x a z) -> (z b x). * </pre> * @throws Exception */ public void test_owlInverseOf2() throws Exception { AbstractTripleStore store = getStore(); try { URI A = new URIImpl("http://www.foo.org/A"); URI B = new URIImpl("http://www.foo.org/B"); URI Z = new URIImpl("http://www.foo.org/Z"); URI X = new URIImpl("http://www.foo.org/X"); URI Y = new URIImpl("http://www.foo.org/Y"); IStatementBuffer buffer = new StatementBuffer(store, 100/* capacity */); buffer.add(A, OWL.INVERSEOF, B); buffer.add(X, A, Z); // write on the store. buffer.flush(); // verify statement(s). assertTrue(store.hasStatement(A, OWL.INVERSEOF, B)); assertTrue(store.hasStatement(X, A, Z)); final long nbefore = store.getStatementCount(); final Vocabulary vocab = store.getVocabulary(); final Rule r = new RuleOwlInverseOf2(store.getSPORelation() .getNamespace(), vocab); // apply the rule. applyRule(store, r, -1/* solutionCount */, 1/* mutationCount */); /* * validate the state of the primary store. */ // told assertTrue(store.hasStatement(A, OWL.INVERSEOF, B)); assertTrue(store.hasStatement(X, A, Z)); // entailed assertTrue(store.hasStatement(Z, B, X)); // final #of statements in the store. assertEquals(nbefore + 1, store.getStatementCount()); } finally { store.__tearDownUnitTest(); } }
Example 12
Source File: TestRuleOwlEquivalentClass.java From database with GNU General Public License v2.0 | 2 votes |
/** * Test where the data satisifies the rule exactly once. * * <pre> * (a owl:equivalentClass b) -> (b owl:equivalentClass a) * </pre> * @throws Exception */ public void test_owlEquivalentClass() throws Exception { AbstractTripleStore store = getStore(); try { URI A = new URIImpl("http://www.foo.org/A"); URI B = new URIImpl("http://www.foo.org/B"); IStatementBuffer buffer = new StatementBuffer(store, 100/* capacity */); buffer.add(A, OWL.EQUIVALENTCLASS, B); // write on the store. buffer.flush(); // verify statement(s). assertTrue(store.hasStatement(A, OWL.EQUIVALENTCLASS, B)); final long nbefore = store.getStatementCount(); final Vocabulary vocab = store.getVocabulary(); final Rule r = new RuleOwlEquivalentClass(store.getSPORelation() .getNamespace(), vocab); // apply the rule. applyRule(store,r, -1/*solutionCount*/,1/*mutationCount*/); /* * validate the state of the primary store. */ // told assertTrue(store.hasStatement(A, OWL.EQUIVALENTCLASS, B)); // entailed assertTrue(store.hasStatement(B, OWL.EQUIVALENTCLASS, A)); // final #of statements in the store. assertEquals(nbefore + 1, store.getStatementCount()); } finally { store.__tearDownUnitTest(); } }
Example 13
Source File: TestRuleOwlInverseOf.java From database with GNU General Public License v2.0 | 2 votes |
/** * Test where the data satisifies the rule exactly once. * * <pre> * owl:InverseOf1 : (a owl:inverseOf b) -> (b owl:inverseOf a) * </pre> * @throws Exception */ public void test_owlInverseOf1() throws Exception { AbstractTripleStore store = getStore(); try { URI X = new URIImpl("http://www.foo.org/X"); URI Y = new URIImpl("http://www.foo.org/Y"); IStatementBuffer buffer = new StatementBuffer(store, 100/* capacity */); buffer.add(X, OWL.INVERSEOF, Y); // write on the store. buffer.flush(); // verify statement(s). assertTrue(store.hasStatement(X, OWL.INVERSEOF, Y)); final long nbefore = store.getStatementCount(); final Vocabulary vocab = store.getVocabulary(); final Rule r = new RuleOwlInverseOf1(store.getSPORelation() .getNamespace(), vocab); // apply the rule. applyRule(store, r, -1/*solutionCount*/,1/*mutationCount*/); /* * validate the state of the primary store. */ // told assertTrue(store.hasStatement(X, OWL.INVERSEOF, Y)); // entailed assertTrue(store.hasStatement(Y, OWL.INVERSEOF, X)); // final #of statements in the store. assertEquals(nbefore + 1, store.getStatementCount()); } finally { store.__tearDownUnitTest(); } }
Example 14
Source File: TestRuleOwlSymmetricProperty.java From database with GNU General Public License v2.0 | 2 votes |
public void test_Rule() throws Exception { AbstractTripleStore store = getStore(); try { URI A = new URIImpl("http://www.foo.org/A"); URI B = new URIImpl("http://www.foo.org/B"); URI X = new URIImpl("http://www.foo.org/X"); IStatementBuffer buffer = new StatementBuffer(store, 100/* capacity */); buffer.add(X, RDF.TYPE, OWL.SYMMETRICPROPERTY); buffer.add(A, X, B); // write on the store. buffer.flush(); // verify statement(s). assertTrue(store.hasStatement(X, RDF.TYPE, OWL.SYMMETRICPROPERTY)); assertTrue(store.hasStatement(A, X, B)); final long nbefore = store.getStatementCount(); final Vocabulary vocab = store.getVocabulary(); final Rule r = new RuleOwlSymmetricProperty(store.getSPORelation() .getNamespace(), vocab); // apply the rule. applyRule(store, r, -1/*solutionCount*/,1/*mutationCount*/); /* * validate the state of the primary store. */ // told assertTrue(store.hasStatement(X, RDF.TYPE, OWL.SYMMETRICPROPERTY)); assertTrue(store.hasStatement(A, X, B)); // entailed assertTrue(store.hasStatement(B, X, A)); // final #of statements in the store. assertEquals(nbefore + 1, store.getStatementCount()); } finally { store.__tearDownUnitTest(); } }
Example 15
Source File: TestVocabulary.java From database with GNU General Public License v2.0 | 2 votes |
public void test_RdfsVocabulary() { final Properties properties = getProperties(); // override the default. properties.setProperty(Options.VOCABULARY_CLASS, RDFSVocabulary.class .getName()); properties.setProperty(Options.AXIOMS_CLASS, NoAxioms.class .getName()); AbstractTripleStore store = getStore(properties); try { final Vocabulary vocab = store.getVocabulary(); assertTrue(vocab instanceof RDFSVocabulary); // verify (de-)serialization. doRoundTripTest(vocab); // lookup/add some values. final BigdataValueFactory f = store.getValueFactory(); final BigdataURI rdfType = f.asValue(RDF.TYPE); final BigdataURI rdfProperty = f.asValue(RDF.PROPERTY); final BigdataURI unknownURI = f.createURI("http://www.bigdata.com/unknown"); // resolve term ids. store.addTerms(new BigdataValue[] { rdfType, rdfProperty, unknownURI }); // point tests for known values. assertEquals(rdfType.getIV(), vocab.get(RDF.TYPE)); assertEquals(rdfProperty.getIV(), vocab.get(RDF.PROPERTY)); // point test for an unknown value. assertNull(vocab.get(unknownURI)); // try { // // vocab.get(unknownURI); // // fail("Expecting: " + IllegalArgumentException.class); // // } catch (IllegalArgumentException ex) { // // log.info("Ignoring expected exception: " + ex); // // } if (store.isStable()) { store = reopenStore(store); final Vocabulary vocab2 = store.getVocabulary(); assertSameVocabulary(vocab, vocab2); } } finally { store.__tearDownUnitTest(); } }
Example 16
Source File: TestRuleOwlSameAs.java From database with GNU General Public License v2.0 | 2 votes |
/** * Test where the data satisifies the rule exactly once. * * <pre> * owl:sameAs1: (x owl:sameAs y) -> (y owl:sameAs x) * </pre> * @throws Exception */ public void test_owlSameAs1() throws Exception { AbstractTripleStore store = getStore(); try { URI X = new URIImpl("http://www.foo.org/X"); URI Y = new URIImpl("http://www.foo.org/Y"); IStatementBuffer buffer = new StatementBuffer(store, 100/* capacity */); buffer.add(X, OWL.SAMEAS, Y); // write on the store. buffer.flush(); // verify statement(s). assertTrue(store.hasStatement(X, OWL.SAMEAS, Y)); final long nbefore = store.getStatementCount(); final Vocabulary vocab = store.getVocabulary(); final Rule r = new RuleOwlSameAs1(store.getSPORelation() .getNamespace(), vocab); // apply the rule. applyRule(store, r, -1/*solutionCount*/,1/*mutationCount*/); /* * validate the state of the primary store. */ // told assertTrue(store.hasStatement(X, OWL.SAMEAS, Y)); // entailed assertTrue(store.hasStatement(Y, OWL.SAMEAS, X)); // final #of statements in the store. assertEquals(nbefore + 1, store.getStatementCount()); } finally { store.__tearDownUnitTest(); } }
Example 17
Source File: TestRuleOwlSameAs.java From database with GNU General Public License v2.0 | 2 votes |
/** * Test where the data satisifies the rule exactly once. * * <pre> * owl:sameAs1b: (x owl:sameAs y), (y owl:sameAs z) -> (x owl:sameAs z) * </pre> * @throws Exception */ public void test_owlSameAs1b() throws Exception { AbstractTripleStore store = getStore(); try { URI X = new URIImpl("http://www.foo.org/X"); URI Y = new URIImpl("http://www.foo.org/Y"); URI Z = new URIImpl("http://www.foo.org/Z"); IStatementBuffer buffer = new StatementBuffer(store, 100/* capacity */); buffer.add(X, OWL.SAMEAS, Y); buffer.add(Y, OWL.SAMEAS, Z); // write on the store. buffer.flush(); // verify statement(s). assertTrue(store.hasStatement(X, OWL.SAMEAS, Y)); assertTrue(store.hasStatement(Y, OWL.SAMEAS, Z)); final long nbefore = store.getStatementCount(); final Vocabulary vocab = store.getVocabulary(); final Rule r = new RuleOwlSameAs1b(store.getSPORelation() .getNamespace(), vocab); // apply the rule. applyRule(store, r, -1/*solutionCount*/,1/*mutationCount*/); /* * validate the state of the primary store. */ // told assertTrue(store.hasStatement(X, OWL.SAMEAS, Y)); assertTrue(store.hasStatement(Y, OWL.SAMEAS, Z)); // entailed assertTrue(store.hasStatement(X, OWL.SAMEAS, Z)); // final #of statements in the store. assertEquals(nbefore + 1, store.getStatementCount()); } finally { store.__tearDownUnitTest(); } }
Example 18
Source File: TestRuleOwlSameAs.java From database with GNU General Public License v2.0 | 2 votes |
/** * Test where the data satisifies the rule exactly once. * <p> * Note: This also verifies that we correctly filter out entailments where * <code>a == owl:sameAs</code>. * * <pre> * owl:sameAs2: (x owl:sameAs y), (x a z) -> (y a z). * </pre> * @throws Exception */ public void test_owlSameAs2() throws Exception { AbstractTripleStore store = getStore(); try { URI A = new URIImpl("http://www.foo.org/A"); URI Z = new URIImpl("http://www.foo.org/Z"); URI X = new URIImpl("http://www.foo.org/X"); URI Y = new URIImpl("http://www.foo.org/Y"); IStatementBuffer buffer = new StatementBuffer(store, 100/* capacity */); buffer.add(X, OWL.SAMEAS, Y); buffer.add(X, A, Z); // write on the store. buffer.flush(); // verify statement(s). assertTrue(store.hasStatement(X, OWL.SAMEAS, Y)); assertTrue(store.hasStatement(X, A, Z)); final long nbefore = store.getStatementCount(); final Vocabulary vocab = store.getVocabulary(); final Rule r = new RuleOwlSameAs2(store.getSPORelation() .getNamespace(), vocab); // apply the rule. applyRule(store, r, -1/* solutionCount */, 1/* mutationCount */); /* * validate the state of the primary store. */ // told assertTrue(store.hasStatement(X, OWL.SAMEAS, Y)); assertTrue(store.hasStatement(X, A, Z)); // entailed assertTrue(store.hasStatement(Y, A, Z)); // final #of statements in the store. assertEquals(nbefore + 1, store.getStatementCount()); } finally { store.__tearDownUnitTest(); } }
Example 19
Source File: TestRuleOwlSameAs.java From database with GNU General Public License v2.0 | 2 votes |
/** * Test where the data satisifies the rule exactly once. * <p> * Note: This also verifies that we correctly filter out entailments where * <code>a == owl:sameAs</code>. * * <pre> * owl:sameAs3: (x owl:sameAs y), (z a x) -> (z a y). * </pre> * @throws Exception */ public void test_owlSameAs3() throws Exception { AbstractTripleStore store = getStore(); try { URI A = new URIImpl("http://www.foo.org/A"); URI Z = new URIImpl("http://www.foo.org/Z"); URI X = new URIImpl("http://www.foo.org/X"); URI Y = new URIImpl("http://www.foo.org/Y"); { IStatementBuffer buffer = new StatementBuffer(store, 100/* capacity */); buffer.add(X, OWL.SAMEAS, Y); buffer.add(Z, A, X); // write on the store. buffer.flush(); } // verify statement(s). assertTrue(store.hasStatement(X, OWL.SAMEAS, Y)); assertTrue(store.hasStatement(Z, A, X)); final long nbefore = store.getStatementCount(); final Vocabulary vocab = store.getVocabulary(); final Rule r = new RuleOwlSameAs3(store.getSPORelation() .getNamespace(), vocab); // apply the rule. applyRule(store,r, -1/*solutionCount*/,1/*mutationCount*/); /* * validate the state of the primary store. */ // told assertTrue(store.hasStatement(X, OWL.SAMEAS, Y)); assertTrue(store.hasStatement(Z, A, X)); // entailed assertTrue(store.hasStatement(Z, A, Y)); // final #of statements in the store. assertEquals(nbefore + 1, store.getStatementCount()); } finally { store.__tearDownUnitTest(); } }
Example 20
Source File: TestRuleOwlEquivalentProperty.java From database with GNU General Public License v2.0 | 2 votes |
/** * Test where the data satisifies the rule exactly once. * * <pre> * (a owl:equivalentProperty b) -> (b owl:equivalentProperty a) * </pre> * @throws Exception */ public void test_owlEquivalentProperty() throws Exception { AbstractTripleStore store = getStore(); try { URI A = new URIImpl("http://www.foo.org/A"); URI B = new URIImpl("http://www.foo.org/B"); IStatementBuffer buffer = new StatementBuffer(store, 100/* capacity */); buffer.add(A, OWL.EQUIVALENTPROPERTY, B); // write on the store. buffer.flush(); // verify statement(s). assertTrue(store.hasStatement(A, OWL.EQUIVALENTPROPERTY, B)); final long nbefore = store.getStatementCount(); final Vocabulary vocab = store.getVocabulary(); final Rule r = new RuleOwlEquivalentProperty(store.getSPORelation() .getNamespace(), vocab); // apply the rule. applyRule(store, r, -1/*solutionCount*/,1/*mutationCount*/); /* * validate the state of the primary store. */ // told assertTrue(store.hasStatement(A, OWL.EQUIVALENTPROPERTY, B)); // entailed assertTrue(store.hasStatement(B, OWL.EQUIVALENTPROPERTY, A)); // final #of statements in the store. assertEquals(nbefore + 1, store.getStatementCount()); } finally { store.__tearDownUnitTest(); } }