rules | [RW] |
This method is used by the parser. Rules are stored in a hash that maps logical functor names (representing rule tags) to a hash that maps natural numbers ≥ 1 (representing antecedent length) to rules.
E.g.,:
@rules = [ "neg_p" => [ 0=>[ ~p(X), ~p(1, Y),.. ], 1=>[ ~p(U)<-a(U), ..
# File AS.dat.rb, line 20 20: def initialize 21: @rules = Hash.new { |h1,k1| 22: h1[k1] = Hash.new{ |h2, k2| h2[k2] = [] } 23: } 24: $kb = self # FIXME good for now, but remove once .. 25: end
Add a Rule r to this KnowledgeBase. Method used by parser.
# File AS.dat.rb, line 28 28: def <<(r) 29: con, ant = r.consequent, r.antecedent 30: n = r.antecedent.length 31: @rules[con.rule_tag][n] << r 32: ?? 33: end
Return dump of KnowledgeBase as ASCII string.
# File AS.dat.rb, line 57 57: def inspect 58: @rules.keys.sort.collect { |id| 59: "=== Regels voor #{id}: =========\n" + 60: @rules[id].collect { |rule| 61: rule.inspect }.join("\n") 62: }.join("\n\n") 63: end