Class: CrossLanguageSpotter::PointsMap
- Inherits:
-
Object
- Object
- CrossLanguageSpotter::PointsMap
- Defined in:
- lib/crosslanguagespotter/methods/context.rb
Instance Method Summary collapse
- #each(threshold, &block) ⇒ Object
-
#initialize(alpha) ⇒ PointsMap
constructor
A new instance of PointsMap.
- #points(pair) ⇒ Object
- #register_child_contribute(pair) ⇒ Object
- #register_context_contribute(pair, value) ⇒ Object
Constructor Details
#initialize(alpha) ⇒ PointsMap
Returns a new instance of PointsMap.
51 52 53 54 |
# File 'lib/crosslanguagespotter/methods/context.rb', line 51 def initialize(alpha) @alpha = alpha @points = Hash.new {|h,k| h[k]=0.0} end |
Instance Method Details
#each(threshold, &block) ⇒ Object
68 69 70 |
# File 'lib/crosslanguagespotter/methods/context.rb', line 68 def each(threshold, &block) @points.select{|k,v| v>=threshold}.each(&block) end |
#points(pair) ⇒ Object
56 57 58 |
# File 'lib/crosslanguagespotter/methods/context.rb', line 56 def points(pair) @points[pair] end |
#register_child_contribute(pair) ⇒ Object
64 65 66 |
# File 'lib/crosslanguagespotter/methods/context.rb', line 64 def register_child_contribute(pair) @points[pair] += 0.1 end |
#register_context_contribute(pair, value) ⇒ Object
60 61 62 |
# File 'lib/crosslanguagespotter/methods/context.rb', line 60 def register_context_contribute(pair,value) @points[pair] += 0.2*@alpha*value.to_f end |