Class: Igo::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.



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

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.



9
10
11
# File 'lib/igo/dictionary.rb', line 9

def cost
  @cost
end

#is_spaceObject

Returns the value of attribute is_space.



9
10
11
# File 'lib/igo/dictionary.rb', line 9

def is_space
  @is_space
end

#left_idObject

Returns the value of attribute left_id.



9
10
11
# File 'lib/igo/dictionary.rb', line 9

def left_id
  @left_id
end

#lengthObject

Returns the value of attribute length.



9
10
11
# File 'lib/igo/dictionary.rb', line 9

def length
  @length
end

#prevObject

Returns the value of attribute prev.



9
10
11
# File 'lib/igo/dictionary.rb', line 9

def prev
  @prev
end

#right_idObject

Returns the value of attribute right_id.



9
10
11
# File 'lib/igo/dictionary.rb', line 9

def right_id
  @right_id
end

#startObject

Returns the value of attribute start.



9
10
11
# File 'lib/igo/dictionary.rb', line 9

def start
  @start
end

#word_idObject

Returns the value of attribute word_id.



9
10
11
# File 'lib/igo/dictionary.rb', line 9

def word_id
  @word_id
end

Class Method Details

.make_BOSEOSObject



21
22
23
# File 'lib/igo/dictionary.rb', line 21

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