Package org.apache.marmotta.kiwi.reasoner.model.program

Examples of org.apache.marmotta.kiwi.reasoner.model.program.Rule


                }
            }
            result.append("    ],");
            result.append("    \"rules\": [\n");
            for(Iterator<Rule> it = justification.getSupportingRules().iterator(); it.hasNext(); ) {
                Rule r = it.next();
                result.append("      \""+r.toString().replace("\"","'")+"\"");
                if(it.hasNext()) {
                    result.append(",\n");
                } else {
                    result.append("\n");
                }
View Full Code Here



            // now we remove the rule2 (symmetric rule) from the program, update the program in the database and then
            // inform the reasoning engine about the removed rule
            Program p = rcon.loadProgram("simple");
            Rule removed = null;
            Iterator<Rule> it = p.getRules().iterator();
            while(it.hasNext()) {
                Rule r = it.next();
                if(r.getName().equals("rule2")) {
                    it.remove();
                    removed = r;
                }
            }
            Assert.assertNotNull("rule 2 not found in program", removed);
View Full Code Here

        if(cached != null) {
            return (Rule) cached.getObjectValue();
        } else {

            Rule result = KWRLProgramParser.parseRule(row.getString("body"),namespaces, valueFactory);
            result.setId(row.getLong("id"));
            result.setName(row.getString("name"));
            result.setDescription(row.getString("description"));

            ruleIdCache.put(new Element(result.getId(), result));

            return result;
        }
    }
View Full Code Here

                }
            }
            result.append("    ],");
            result.append("    \"rules\": [\n");
            for(Iterator<Rule> it = justification.getSupportingRules().iterator(); it.hasNext(); ) {
                Rule r = it.next();
                result.append("      \""+r.toString().replace("\"","'")+"\"");
                if(it.hasNext()) {
                    result.append(",\n");
                } else {
                    result.append("\n");
                }
View Full Code Here

    };

    @Test
    public void testRule1() throws Exception {
        String rule = "($1 http://www.w3.org/2000/01/rdf-schema#subClassOf $2), ($2 http://www.w3.org/2000/01/rdf-schema#subClassOf $3) -> ($1 http://www.w3.org/2000/01/rdf-schema#subClassOf $3)";
        Rule r = KWRLProgramParser.parseRule(rule,repository.getValueFactory());

        Assert.assertNotNull(r);
        Assert.assertEquals(2, r.getBody().size());
        Assert.assertTrue(r.getHead().getSubject().isVariableField());
        Assert.assertTrue(r.getHead().getProperty().isResourceField());
        Assert.assertTrue(r.getHead().getObject().isVariableField());
    }
View Full Code Here

    }

    @Test
    public void testRule2() throws Exception {
        String rule = "($1 rdfs:subClassOf $2), ($2 rdfs:subClassOf $3) -> ($1 rdfs:subClassOf $3)";
        Rule r = KWRLProgramParser.parseRule(rule, ImmutableMap.of("rdfs", "http://www.w3.org/2000/01/rdf-schema#"), repository.getValueFactory());

        Assert.assertNotNull(r);
        Assert.assertEquals(2, r.getBody().size());
        Assert.assertTrue(r.getHead().getSubject().isVariableField());
        Assert.assertTrue(r.getHead().getProperty().isResourceField());
        Assert.assertTrue(r.getHead().getObject().isVariableField());
    }
View Full Code Here


            // now we remove the rule2 (symmetric rule) from the program, update the program in the database and then
            // inform the reasoning engine about the removed rule
            Program p = rcon.loadProgram("simple");
            Rule removed = null;
            Iterator<Rule> it = p.getRules().iterator();
            while(it.hasNext()) {
                Rule r = it.next();
                if(r.getName().equals("rule2")) {
                    it.remove();
                    removed = r;
                }
            }
            Assert.assertNotNull("rule 2 not found in program", removed);
View Full Code Here


            // now we remove the rule2 (symmetric rule) from the program, update the program in the database and then
            // inform the reasoning engine about the removed rule
            Program p = rcon.loadProgram("simple");
            Rule removed = null;
            Iterator<Rule> it = p.getRules().iterator();
            while(it.hasNext()) {
                Rule r = it.next();
                if(r.getName().equals("rule2")) {
                    it.remove();
                    removed = r;
                }
            }
            Assert.assertNotNull("rule 2 not found in program", removed);
View Full Code Here

TOP

Related Classes of org.apache.marmotta.kiwi.reasoner.model.program.Rule

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.