Class: Mocodo::Entity
Instance Attribute Summary
#config_e, #config_h, #config_m, #config_s
Instance Method Summary
collapse
#initialize
Instance Method Details
#build_body(sentence) ⇒ Object
67
68
69
70
71
72
73
74
|
# File 'lib/mocodo/goo_language_analysis.rb', line 67
def build_body(sentence)
body = {}
self.config_e.each { |sym|
body[sym[0].id2name] = sym[1]
}
body['sentence'] = sentence
return body.to_json
end
|
53
54
55
56
57
|
# File 'lib/mocodo/goo_language_analysis.rb', line 53
def configure(options = {})
options.each do |key, value|
self.config_e[key] = value
end
end
|
#entity(sentence) ⇒ Object
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/mocodo/goo_language_analysis.rb', line 76
def entity sentence
uri = URI.parse("https://api.apigw.smt.docomo.ne.jp/gooLanguageAnalysis/v1/entity?APIKEY=#{@client.get_api_key}")
http = Net::HTTP.new('api.apigw.smt.docomo.ne.jp', 443)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.request_uri, {'Content-Type' =>'application/json'})
request.body = build_body(sentence)
response = nil
http.start do |h|
response = JSON.parse(h.request(request).body, symbolize_names: true)
end
return response[:ne_list]
end
|
#get_current_data(option = nil) ⇒ Object
59
60
61
62
63
64
65
|
# File 'lib/mocodo/goo_language_analysis.rb', line 59
def get_current_data(option=nil)
if option.nil?
return self.config_e
else
return self.config_e[option]
end
end
|