Class: ViterbiNode

Inherits:
Object
  • Object
show all
Defined in:
lib/igo/dictionary.rb

Overview

Viterbiアルゴリズムで使用されるノードクラス

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(word_id, start, length, left_id, right_id, is_space) ⇒ ViterbiNode

Returns a new instance of ViterbiNode.



8
9
10
11
12
13
14
15
16
17
# File 'lib/igo/dictionary.rb', line 8

def initialize(word_id, start, length, left_id, right_id, is_space)
  @cost = 0            # 始点からノードまでの総コスト
  @prev = nil          # コスト最小の前方のノードへのリンク
  @word_id = word_id   # 単語ID
  @start = start       # 入力テキスト内での形態素の開始位置
  @length = length     # 形態素の表層形の長さ(文字数)
  @left_id = left_id   # 左文脈ID
  @right_id = right_id # 右文脈ID
  @is_space = is_space # 形態素の文字種(文字カテゴリ)が空白かどうか
end

Instance Attribute Details

#costObject

Returns the value of attribute cost.



7
8
9
# File 'lib/igo/dictionary.rb', line 7

def cost
  @cost
end

#is_spaceObject

Returns the value of attribute is_space.



7
8
9
# File 'lib/igo/dictionary.rb', line 7

def is_space
  @is_space
end

#left_idObject

Returns the value of attribute left_id.



7
8
9
# File 'lib/igo/dictionary.rb', line 7

def left_id
  @left_id
end

#lengthObject

Returns the value of attribute length.



7
8
9
# File 'lib/igo/dictionary.rb', line 7

def length
  @length
end

#prevObject

Returns the value of attribute prev.



7
8
9
# File 'lib/igo/dictionary.rb', line 7

def prev
  @prev
end

#right_idObject

Returns the value of attribute right_id.



7
8
9
# File 'lib/igo/dictionary.rb', line 7

def right_id
  @right_id
end

#startObject

Returns the value of attribute start.



7
8
9
# File 'lib/igo/dictionary.rb', line 7

def start
  @start
end

#word_idObject

Returns the value of attribute word_id.



7
8
9
# File 'lib/igo/dictionary.rb', line 7

def word_id
  @word_id
end

Class Method Details

.make_BOSEOSObject



19
20
21
# File 'lib/igo/dictionary.rb', line 19

def self.make_BOSEOS
  return ViterbiNode.new(0, 0, 0, 0, 0, false)
end