mocodo 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.project +17 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/README.md +114 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/example/hqdefault.jpg +0 -0
- data/example/mocodo-example.rb +134 -0
- data/lib/mocodo.rb +10 -0
- data/lib/mocodo/character_recognition.rb +186 -0
- data/lib/mocodo/client.rb +15 -0
- data/lib/mocodo/dialogue.rb +51 -0
- data/lib/mocodo/goo_language_analysis.rb +165 -0
- data/lib/mocodo/image_recognition.rb +47 -0
- data/lib/mocodo/knowledge_qa.rb +21 -0
- data/lib/mocodo/sentence_understanding.rb +51 -0
- data/lib/mocodo/text_to_speech.rb +82 -0
- data/lib/mocodo/version.rb +3 -0
- data/lib/mocodo/web_curation.rb +74 -0
- data/mocodo.gemspec +24 -0
- metadata +107 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2c6d6e0ce71bd29c045503282f657651a2caec60
|
4
|
+
data.tar.gz: bd1cd7d123b6fd37cbd9bb8cbf67717422115538
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 80f55fe30375e206dcc359573d107564eb9c13bf863fedb79c895671dc0c704fa038c47f02875750399f6f7adea2846f3cdd19c9308a68a0c700001277ea3888
|
7
|
+
data.tar.gz: c3eb9a5c46a4add0333861c45692251556a126664bd2b07550b4ef800cf6cdc16112ff6a34247add4a79df279ffbe828ece043c92ee785a7e565213e27cbfbe3
|
data/.gitignore
ADDED
data/.project
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<projectDescription>
|
3
|
+
<name>mocodo</name>
|
4
|
+
<comment></comment>
|
5
|
+
<projects>
|
6
|
+
</projects>
|
7
|
+
<buildSpec>
|
8
|
+
<buildCommand>
|
9
|
+
<name>org.eclipse.dltk.core.scriptbuilder</name>
|
10
|
+
<arguments>
|
11
|
+
</arguments>
|
12
|
+
</buildCommand>
|
13
|
+
</buildSpec>
|
14
|
+
<natures>
|
15
|
+
<nature>org.eclipse.dltk.ruby.core.nature</nature>
|
16
|
+
</natures>
|
17
|
+
</projectDescription>
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
# Mocodo
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/mocodo`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
docomoAPIのクライアントライブラリです。
|
6
|
+
apiについての説明は[API共通ガイドライン](https://dev.smt.docomo.ne.jp/?p=docs.api.page&api_name=image_recognition&p_name=api_usage_scenario)へ
|
7
|
+
公式サイトは[docomo Developer support](https://dev.smt.docomo.ne.jp/)
|
8
|
+
|
9
|
+
質問等ありましたらTwitter:[@flum_](https://twitter.com/flum_)までお願いします。
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'mocodo'
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
$ gem install mocodo
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
requireしてから
|
30
|
+
|
31
|
+
```
|
32
|
+
dialogue = Mocodo::Dialogue.new(api_key)
|
33
|
+
puts dialogue.create_dialogue "こんにちは"
|
34
|
+
```
|
35
|
+
|
36
|
+
たったこれだけで会話することができます。
|
37
|
+
詳しいパラメータ等は、ガイドラインを参照して
|
38
|
+
```
|
39
|
+
dialogue.configure config = {
|
40
|
+
:mode=>"dialog",
|
41
|
+
}
|
42
|
+
```
|
43
|
+
の様な感じでセットしてください。
|
44
|
+
|
45
|
+
##Supported APIs
|
46
|
+
>画像認識
|
47
|
+
|
48
|
+
>発話理解
|
49
|
+
|
50
|
+
>音声合成
|
51
|
+
|
52
|
+
>>漢字かな混じり文
|
53
|
+
|
54
|
+
>>SSML
|
55
|
+
|
56
|
+
>>カナアクセント文
|
57
|
+
|
58
|
+
>※文字認識
|
59
|
+
|
60
|
+
>>情景画像認識要求
|
61
|
+
|
62
|
+
>>情景画像認識結果取得
|
63
|
+
|
64
|
+
>>情景画像認識取消
|
65
|
+
|
66
|
+
>>行画像認識要求
|
67
|
+
|
68
|
+
>>文章画像認識要求
|
69
|
+
|
70
|
+
>>文章画像認識結果取得
|
71
|
+
|
72
|
+
>>文章画像認識取消
|
73
|
+
|
74
|
+
>>文章画像レイアウト認識要求
|
75
|
+
|
76
|
+
>言語解析
|
77
|
+
|
78
|
+
>>形態素解析
|
79
|
+
|
80
|
+
>>固定表現抽出
|
81
|
+
|
82
|
+
>>語句類似度算出
|
83
|
+
|
84
|
+
>>ひらがな化
|
85
|
+
|
86
|
+
>雑談対話
|
87
|
+
|
88
|
+
>トレンド記事抽出
|
89
|
+
|
90
|
+
>>ジャンル情報の取得
|
91
|
+
|
92
|
+
>>記事取得
|
93
|
+
|
94
|
+
>>キーワード検索
|
95
|
+
|
96
|
+
>知識Q&A
|
97
|
+
|
98
|
+
##Notice
|
99
|
+
※印の付いたAPIは現在エラーが発生して使用できません。
|
100
|
+
ソースを見てわかる人は修正お願いします。
|
101
|
+
|
102
|
+
## Development
|
103
|
+
|
104
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
105
|
+
|
106
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
107
|
+
|
108
|
+
## Contributing
|
109
|
+
|
110
|
+
1. Fork it ( https://github.com/[my-github-username]/mocodo/fork )
|
111
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
112
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
113
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
114
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "mocodo"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
Binary file
|
@@ -0,0 +1,134 @@
|
|
1
|
+
# Coding: UTF-8
|
2
|
+
lib = File.expand_path('../../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'mocodo'
|
5
|
+
|
6
|
+
api_key = ''
|
7
|
+
|
8
|
+
###Mocodoの使用例
|
9
|
+
####詳しい説明は https://github.com/flum1025/Mocodo
|
10
|
+
####apiについての説明は https://dev.smt.docomo.ne.jp/?p=docs.api.page&api_name=image_recognition&p_name=api_usage_scenario
|
11
|
+
####公式サイトは https://dev.smt.docomo.ne.jp/?p=index
|
12
|
+
|
13
|
+
###Copyright c @flum_ 2015
|
14
|
+
###Twitter:@flum https://twitter.com/flum_
|
15
|
+
###WEBサイト http://flum.pw/
|
16
|
+
|
17
|
+
###画像認識
|
18
|
+
recognize = Mocodo::Recognize.new(api_key)
|
19
|
+
p recognize.image_recognition('http://i.ytimg.com/vi/kmqAuILzS14/hqdefault.jpg') #WEB上のがそうURL
|
20
|
+
p recognize.local_image_recognition(File.join(path, 'mocodo/hqdefault.jpg')) #ローカルの画像パス
|
21
|
+
###発話理解
|
22
|
+
sentence = Mocodo::SentenceUnderstanding.new(api_key)
|
23
|
+
sentence.configure config = {
|
24
|
+
:projectKey=> "OSU",
|
25
|
+
:appInfo=> {
|
26
|
+
:appName=> "hoge_app",
|
27
|
+
:appKey=> "hoge_app01"
|
28
|
+
},
|
29
|
+
:clientVer=> "1.0.0",
|
30
|
+
:dialogMode=> "off",
|
31
|
+
:language=> "ja",
|
32
|
+
:userId=> "fly",
|
33
|
+
:location=> {
|
34
|
+
:lat=> "139.766084",
|
35
|
+
:lon=> "35.681382",
|
36
|
+
},
|
37
|
+
}
|
38
|
+
sentence.sentenceUnderstanding("電話して")
|
39
|
+
sentence.get_current_data
|
40
|
+
|
41
|
+
###音声合成
|
42
|
+
###共通概要
|
43
|
+
#レスポンスは全てbinary形式です。
|
44
|
+
###漢字かな混じり文
|
45
|
+
textToSpeech = Mocodo::TextToSpeech.new(api_key)
|
46
|
+
textToSpeech.configure config = {
|
47
|
+
:Command=> "AP_Synth",
|
48
|
+
:SpeechRate=> "1.15",
|
49
|
+
:AudioFileFormat=> "0",
|
50
|
+
}
|
51
|
+
binary1 = textToSpeech.textToSpeech "のあちゃんかわいい"
|
52
|
+
###SSML
|
53
|
+
textToSpeechSsml = Mocodo::TextToSpeechSsml.new(api_key)
|
54
|
+
binary2 = textToSpeechSsml.textToSpeech "ゆあちゃんかわいい"
|
55
|
+
###カナアクセント文
|
56
|
+
textToSpeechKanaAccent = Mocodo::TextToSpeechKanaAccent.new(api_key)
|
57
|
+
binary3 = textToSpeechKanaAccent.textToSpeech "ふらんちゃんちゃんかわいい"
|
58
|
+
|
59
|
+
###文字認識
|
60
|
+
###共通概要
|
61
|
+
#現時点ではエラーが出て使えません。lib/characterRecognition.rb内のimage_openでの画像の読み込み方法を変えれば、全てのメソッドが使えるようになりそうですが、いまいちわからないのでこのまま。
|
62
|
+
#わかる方いたらプルリクお願いします。
|
63
|
+
###情景画像認識要求
|
64
|
+
scene = Mocodo::SceneRecognition.new(api_key)
|
65
|
+
scene.recognitionRequest('http://i.ytimg.com/vi/kmqAuILzS14/hqdefault.jpg')
|
66
|
+
###情景画像認識結果取得
|
67
|
+
#scene.getRecognition #recognitionRequestを実行していればidは自動で入力されます。引数で直接指定もできます。
|
68
|
+
###情景画像認識取消
|
69
|
+
#scene.cancelRecognition #recognitionRequestを実行していればidは自動で入力されます。引数で直接指定もできます。
|
70
|
+
###行画像認識要求
|
71
|
+
line = Mocodo::Line.new(api_key)
|
72
|
+
line.get_line('http://i.ytimg.com/vi/kmqAuILzS14/hqdefault.jpg')
|
73
|
+
###文章画像認識要求
|
74
|
+
document = Mocodo::DocumentRecognition.new(api_key)
|
75
|
+
document.recognitionRequest('http://i.ytimg.com/vi/kmqAuILzS14/hqdefault.jpg')
|
76
|
+
###文章画像認識結果取得
|
77
|
+
#document.getRecognition #recognitionRequestを実行していればidは自動で入力されます。引数で直接指定もできます。
|
78
|
+
###文章画像認識取消
|
79
|
+
#document.cancelRecognition #recognitionRequestを実行していればidは自動で入力されます。引数で直接指定もできます。
|
80
|
+
###文章画像レイアウト認識要求
|
81
|
+
layout = Mocodo::Layout.new(api_key)
|
82
|
+
layout.get_layout('http://i.ytimg.com/vi/kmqAuILzS14/hqdefault.jpg')
|
83
|
+
|
84
|
+
###言語解析
|
85
|
+
###形態素解析
|
86
|
+
morph = Mocodo::Morph.new(api_key)
|
87
|
+
morph.configure config={
|
88
|
+
:request_id=>"record001",
|
89
|
+
:info_filter=>"form"
|
90
|
+
}
|
91
|
+
morph.morph "たおはホモ"
|
92
|
+
###固定表現抽出
|
93
|
+
entity = Mocodo::Entity.new(api_key)
|
94
|
+
entity.configure config={
|
95
|
+
:class_filter=>"ART|ORG|PSN|LOC|DAT|TIM"
|
96
|
+
}
|
97
|
+
entity.entity "ふらんはノンケ"
|
98
|
+
###語句類似度算出
|
99
|
+
similarity = Mocodo::Similarity.new(api_key)
|
100
|
+
similarity.similarity "のあちゃん","ゆあちゃん"
|
101
|
+
###ひらがな化
|
102
|
+
hiragana = Mocodo::Hiragana.new(api_key)
|
103
|
+
hiragana.configure config={
|
104
|
+
:output_type=>"hiragana"
|
105
|
+
}
|
106
|
+
hiragana.hiragana "Fラン私立大学"
|
107
|
+
|
108
|
+
###雑談対話
|
109
|
+
dialogue = Mocodo::Dialogue.new(api_key)
|
110
|
+
dialogue.configure config = {
|
111
|
+
:mode=>"dialog",
|
112
|
+
:context=>"1234567890",
|
113
|
+
}
|
114
|
+
dialogue.create_dialogue "こんにちは"
|
115
|
+
dialogue.get_current_data
|
116
|
+
|
117
|
+
###トレンド記事抽出
|
118
|
+
###ジャンル情報の取得
|
119
|
+
genre = Mocodo::Genre.new(api_key)
|
120
|
+
genre.get_genre
|
121
|
+
###記事取得
|
122
|
+
contents = Mocodo::Contents.new(api_key)
|
123
|
+
contents.get_contents config={
|
124
|
+
:genreId=>"1",
|
125
|
+
}
|
126
|
+
###キーワード検索
|
127
|
+
search = Mocodo::Search.new(api_key)
|
128
|
+
search.search_contents config={
|
129
|
+
:keyword=>"ラーメン"
|
130
|
+
}
|
131
|
+
|
132
|
+
###知識Q&A
|
133
|
+
qa = Mocodo::KnowledgeQA.new(api_key)
|
134
|
+
qa.create_qa "今日は何日"
|
data/lib/mocodo.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require "mocodo/version"
|
2
|
+
require "mocodo/character_recognition"
|
3
|
+
require "mocodo/client"
|
4
|
+
require "mocodo/dialogue"
|
5
|
+
require "mocodo/goo_language_analysis"
|
6
|
+
require "mocodo/image_recognition"
|
7
|
+
require "mocodo/knowledge_qa"
|
8
|
+
require "mocodo/sentence_understanding"
|
9
|
+
require "mocodo/text_to_speech"
|
10
|
+
require "mocodo/web_curation"
|
@@ -0,0 +1,186 @@
|
|
1
|
+
require 'net/https'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Mocodo
|
6
|
+
class Recognize
|
7
|
+
def initialize(api_key)
|
8
|
+
@client = Client.new(api_key)
|
9
|
+
end
|
10
|
+
|
11
|
+
def image_open(path)
|
12
|
+
if /^http/ =~ path
|
13
|
+
#image = File.binread(open(path))
|
14
|
+
image = open(path)
|
15
|
+
else
|
16
|
+
#image = File.binread(File.open(path))
|
17
|
+
image = File.open(path)
|
18
|
+
end
|
19
|
+
return image
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class SceneRecognition < Recognize
|
24
|
+
attr_accessor :id
|
25
|
+
|
26
|
+
def recognitionRequest path
|
27
|
+
uri = URI.parse("https://api.apigw.smt.docomo.ne.jp/characterRecognition/v1/scene?APIKEY=#{@client.get_api_key}")
|
28
|
+
http = Net::HTTP.new('api.apigw.smt.docomo.ne.jp', 443)
|
29
|
+
http.use_ssl = true
|
30
|
+
request = Net::HTTP::Post.new(uri.request_uri, {'Content-Type' =>'multipart/form-data; boundary=myboundary'})
|
31
|
+
form_data = MultiPartFormDataStream.new("image", File.basename(path), image_open(path))
|
32
|
+
request.body_stream = form_data
|
33
|
+
request["Content-Length"] = form_data.size
|
34
|
+
request["Content-Type"] = form_data.content_type
|
35
|
+
response = nil
|
36
|
+
http.start do |h|
|
37
|
+
response = JSON.parse(h.request(request).body, symbolize_names: true)
|
38
|
+
end
|
39
|
+
self.id = response[:job][:id]
|
40
|
+
return response
|
41
|
+
end
|
42
|
+
|
43
|
+
def getRecognition(id=self.id)
|
44
|
+
uri = URI.parse("https://api.apigw.smt.docomo.ne.jp/characterRecognition/v1/scene/#{id}?APIKEY=#{@client.get_api_key}")
|
45
|
+
http = Net::HTTP.new('api.apigw.smt.docomo.ne.jp', 443)
|
46
|
+
http.use_ssl = true
|
47
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
48
|
+
response = nil
|
49
|
+
http.start do |h|
|
50
|
+
response = JSON.parse(h.request(request).body, symbolize_names: true)
|
51
|
+
end
|
52
|
+
return response
|
53
|
+
end
|
54
|
+
|
55
|
+
def cancelRecognition(id=self.id)
|
56
|
+
uri = URI.parse("https://api.apigw.smt.docomo.ne.jp/characterRecognition/v1/scene/#{id}?APIKEY=#{@client.get_api_key}")
|
57
|
+
http = Net::HTTP.new('api.apigw.smt.docomo.ne.jp', 443)
|
58
|
+
http.use_ssl = true
|
59
|
+
request = Net::HTTP::Delete.new(uri.request_uri)
|
60
|
+
response = nil
|
61
|
+
http.start do |h|
|
62
|
+
response = JSON.parse(h.request(request).body, symbolize_names: true)
|
63
|
+
end
|
64
|
+
return response
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
class Line < Recognize
|
69
|
+
def get_line path
|
70
|
+
uri = URI.parse("https://api.apigw.smt.docomo.ne.jp/characterRecognition/v1/line?APIKEY=#{@client.get_api_key}")
|
71
|
+
http = Net::HTTP.new('api.apigw.smt.docomo.ne.jp', 443)
|
72
|
+
http.use_ssl = true
|
73
|
+
request = Net::HTTP::Post.new(uri.request_uri, {'Content-Type' =>'multipart/form-data; boundary=myboundary'})
|
74
|
+
form_data = MultiPartFormDataStream.new("image", File.basename(path), image_open(path))
|
75
|
+
request.body_stream = form_data
|
76
|
+
request["Content-Length"] = form_data.size
|
77
|
+
request["Content-Type"] = form_data.content_type
|
78
|
+
response = nil
|
79
|
+
http.start do |h|
|
80
|
+
response = JSON.parse(h.request(request).body, symbolize_names: true)
|
81
|
+
end
|
82
|
+
return response
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
class DocumentRecognition < Recognize
|
87
|
+
attr_accessor :id
|
88
|
+
|
89
|
+
def recognitionRequest path
|
90
|
+
uri = URI.parse("https://api.apigw.smt.docomo.ne.jp/characterRecognition/v1/document?APIKEY=#{@client.get_api_key}")
|
91
|
+
http = Net::HTTP.new('api.apigw.smt.docomo.ne.jp', 443)
|
92
|
+
http.use_ssl = true
|
93
|
+
request = Net::HTTP::Post.new(uri.request_uri, {'Content-Type' =>'multipart/form-data; boundary=myboundary'})
|
94
|
+
form_data = MultiPartFormDataStream.new("image", File.basename(path), image_open(path))
|
95
|
+
request.body_stream = form_data
|
96
|
+
request["Content-Length"] = form_data.size
|
97
|
+
request["Content-Type"] = form_data.content_type
|
98
|
+
response = nil
|
99
|
+
http.start do |h|
|
100
|
+
response = JSON.parse(h.request(request).body, symbolize_names: true)
|
101
|
+
end
|
102
|
+
self.id = response[:job][:id]
|
103
|
+
return response
|
104
|
+
end
|
105
|
+
|
106
|
+
def getRecognition(id=self.id)
|
107
|
+
uri = URI.parse("https://api.apigw.smt.docomo.ne.jp/characterRecognition/v1/document/#{id}?APIKEY=#{@client.get_api_key}")
|
108
|
+
http = Net::HTTP.new('api.apigw.smt.docomo.ne.jp', 443)
|
109
|
+
http.use_ssl = true
|
110
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
111
|
+
response = nil
|
112
|
+
http.start do |h|
|
113
|
+
response = JSON.parse(h.request(request).body, symbolize_names: true)
|
114
|
+
end
|
115
|
+
return response
|
116
|
+
end
|
117
|
+
|
118
|
+
def cancelRecognition(id=self.id)
|
119
|
+
uri = URI.parse("https://api.apigw.smt.docomo.ne.jp/characterRecognition/v1/document/#{id}?APIKEY=#{@client.get_api_key}")
|
120
|
+
http = Net::HTTP.new('api.apigw.smt.docomo.ne.jp', 443)
|
121
|
+
http.use_ssl = true
|
122
|
+
request = Net::HTTP::Delete.new(uri.request_uri)
|
123
|
+
response = nil
|
124
|
+
http.start do |h|
|
125
|
+
response = JSON.parse(h.request(request).body, symbolize_names: true)
|
126
|
+
end
|
127
|
+
return response
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
class Layout < Recognize
|
132
|
+
def get_layout path
|
133
|
+
uri = URI.parse("https://api.apigw.smt.docomo.ne.jp/characterRecognition/v1/layout?APIKEY=#{@client.get_api_key}")
|
134
|
+
http = Net::HTTP.new('api.apigw.smt.docomo.ne.jp', 443)
|
135
|
+
http.use_ssl = true
|
136
|
+
request = Net::HTTP::Post.new(uri.request_uri, {'Content-Type' =>'multipart/form-data; boundary=myboundary'})
|
137
|
+
form_data = MultiPartFormDataStream.new("image", File.basename(path), image_open(path))
|
138
|
+
request.body_stream = form_data
|
139
|
+
request["Content-Length"] = form_data.size
|
140
|
+
request["Content-Type"] = form_data.content_type
|
141
|
+
response = nil
|
142
|
+
http.start do |h|
|
143
|
+
response = JSON.parse(h.request(request).body, symbolize_names: true)
|
144
|
+
end
|
145
|
+
return response
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
class MultiPartFormDataStream
|
150
|
+
def initialize(name, filename, file, boundary=nil)
|
151
|
+
@boundary = boundary || "boundary"
|
152
|
+
first = [boundary_line, content_disposition(name, filename), "", ""].join(new_line)
|
153
|
+
last = ["", boundary_last, ""].join(new_line)
|
154
|
+
@first = StringIO.new(first)
|
155
|
+
@file = file
|
156
|
+
@last = StringIO.new(last)
|
157
|
+
@size = @first.size + @file.size + @last.size
|
158
|
+
end
|
159
|
+
def content_type
|
160
|
+
"multipart/form-data; boundary=#{@boundary}"
|
161
|
+
end
|
162
|
+
def boundary_line
|
163
|
+
"--#{@boundary}"
|
164
|
+
end
|
165
|
+
def boundary_last
|
166
|
+
"--#{@boundary}--"
|
167
|
+
end
|
168
|
+
def content_disposition(name, filename)
|
169
|
+
"content-disposition: form-data; name=\"#{name}\"; filename=\"#{filename}\""
|
170
|
+
end
|
171
|
+
def new_line
|
172
|
+
"\r\n"
|
173
|
+
end
|
174
|
+
def read(len=nil, buf=nil)
|
175
|
+
return @first.read(len, buf) unless @first.eof?
|
176
|
+
return @file.read(len, buf) unless @file.eof?
|
177
|
+
return @last.read(len, buf)
|
178
|
+
end
|
179
|
+
def size
|
180
|
+
@size
|
181
|
+
end
|
182
|
+
def eof?
|
183
|
+
@last.eof?
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'net/https'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Mocodo
|
5
|
+
class Dialogue
|
6
|
+
attr_accessor :config
|
7
|
+
|
8
|
+
def initialize(api_key)
|
9
|
+
@client = Client.new(api_key)
|
10
|
+
self.config = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def configure(options = {})
|
14
|
+
options.each do |key, value|
|
15
|
+
self.config[key] = value
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_current_data(option=nil)
|
20
|
+
if option.nil?
|
21
|
+
return self.config
|
22
|
+
else
|
23
|
+
return self.config[option]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def build_body(talk)
|
28
|
+
body = {}
|
29
|
+
self.config.each { |sym|
|
30
|
+
body[sym[0].id2name] = sym[1]
|
31
|
+
}
|
32
|
+
body['utt'] = talk
|
33
|
+
return body.to_json
|
34
|
+
end
|
35
|
+
|
36
|
+
def create_dialogue talk
|
37
|
+
uri = URI.parse("https://api.apigw.smt.docomo.ne.jp/dialogue/v1/dialogue?APIKEY=#{@client.get_api_key}")
|
38
|
+
http = Net::HTTP.new('api.apigw.smt.docomo.ne.jp', 443)
|
39
|
+
http.use_ssl = true
|
40
|
+
request = Net::HTTP::Post.new(uri.request_uri, {'Content-Type' =>'application/json'})
|
41
|
+
request.body = build_body(talk)
|
42
|
+
response = nil
|
43
|
+
http.start do |h|
|
44
|
+
response = JSON.parse(h.request(request).body, symbolize_names: true)
|
45
|
+
end
|
46
|
+
configure(response)
|
47
|
+
self.config.delete(:utt)
|
48
|
+
return response[:utt]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
require 'net/https'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Mocodo
|
5
|
+
class GooLanguageAnalysis
|
6
|
+
attr_accessor :config_m, :config_e, :config_s, :config_h
|
7
|
+
|
8
|
+
def initialize(api_key)
|
9
|
+
@client = Client.new(api_key)
|
10
|
+
self.config_m = self.config_e = self.config_s = self.config_h = {}
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Morph < GooLanguageAnalysis
|
15
|
+
def configure(options = {})
|
16
|
+
options.each do |key, value|
|
17
|
+
self.config_m[key] = value
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_current_data(option=nil)
|
22
|
+
if option.nil?
|
23
|
+
return self.config_m
|
24
|
+
else
|
25
|
+
return self.config_m[option]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def build_body(sentence)
|
30
|
+
body = {}
|
31
|
+
self.config_m.each { |sym|
|
32
|
+
body[sym[0].id2name] = sym[1]
|
33
|
+
}
|
34
|
+
body['sentence'] = sentence
|
35
|
+
return body.to_json
|
36
|
+
end
|
37
|
+
|
38
|
+
def morph sentence
|
39
|
+
uri = URI.parse("https://api.apigw.smt.docomo.ne.jp/gooLanguageAnalysis/v1/morph?APIKEY=#{@client.get_api_key}")
|
40
|
+
http = Net::HTTP.new('api.apigw.smt.docomo.ne.jp', 443)
|
41
|
+
http.use_ssl = true
|
42
|
+
request = Net::HTTP::Post.new(uri.request_uri, {'Content-Type' =>'application/json'})
|
43
|
+
request.body = build_body(sentence)
|
44
|
+
response = nil
|
45
|
+
http.start do |h|
|
46
|
+
response = JSON.parse(h.request(request).body, symbolize_names: true)
|
47
|
+
end
|
48
|
+
return response[:word_list]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
class Entity < GooLanguageAnalysis
|
53
|
+
def configure(options = {})
|
54
|
+
options.each do |key, value|
|
55
|
+
self.config_e[key] = value
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def get_current_data(option=nil)
|
60
|
+
if option.nil?
|
61
|
+
return self.config_e
|
62
|
+
else
|
63
|
+
return self.config_e[option]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def build_body(sentence)
|
68
|
+
body = {}
|
69
|
+
self.config_e.each { |sym|
|
70
|
+
body[sym[0].id2name] = sym[1]
|
71
|
+
}
|
72
|
+
body['sentence'] = sentence
|
73
|
+
return body.to_json
|
74
|
+
end
|
75
|
+
|
76
|
+
def entity sentence
|
77
|
+
uri = URI.parse("https://api.apigw.smt.docomo.ne.jp/gooLanguageAnalysis/v1/entity?APIKEY=#{@client.get_api_key}")
|
78
|
+
http = Net::HTTP.new('api.apigw.smt.docomo.ne.jp', 443)
|
79
|
+
http.use_ssl = true
|
80
|
+
request = Net::HTTP::Post.new(uri.request_uri, {'Content-Type' =>'application/json'})
|
81
|
+
request.body = build_body(sentence)
|
82
|
+
response = nil
|
83
|
+
http.start do |h|
|
84
|
+
response = JSON.parse(h.request(request).body, symbolize_names: true)
|
85
|
+
end
|
86
|
+
return response[:ne_list]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
class Similarity < GooLanguageAnalysis
|
91
|
+
def configure(options = {})
|
92
|
+
options.each do |key, value|
|
93
|
+
self.config_s[key] = value
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def get_current_data(option=nil)
|
98
|
+
if option.nil?
|
99
|
+
return self.config_s
|
100
|
+
else
|
101
|
+
return self.config_s[option]
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def build_body(sentence1, sentence2)
|
106
|
+
body = {}
|
107
|
+
self.config_s.each { |sym|
|
108
|
+
body[sym[0].id2name] = sym[1]
|
109
|
+
}
|
110
|
+
body['query_pair'] = [sentence1, sentence2]
|
111
|
+
return body.to_json
|
112
|
+
end
|
113
|
+
|
114
|
+
def similarity(sentence1, sentence2)
|
115
|
+
uri = URI.parse("https://api.apigw.smt.docomo.ne.jp/gooLanguageAnalysis/v1/similarity?APIKEY=#{@client.get_api_key}")
|
116
|
+
http = Net::HTTP.new('api.apigw.smt.docomo.ne.jp', 443)
|
117
|
+
http.use_ssl = true
|
118
|
+
request = Net::HTTP::Post.new(uri.request_uri, {'Content-Type' =>'application/json'})
|
119
|
+
request.body = build_body(sentence1, sentence2)
|
120
|
+
response = nil
|
121
|
+
http.start do |h|
|
122
|
+
response = JSON.parse(h.request(request).body, symbolize_names: true)
|
123
|
+
end
|
124
|
+
return response[:score]
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
class Hiragana < GooLanguageAnalysis
|
129
|
+
def configure(options = {})
|
130
|
+
options.each do |key, value|
|
131
|
+
self.config_h[key] = value
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def get_current_data(option=nil)
|
136
|
+
if option.nil?
|
137
|
+
return self.config_h
|
138
|
+
else
|
139
|
+
return self.config_h[option]
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def build_body(sentence)
|
144
|
+
body = {}
|
145
|
+
self.config_h.each { |sym|
|
146
|
+
body[sym[0].id2name] = sym[1]
|
147
|
+
}
|
148
|
+
body['sentence'] = sentence
|
149
|
+
return body.to_json
|
150
|
+
end
|
151
|
+
|
152
|
+
def hiragana sentence
|
153
|
+
uri = URI.parse("https://api.apigw.smt.docomo.ne.jp/gooLanguageAnalysis/v1/hiragana?APIKEY=#{@client.get_api_key}")
|
154
|
+
http = Net::HTTP.new('api.apigw.smt.docomo.ne.jp', 443)
|
155
|
+
http.use_ssl = true
|
156
|
+
request = Net::HTTP::Post.new(uri.request_uri, {'Content-Type' =>'application/json'})
|
157
|
+
request.body = build_body(sentence)
|
158
|
+
response = nil
|
159
|
+
http.start do |h|
|
160
|
+
response = JSON.parse(h.request(request).body, symbolize_names: true)
|
161
|
+
end
|
162
|
+
return response[:converted]
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'net/https'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Mocodo
|
6
|
+
class Recognize
|
7
|
+
|
8
|
+
def initialize(api_key)
|
9
|
+
@client = Client.new(api_key)
|
10
|
+
end
|
11
|
+
|
12
|
+
def image_open(path)
|
13
|
+
if /^http/ =~ path
|
14
|
+
binary_image = File.binread(open(path))
|
15
|
+
else
|
16
|
+
binary_image = File.binread(File.open(path))
|
17
|
+
end
|
18
|
+
return binary_image
|
19
|
+
end
|
20
|
+
|
21
|
+
def image_recognition(path, num=1)
|
22
|
+
uri = URI.parse("https://api.apigw.smt.docomo.ne.jp/imageRecognition/v1/recognize?APIKEY=#{@client.get_api_key}&recog=product-all&numOfCandidates=#{num}")
|
23
|
+
http = Net::HTTP.new('api.apigw.smt.docomo.ne.jp', 443)
|
24
|
+
http.use_ssl = true
|
25
|
+
request = Net::HTTP::Post.new(uri.request_uri, {'Content-Type' =>'application/octet-stream'})
|
26
|
+
request.body = File.binread(open(path)) #image_open(path)
|
27
|
+
response = nil
|
28
|
+
http.start do |h|
|
29
|
+
response = JSON.parse(h.request(request).body, symbolize_names: true)
|
30
|
+
end
|
31
|
+
return response[:candidates]
|
32
|
+
end
|
33
|
+
|
34
|
+
def local_image_recognition(path, num=1)
|
35
|
+
uri = URI.parse("https://api.apigw.smt.docomo.ne.jp/imageRecognition/v1/recognize?APIKEY=#{@client.get_api_key}&recog=product-all&numOfCandidates=#{num}")
|
36
|
+
http = Net::HTTP.new('api.apigw.smt.docomo.ne.jp', 443)
|
37
|
+
http.use_ssl = true
|
38
|
+
request = Net::HTTP::Post.new(uri.request_uri, {'Content-Type' =>'application/octet-stream'})
|
39
|
+
request.body = File.binread(File.open(path))
|
40
|
+
response = nil
|
41
|
+
http.start do |h|
|
42
|
+
response = JSON.parse(h.request(request).body, symbolize_names: true)
|
43
|
+
end
|
44
|
+
return response[:candidates]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'net/https'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Mocodo
|
5
|
+
class KnowledgeQA
|
6
|
+
def initialize(api_key)
|
7
|
+
@client = Client.new(api_key)
|
8
|
+
end
|
9
|
+
|
10
|
+
def create_qa qa
|
11
|
+
uri = URI.parse("https://api.apigw.smt.docomo.ne.jp/knowledgeQA/v1/ask?APIKEY=#{@client.get_api_key}&q=#{URI.encode(qa)}")
|
12
|
+
http = Net::HTTP.new('api.apigw.smt.docomo.ne.jp', 443)
|
13
|
+
http.use_ssl = true
|
14
|
+
res = http.start {
|
15
|
+
http.get(uri.request_uri)
|
16
|
+
}
|
17
|
+
data = JSON.parse(res.body)
|
18
|
+
return data
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'net/https'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Mocodo
|
5
|
+
class SentenceUnderstanding
|
6
|
+
attr_accessor :config
|
7
|
+
|
8
|
+
def initialize(api_key)
|
9
|
+
@client = Client.new(api_key)
|
10
|
+
self.config = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def configure(options = {})
|
14
|
+
options.each do |key, value|
|
15
|
+
self.config[key] = value
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_current_data(option=nil)
|
20
|
+
if option.nil?
|
21
|
+
return self.config
|
22
|
+
else
|
23
|
+
return self.config[option]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def build_body(talk)
|
28
|
+
body = {}
|
29
|
+
self.config.each { |sym|
|
30
|
+
body[sym[0].id2name] = sym[1]
|
31
|
+
}
|
32
|
+
body['userUtterance'] = {}
|
33
|
+
body['userUtterance']['utteranceText'] = talk
|
34
|
+
return body.to_json
|
35
|
+
end
|
36
|
+
|
37
|
+
def sentenceUnderstanding talk
|
38
|
+
uri = URI.parse("https://api.apigw.smt.docomo.ne.jp/sentenceUnderstanding/v1/task?APIKEY=#{@client.get_api_key}")
|
39
|
+
http = Net::HTTP.new('api.apigw.smt.docomo.ne.jp', 443)
|
40
|
+
http.use_ssl = true
|
41
|
+
request = Net::HTTP::Post.new(uri.request_uri, {'Content-Type' =>'application/x-www-form-urlencoded'})
|
42
|
+
request.body = build_body(talk)
|
43
|
+
response = nil
|
44
|
+
http.start do |h|
|
45
|
+
response = JSON.parse(h.request(request).body, symbolize_names: true)
|
46
|
+
end
|
47
|
+
configure(response)
|
48
|
+
return response
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'net/https'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Mocodo
|
6
|
+
class VirtualNarrator
|
7
|
+
attr_accessor :config
|
8
|
+
|
9
|
+
def initialize(api_key)
|
10
|
+
@client = Client.new(api_key)
|
11
|
+
self.config = {}
|
12
|
+
end
|
13
|
+
|
14
|
+
def configure(options = {})
|
15
|
+
options.each do |key, value|
|
16
|
+
self.config[key] = value
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def get_current_data(option=nil)
|
21
|
+
if option.nil?
|
22
|
+
return self.config
|
23
|
+
else
|
24
|
+
return self.config[option]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def build_body(text)
|
29
|
+
body = {}
|
30
|
+
self.config.each { |sym|
|
31
|
+
body[sym[0].id2name] = sym[1]
|
32
|
+
}
|
33
|
+
body['TextData'] = text
|
34
|
+
return body.to_json
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class TextToSpeech < VirtualNarrator
|
39
|
+
def textToSpeech text
|
40
|
+
uri = URI.parse("https://api.apigw.smt.docomo.ne.jp/virtualNarrator/v1/textToSpeech?APIKEY=#{@client.get_api_key}")
|
41
|
+
http = Net::HTTP.new('api.apigw.smt.docomo.ne.jp', 443)
|
42
|
+
http.use_ssl = true
|
43
|
+
request = Net::HTTP::Post.new(uri.request_uri, {'Content-Type' =>'application/json'})
|
44
|
+
request.body = build_body(text)
|
45
|
+
response = nil
|
46
|
+
http.start do |h|
|
47
|
+
response = h.request(request).body
|
48
|
+
end
|
49
|
+
return response
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
class TextToSpeechSsml < VirtualNarrator
|
54
|
+
def textToSpeech text
|
55
|
+
uri = URI.parse("https://api.apigw.smt.docomo.ne.jp/virtualNarrator/v1/textToSpeechSsml?APIKEY=#{@client.get_api_key}")
|
56
|
+
http = Net::HTTP.new('api.apigw.smt.docomo.ne.jp', 443)
|
57
|
+
http.use_ssl = true
|
58
|
+
request = Net::HTTP::Post.new(uri.request_uri, {'Content-Type' =>'application/json'})
|
59
|
+
request.body = build_body(text)
|
60
|
+
response = nil
|
61
|
+
http.start do |h|
|
62
|
+
response = h.request(request).body
|
63
|
+
end
|
64
|
+
return response
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
class TextToSpeechKanaAccent < VirtualNarrator
|
69
|
+
def textToSpeech text
|
70
|
+
uri = URI.parse("https://api.apigw.smt.docomo.ne.jp/virtualNarrator/v1/textToSpeechKanaAccent?APIKEY=#{@client.get_api_key}")
|
71
|
+
http = Net::HTTP.new('api.apigw.smt.docomo.ne.jp', 443)
|
72
|
+
http.use_ssl = true
|
73
|
+
request = Net::HTTP::Post.new(uri.request_uri, {'Content-Type' =>'application/json'})
|
74
|
+
request.body = build_body(text)
|
75
|
+
response = nil
|
76
|
+
http.start do |h|
|
77
|
+
response = h.request(request).body
|
78
|
+
end
|
79
|
+
return response
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'net/https'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Mocodo
|
5
|
+
class WebCuration
|
6
|
+
def initialize(api_key)
|
7
|
+
@client = Client.new(api_key)
|
8
|
+
end
|
9
|
+
|
10
|
+
def build_url(options = {})
|
11
|
+
url = ""
|
12
|
+
options.each do |key, value|
|
13
|
+
url << "&" << key.id2name << "=" << value
|
14
|
+
end
|
15
|
+
return URI.escape(url)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class Genre < WebCuration
|
20
|
+
def get_genre(conf = {})
|
21
|
+
uri = URI.parse("https://api.apigw.smt.docomo.ne.jp/webCuration/v3/genre?APIKEY=#{@client.get_api_key}#{build_url(conf)}")
|
22
|
+
http = Net::HTTP.new('api.apigw.smt.docomo.ne.jp', 443)
|
23
|
+
http.use_ssl = true
|
24
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
25
|
+
response = nil
|
26
|
+
http.start do |h|
|
27
|
+
response = JSON.parse(h.request(request).body, symbolize_names: true)
|
28
|
+
end
|
29
|
+
return response
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class Contents < WebCuration
|
34
|
+
def get_contents(conf = {})
|
35
|
+
uri = URI.parse("https://api.apigw.smt.docomo.ne.jp/webCuration/v3/contents?APIKEY=#{@client.get_api_key}#{build_url(conf)}")
|
36
|
+
http = Net::HTTP.new('api.apigw.smt.docomo.ne.jp', 443)
|
37
|
+
http.use_ssl = true
|
38
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
39
|
+
response = nil
|
40
|
+
http.start do |h|
|
41
|
+
response = JSON.parse(h.request(request).body, symbolize_names: true)
|
42
|
+
end
|
43
|
+
return response
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class Search < WebCuration
|
48
|
+
def search_contents(conf = {})
|
49
|
+
uri = URI.parse("https://api.apigw.smt.docomo.ne.jp/webCuration/v3/search?APIKEY=#{@client.get_api_key}#{build_url(conf)}")
|
50
|
+
http = Net::HTTP.new('api.apigw.smt.docomo.ne.jp', 443)
|
51
|
+
http.use_ssl = true
|
52
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
53
|
+
response = nil
|
54
|
+
http.start do |h|
|
55
|
+
response = JSON.parse(h.request(request).body, symbolize_names: true)
|
56
|
+
end
|
57
|
+
return response
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class RelatedContents < WebCuration
|
62
|
+
def relatedContents(conf = {})
|
63
|
+
uri = URI.parse("https://api.apigw.smt.docomo.ne.jp/webCuration/v3/relatedContents?APIKEY=#{@client.get_api_key}#{build_url(conf)}")
|
64
|
+
http = Net::HTTP.new('api.apigw.smt.docomo.ne.jp', 443)
|
65
|
+
http.use_ssl = true
|
66
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
67
|
+
response = nil
|
68
|
+
http.start do |h|
|
69
|
+
response = JSON.parse(h.request(request).body, symbolize_names: true)
|
70
|
+
end
|
71
|
+
return response
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/mocodo.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'mocodo/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "mocodo"
|
8
|
+
spec.version = Mocodo::VERSION
|
9
|
+
spec.authors = ["flum1025"]
|
10
|
+
spec.email = ["flum.1025@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Docomo Api Library}
|
13
|
+
spec.description = spec.summary
|
14
|
+
spec.homepage = "https://github.com/flum1025/Mocodo"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_dependency 'json'
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mocodo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- flum1025
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.9'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: json
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Docomo Api Library
|
56
|
+
email:
|
57
|
+
- flum.1025@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- .project
|
64
|
+
- .travis.yml
|
65
|
+
- Gemfile
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/console
|
69
|
+
- bin/setup
|
70
|
+
- example/hqdefault.jpg
|
71
|
+
- example/mocodo-example.rb
|
72
|
+
- lib/mocodo.rb
|
73
|
+
- lib/mocodo/character_recognition.rb
|
74
|
+
- lib/mocodo/client.rb
|
75
|
+
- lib/mocodo/dialogue.rb
|
76
|
+
- lib/mocodo/goo_language_analysis.rb
|
77
|
+
- lib/mocodo/image_recognition.rb
|
78
|
+
- lib/mocodo/knowledge_qa.rb
|
79
|
+
- lib/mocodo/sentence_understanding.rb
|
80
|
+
- lib/mocodo/text_to_speech.rb
|
81
|
+
- lib/mocodo/version.rb
|
82
|
+
- lib/mocodo/web_curation.rb
|
83
|
+
- mocodo.gemspec
|
84
|
+
homepage: https://github.com/flum1025/Mocodo
|
85
|
+
licenses: []
|
86
|
+
metadata: {}
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.5.2
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: Docomo Api Library
|
107
|
+
test_files: []
|