Class: Sbn::StringCovariable
- Defined in:
- lib/sbn/string_variable.rb
Overview
:nodoc:
Constant Summary
Constants inherited from Variable
Variable::NEGLIGIBLE_PROBABILITY
Instance Attribute Summary collapse
-
#text_to_match ⇒ Object
readonly
Returns the value of attribute text_to_match.
Attributes inherited from Variable
#children, #name, #parents, #probability_table, #states
Instance Method Summary collapse
-
#evidence_name ⇒ Object
:nodoc:.
-
#get_observed_state(evidence) ⇒ Object
:nodoc:.
-
#initialize(net, manager_name, text_to_match, probabilities) ⇒ StringCovariable
constructor
A new instance of StringCovariable.
-
#set_in_evidence?(evidence) ⇒ Boolean
:nodoc:.
- #to_xmlbif_variable(xml) ⇒ Object
-
#transform_evidence_value(val) ⇒ Object
:nodoc:.
Methods inherited from Variable
#==, #===, #add_child, #add_child_no_recurse, #add_parent, #add_parent_no_recurse, #add_sample_point, #can_be_evaluated?, #eql?, #evaluate_marginal, #generate_probability_table, #get_random_state, #get_random_state_with_markov_blanket, #is_complete_evidence?, #set_probabilities, #set_probabilities_from_sample_points!, #set_probability, #set_states, #to_s, #to_xmlbif_definition
Constructor Details
#initialize(net, manager_name, text_to_match, probabilities) ⇒ StringCovariable
Returns a new instance of StringCovariable.
5 6 7 8 9 10 11 |
# File 'lib/sbn/string_variable.rb', line 5 def initialize(net, manager_name, text_to_match, probabilities) @@covar_count ||= 0 @@covar_count += 1 @manager_name = manager_name @text_to_match = text_to_match.downcase super(net, "#{@manager_name}_covar_#{@@covar_count}", probabilities) end |
Instance Attribute Details
#text_to_match ⇒ Object (readonly)
Returns the value of attribute text_to_match.
3 4 5 |
# File 'lib/sbn/string_variable.rb', line 3 def text_to_match @text_to_match end |
Instance Method Details
#evidence_name ⇒ Object
:nodoc:
20 21 22 |
# File 'lib/sbn/string_variable.rb', line 20 def evidence_name # :nodoc: @manager_name end |
#get_observed_state(evidence) ⇒ Object
:nodoc:
24 25 26 |
# File 'lib/sbn/string_variable.rb', line 24 def get_observed_state(evidence) # :nodoc: evidence[@manager_name].include?(@text_to_match) ? :true : :false end |
#set_in_evidence?(evidence) ⇒ Boolean
:nodoc:
32 33 34 |
# File 'lib/sbn/string_variable.rb', line 32 def set_in_evidence?(evidence) # :nodoc: evidence.has_key?(@manager_name) end |
#to_xmlbif_variable(xml) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/sbn/string_variable.rb', line 13 def to_xmlbif_variable(xml) super(xml) do |x| x.property("ManagerVariableName = #{@manager_name.to_s}") x.property("TextToMatch = #{@text_to_match.inspect}") end end |
#transform_evidence_value(val) ⇒ Object
:nodoc:
28 29 30 |
# File 'lib/sbn/string_variable.rb', line 28 def transform_evidence_value(val) # :nodoc: raise "Evidence should not be provided for string covariables" end |