Class: ProgramR::GraphMaster
- Inherits:
-
Object
- Object
- ProgramR::GraphMaster
- Defined in:
- lib/programr/graph_master.rb
Instance Attribute Summary collapse
-
#graph ⇒ Object
readonly
Returns the value of attribute graph.
Instance Method Summary collapse
- #get_reaction(stimula, last_said, cur_topic, starGreedy) ⇒ Object
-
#initialize ⇒ GraphMaster
constructor
A new instance of GraphMaster.
- #learn(category) ⇒ Object
- #merge(aCache) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ GraphMaster
Returns a new instance of GraphMaster.
8 9 10 |
# File 'lib/programr/graph_master.rb', line 8 def initialize @graph = Node.new end |
Instance Attribute Details
#graph ⇒ Object (readonly)
Returns the value of attribute graph.
7 8 9 |
# File 'lib/programr/graph_master.rb', line 7 def graph @graph end |
Instance Method Details
#get_reaction(stimula, last_said, cur_topic, starGreedy) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/programr/graph_master.rb', line 27 def get_reaction(stimula, last_said,cur_topic,starGreedy) path = "#{stimula} #{THAT} #{last_said} #{TOPIC} #{cur_topic}" template = @graph.get_template(path.split(/\s+/),starGreedy) return template.value unless(template == nil) return [] end |
#learn(category) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/programr/graph_master.rb', line 16 def learn(category) path = category.get_pattern path += [THAT] + category.get_that unless (category.get_that).empty? path += [TOPIC] + category.topic.split(/\s+/) if category.topic @graph.learn(category, path) end |
#merge(aCache) ⇒ Object
12 13 14 |
# File 'lib/programr/graph_master.rb', line 12 def merge(aCache) @graph.merge(aCache.graph) end |
#to_s ⇒ Object
23 24 25 |
# File 'lib/programr/graph_master.rb', line 23 def to_s @graph.inspectNode() end |