Class: Juman

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

Overview

coding: utf-8

Constant Summary collapse

Juman_Versin =
"7.0"
Hinshi =
["名詞","助詞","動詞","接尾辞","助動詞","特殊","指示詞","判定詞","未定義語","形容詞","副詞","接頭辞","接続詞","連体詞","感動詞"]
Category =
["","組織・団体","動物","植物","動物-部位","植物-部位","人工物-食べ物","人工物-衣類","人工物-乗り物","人工物-金銭","人工物-その他","自然物","場所-施設","場所-施設部位","場所-自然","場所-機能","場所-その他","抽象物","形・模様","","数量","時間"]
Domain =
["文化・芸術","レクリエーション","スポーツ","健康・医学","家庭・暮らし","料理・食事","交通","教育・学習","科学・技術","ビジネス","メディア","政治"]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string, id = nil, pos = nil) ⇒ Juman

Returns a new instance of Juman.



15
16
17
18
19
20
21
22
23
24
# File 'lib/juman_knp.rb', line 15

def initialize(string, id=nil, pos=nil)
  @id = id # please use for tilte, id , etc...
  @string = string
  @pos = pos # parts of speech(pos)
  @ma_arr = ma(string)
  
  unless pos == nil
    @specific_pos = words_of(pos)
  end
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



13
14
15
# File 'lib/juman_knp.rb', line 13

def id
  @id
end

#ma_arrObject (readonly)

Returns the value of attribute ma_arr.



13
14
15
# File 'lib/juman_knp.rb', line 13

def ma_arr
  @ma_arr
end

#posObject (readonly)

Returns the value of attribute pos.



13
14
15
# File 'lib/juman_knp.rb', line 13

def pos
  @pos
end

#stringObject (readonly)

Returns the value of attribute string.



13
14
15
# File 'lib/juman_knp.rb', line 13

def string
  @string
end

Instance Method Details

#array_of(i) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/juman_knp.rb', line 26

def array_of(i)
  array_of_i = Array.new
  
  case i
  when 0..10
    @ma_arr.each{|e| array_of_i.push(e[i])}
  # 代表表記
  when 17
    @ma_arr.each{|e| array_of_i.push(get_info(e, "代表表記"))}
  # 漢字読み
  when 18
    @ma_arr.each{|e| array_of_i.push(get_info(e, "漢字読み"))}
  # Category
  when 19
    @ma_arr.each{|e| array_of_i.push(get_info(e, "カテゴリ"))}
  # Domain
  when 20
    @ma_arr.each{|e| array_of_i.push(get_info(e, "ドメイン"))}
  else

  end
  return array_of_i
end

#words_of(pos) ⇒ Object

filter of pos



51
52
53
54
55
56
57
58
# File 'lib/juman_knp.rb', line 51

def words_of(pos)
  hinshi_arr = Array.new
  pos.each do |h|
    @ma_arr.each{|array_of| hinshi_arr.push(array_of) if h == array_of[3]}
  end
  @ma_arr = hinshi_arr
  return hinshi_arr
end