[ 
https://issues.apache.org/jira/browse/RYA-417?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16320714#comment-16320714
 ] 

ASF GitHub Bot commented on RYA-417:
------------------------------------

Github user ejwhite922 commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/255#discussion_r160738522
  
    --- Diff: 
extras/rya.forwardchain/src/main/java/org/apache/rya/forwardchain/rule/Ruleset.java
 ---
    @@ -0,0 +1,166 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.rya.forwardchain.rule;
    +
    +import java.util.Collection;
    +import java.util.HashSet;
    +import java.util.Map;
    +import java.util.Set;
    +import java.util.concurrent.ConcurrentHashMap;
    +
    +import org.apache.log4j.Logger;
    +import org.openrdf.query.algebra.StatementPattern;
    +
    +import com.google.common.base.Preconditions;
    +
    +/**
    + * Represents a set of forward-chaining {@link Rule}s and their 
relationships.
    + */
    +public class Ruleset {
    +    private final Set<Rule> rules;
    +    private final Map<Rule, Set<Rule>> successors;
    +    private final Map<Rule, Set<Rule>> predecessors;
    +
    +    private final Logger logger = Logger.getLogger(this.getClass());
    +
    +    /**
    +     * Constructor. Takes in a set of rules and determines their 
dependencies.
    +     * @param rules The complete set of rules to process; should not be 
null.
    +     */
    +    public Ruleset(Collection<Rule> rules) {
    +        Preconditions.checkNotNull(rules);
    +        this.rules = new HashSet<>();
    +        for (Rule rule : rules) {
    +            if (rule != null) {
    +                this.rules.add(rule);
    +            }
    +        }
    +        successors = new ConcurrentHashMap<>();
    +        predecessors = new ConcurrentHashMap<>();
    +        // Build the dependency graph of all the rules, in both directions
    +        for (Rule rule : rules) {
    +            successors.put(rule, new HashSet<>());
    +            predecessors.put(rule, new HashSet<>());
    +        }
    +        for (Rule rule1 : rules) {
    +            for (Rule rule2 : rules) {
    +                if (canTrigger(rule1, rule2)) {
    --- End diff --
    
    Can a rule trigger itself?  It would then be a successor and predecessor of 
itself


> Implement a forward-chaining rules engine (SPIN)
> ------------------------------------------------
>
>                 Key: RYA-417
>                 URL: https://issues.apache.org/jira/browse/RYA-417
>             Project: Rya
>          Issue Type: New Feature
>            Reporter: Jesse Hatfield
>            Assignee: Jesse Hatfield
>
> Implement a forward-chaining reasoner that:
> * Runs as a batch process
> * Operates on user-defined [SPIN|http://spinrdf.org] rules
> * Inserts derived information back into Rya
> * Iterates until no new information can be derived



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to