Class: TfIdf::Dictionary

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

Overview

辞書基底クラス

Direct Known Subclasses

DFs, IDFs

Instance Method Summary collapse

Constructor Details

#initializeDictionary

コンストラクタ



12
13
14
# File 'lib/dictionary.rb', line 12

def initialize
  @map = {}
end

Instance Method Details

#allObject

辞書全体を返却する

value

ハッシュテーブル



32
33
34
# File 'lib/dictionary.rb', line 32

def all
  return @map
end

#exists?(k) ⇒ Boolean

keyが存在するか検査する

k

検査するkey

return

true=存在する faluse=存在しない

Returns:

  • (Boolean)


39
40
41
# File 'lib/dictionary.rb', line 39

def exists?(k)
  return @map.key?(k)
end

#get(k) ⇒ Object

keyからvalueを取得する

k

key

return

value



26
27
28
# File 'lib/dictionary.rb', line 26

def get(k)
  return @map[k]
end

#set(k, v) ⇒ Object

辞書にkeyとvalueを設定する

k

key

v

value



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

def set(k, v)
  @map[k] = v
end