use of org.apache.stanbol.rules.manager.KB in project stanbol by apache.
the class RuleParserTest method testParser.
@Test
public void testParser() {
try {
KB kReSKB = RuleParserImpl.parse("http://incubator.apache.org/stanbol/rules/test/", kReSRule);
if (kReSKB != null) {
RuleList kReSRuleList = kReSKB.getRuleList();
if (kReSRuleList != null) {
for (Rule kReSRule : kReSRuleList) {
log.debug("RULE : " + kReSRule.toString());
}
}
log.debug("RULE LIST IS NULL");
} else {
log.debug("KB IS NULL");
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.apache.stanbol.rules.manager.KB in project stanbol by apache.
the class RuleParserImpl method parse.
public static KB parse(String namespace, InputStream inStream) {
kb = new KB(namespace);
Reader reader = new InputStreamReader(inStream);
RuleParserImpl parser = new RuleParserImpl(reader);
try {
parser.start();
} catch (TokenMgrError e) {
throw new IllegalStateException(e);
} catch (ParseException e) {
throw new IllegalStateException(e);
}
return kb;
}
use of org.apache.stanbol.rules.manager.KB in project stanbol by apache.
the class SPARQLAdpterTest method setUp.
@Before
public void setUp() {
String separator = System.getProperty("line.separator");
String recipeString = "kres = <http://kres.iks-project.eu/ontology.owl#> . " + separator + "foaf = <http://xmlns.com/foaf/0.1/> . " + separator + "rule1[ is(kres:Person, ?x) . has(kres:friend, ?x, ?y) -> is(foaf:Person, ?x) . has(foaf:knows, ?x, ?y) . is(foaf:Person, ?y)] . " + "rule2[ is(kres:Person, ?x) . values(kres:age, ?x, ?age) . endsWith(?t, \"string\") . gt(?age, sum(sub(70, ?k), ?z)) -> is(kres:OldPerson, ?x)]";
KB kb = RuleParserImpl.parse("http://incubator.apache.com/stanbol/rules/adapters/jena/test/", recipeString);
recipeGood = new RecipeImpl(new IRI("http://incubator.apache.com/stanbol/rules/adapters/jena/test"), "A recipe.", kb.getRuleList());
recipeString = "kres = <http://kres.iks-project.eu/ontology.owl#> . " + separator + "foaf = <http://xmlns.com/foaf/0.1/> . " + separator + "rule1[ is(kres:Person, ?x) . has(kres:friend, ?x, ?y) -> is(foaf:Person, ?x) . has(foaf:knows, ?x, ?y) . is(foaf:Person, ?y)] . " + "rule2[ is(kres:Person, ?x) . same(\"Andrea\", localname(?x)) -> is(kres:OldPerson, ?x)]";
kb = RuleParserImpl.parse("http://incubator.apache.com/stanbol/rules/adapters/jena/test/", recipeString);
recipeWrong = new RecipeImpl(new IRI("http://incubator.apache.com/stanbol/rules/adapters/jena/test"), "A recipe.", kb.getRuleList());
}
Aggregations