diff options
Diffstat (limited to 'lib/nlp_ruby/semirings.rb')
-rw-r--r-- | lib/nlp_ruby/semirings.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/nlp_ruby/semirings.rb b/lib/nlp_ruby/semirings.rb index 83551a9..fda4683 100644 --- a/lib/nlp_ruby/semirings.rb +++ b/lib/nlp_ruby/semirings.rb @@ -26,6 +26,16 @@ class ViterbiSemiring < Semiring end end +class ViterbiLogSemiring < Semiring + def initialize + @add = Proc.new { |a,b| [a,b].max } + @multiply = Proc.new { |a,b| a+b } + @one = 0.0 + @null = -1.0/0.0 + @convert = Proc.new { |v| v } + end +end + class InsideSemiring < Semiring def initialize @add = Proc.new { |a,b| a+b } |