mushikago-sdk 0.4.3 → 2.0.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.
Files changed (134) hide show
  1. data/README.md +3 -1
  2. data/Rakefile +1 -0
  3. data/lib/mushikago/hanamgri/client.rb +264 -0
  4. data/lib/mushikago/hanamgri/create_domain_request.rb +25 -0
  5. data/lib/mushikago/hanamgri/delete_dictionary_request.rb +14 -0
  6. data/lib/mushikago/hanamgri/delete_domain_request.rb +16 -0
  7. data/lib/mushikago/hanamgri/delete_knowledge_request.rb +15 -0
  8. data/lib/mushikago/hanamgri/field.rb +20 -0
  9. data/lib/mushikago/hanamgri/get_analysis_request.rb +16 -0
  10. data/lib/mushikago/hanamgri/get_information_request.rb +14 -0
  11. data/lib/mushikago/hanamgri/get_queue_size_request.rb +14 -0
  12. data/lib/mushikago/hanamgri/list_analyses_request.rb +24 -0
  13. data/lib/mushikago/hanamgri/list_dictionaries_request.rb +17 -0
  14. data/lib/mushikago/hanamgri/list_domains_request.rb +20 -0
  15. data/lib/mushikago/hanamgri/list_knowledges_request.rb +20 -0
  16. data/lib/mushikago/hanamgri/request_analysis_request.rb +21 -0
  17. data/lib/mushikago/hanamgri/save_dictionary_request.rb +18 -0
  18. data/lib/mushikago/hanamgri/save_knowledge_request.rb +19 -0
  19. data/lib/mushikago/hanamgri/schema.rb +28 -0
  20. data/lib/mushikago/hanamgri/search_schema_request.rb +19 -0
  21. data/lib/mushikago/hanamgri/train_request.rb +21 -0
  22. data/lib/mushikago/hanamgri/training_data.rb +27 -0
  23. data/lib/mushikago/hanamgri/update_domain_request.rb +18 -0
  24. data/lib/mushikago/hanamgri.rb +30 -0
  25. data/lib/mushikago/version.rb +1 -1
  26. data/lib/mushikago.rb +1 -0
  27. data/spec/mushikago/hanamgri/client_spec.rb +61 -0
  28. data/spec/mushikago/hanamgri/create_domain_spec.rb +34 -0
  29. data/spec/mushikago/hanamgri/delete_dictionary_spec.rb +11 -0
  30. data/spec/mushikago/hanamgri/delete_domain_spec.rb +12 -0
  31. data/spec/mushikago/hanamgri/delete_knowledge_request_spec.rb +11 -0
  32. data/spec/mushikago/hanamgri/field_spec.rb +44 -0
  33. data/spec/mushikago/hanamgri/get_analysis_request_spec.rb +12 -0
  34. data/spec/mushikago/hanamgri/get_information_request_spec.rb +14 -0
  35. data/spec/mushikago/hanamgri/get_queue_size_request_spec.rb +10 -0
  36. data/spec/mushikago/hanamgri/list_analyses_spec.rb +25 -0
  37. data/spec/mushikago/hanamgri/list_dictionaries_spec.rb +19 -0
  38. data/spec/mushikago/hanamgri/list_domains_spec.rb +19 -0
  39. data/spec/mushikago/hanamgri/list_knowledges_request_spec.rb +20 -0
  40. data/spec/mushikago/hanamgri/request_analysis_request_spec.rb +21 -0
  41. data/spec/mushikago/hanamgri/save_dictionary_request_spec.rb +22 -0
  42. data/spec/mushikago/hanamgri/save_knowledge_request_spec.rb +22 -0
  43. data/spec/mushikago/hanamgri/schema_spec.rb +53 -0
  44. data/spec/mushikago/hanamgri/search_schema_request_spec.rb +22 -0
  45. data/spec/mushikago/hanamgri/train_spec.rb +31 -0
  46. data/spec/mushikago/hanamgri/update_domain_spec.rb +22 -0
  47. metadata +95 -109
  48. data/doc/Mushikago/Auth/Signature.html +0 -312
  49. data/doc/Mushikago/Auth/Signer.html +0 -465
  50. data/doc/Mushikago/Auth.html +0 -122
  51. data/doc/Mushikago/Config.html +0 -285
  52. data/doc/Mushikago/Hotaru/ClassifierJudgeRequest.html +0 -307
  53. data/doc/Mushikago/Hotaru/Client.html +0 -4174
  54. data/doc/Mushikago/Hotaru/CollocationCreateRequest.html +0 -375
  55. data/doc/Mushikago/Hotaru/CollocationDeleteRequest.html +0 -307
  56. data/doc/Mushikago/Hotaru/CollocationDownloadRequest.html +0 -307
  57. data/doc/Mushikago/Hotaru/CollocationGetRequest.html +0 -309
  58. data/doc/Mushikago/Hotaru/CollocationListRequest.html +0 -313
  59. data/doc/Mushikago/Hotaru/CollocationWordlistRequest.html +0 -313
  60. data/doc/Mushikago/Hotaru/DictionaryDeleteRequest.html +0 -305
  61. data/doc/Mushikago/Hotaru/DictionaryListRequest.html +0 -309
  62. data/doc/Mushikago/Hotaru/DictionaryPutRequest.html +0 -342
  63. data/doc/Mushikago/Hotaru/DomainCreateRequest.html +0 -313
  64. data/doc/Mushikago/Hotaru/DomainDeleteRequest.html +0 -305
  65. data/doc/Mushikago/Hotaru/DomainInfoRequest.html +0 -307
  66. data/doc/Mushikago/Hotaru/DomainListRequest.html +0 -311
  67. data/doc/Mushikago/Hotaru/TagDeleteRequest.html +0 -307
  68. data/doc/Mushikago/Hotaru/TagListRequest.html +0 -307
  69. data/doc/Mushikago/Hotaru/TagPutRequest.html +0 -307
  70. data/doc/Mushikago/Hotaru/TextDeleteRequest.html +0 -309
  71. data/doc/Mushikago/Hotaru/TextGetRequest.html +0 -307
  72. data/doc/Mushikago/Hotaru/TextListRequest.html +0 -315
  73. data/doc/Mushikago/Hotaru/TextPutRequest.html +0 -311
  74. data/doc/Mushikago/Hotaru/TextTagsetRequest.html +0 -311
  75. data/doc/Mushikago/Hotaru/WordGetRequest.html +0 -307
  76. data/doc/Mushikago/Hotaru/WordListRequest.html +0 -311
  77. data/doc/Mushikago/Hotaru.html +0 -120
  78. data/doc/Mushikago/Http/Client.html +0 -673
  79. data/doc/Mushikago/Http/DeleteRequest.html +0 -240
  80. data/doc/Mushikago/Http/GetRequest.html +0 -240
  81. data/doc/Mushikago/Http/MultipartPostRequest.html +0 -265
  82. data/doc/Mushikago/Http/MultipartPutRequest.html +0 -265
  83. data/doc/Mushikago/Http/MultipartRequest.html +0 -362
  84. data/doc/Mushikago/Http/PostRequest.html +0 -240
  85. data/doc/Mushikago/Http/PutRequest.html +0 -240
  86. data/doc/Mushikago/Http/Request.html +0 -1223
  87. data/doc/Mushikago/Http/Response.html +0 -840
  88. data/doc/Mushikago/Http.html +0 -120
  89. data/doc/Mushikago/Mitsubachi/Client.html +0 -3232
  90. data/doc/Mushikago/Mitsubachi/HttpFetchRequest.html +0 -319
  91. data/doc/Mushikago/Mitsubachi/HttpPushRequest.html +0 -321
  92. data/doc/Mushikago/Mitsubachi/Project.html +0 -742
  93. data/doc/Mushikago/Mitsubachi/ProjectCreateRequest.html +0 -317
  94. data/doc/Mushikago/Mitsubachi/ProjectDeleteRequest.html +0 -307
  95. data/doc/Mushikago/Mitsubachi/ProjectDiscontinueRequest.html +0 -305
  96. data/doc/Mushikago/Mitsubachi/ProjectInfoRequest.html +0 -307
  97. data/doc/Mushikago/Mitsubachi/ProjectListRequest.html +0 -309
  98. data/doc/Mushikago/Mitsubachi/ProjectQueuesRequest.html +0 -305
  99. data/doc/Mushikago/Mitsubachi/ProjectUpdateRequest.html +0 -315
  100. data/doc/Mushikago/Mitsubachi/Projects.html +0 -474
  101. data/doc/Mushikago/Mitsubachi/Resource.html +0 -569
  102. data/doc/Mushikago/Mitsubachi/ResourceDeleteRequest.html +0 -307
  103. data/doc/Mushikago/Mitsubachi/ResourceGetRequest.html +0 -307
  104. data/doc/Mushikago/Mitsubachi/ResourceListRequest.html +0 -311
  105. data/doc/Mushikago/Mitsubachi/ResourceStoreRequest.html +0 -346
  106. data/doc/Mushikago/Mitsubachi/Resources.html +0 -546
  107. data/doc/Mushikago/Mitsubachi/Script.html +0 -569
  108. data/doc/Mushikago/Mitsubachi/ScriptDeleteRequest.html +0 -307
  109. data/doc/Mushikago/Mitsubachi/ScriptDeployRequest.html +0 -342
  110. data/doc/Mushikago/Mitsubachi/ScriptGetRequest.html +0 -307
  111. data/doc/Mushikago/Mitsubachi/ScriptListRequest.html +0 -311
  112. data/doc/Mushikago/Mitsubachi/Scripts.html +0 -546
  113. data/doc/Mushikago/Mitsubachi.html +0 -120
  114. data/doc/Mushikago/Tombo/CaptureRequest.html +0 -454
  115. data/doc/Mushikago/Tombo/CapturesRequest.html +0 -417
  116. data/doc/Mushikago/Tombo/Client.html +0 -830
  117. data/doc/Mushikago/Tombo/DeleteRequest.html +0 -357
  118. data/doc/Mushikago/Tombo/InfoRequest.html +0 -338
  119. data/doc/Mushikago/Tombo.html +0 -120
  120. data/doc/Mushikago.html +0 -246
  121. data/doc/_index.html +0 -701
  122. data/doc/class_list.html +0 -47
  123. data/doc/css/common.css +0 -1
  124. data/doc/css/full_list.css +0 -55
  125. data/doc/css/style.css +0 -322
  126. data/doc/file.README.html +0 -250
  127. data/doc/file_list.html +0 -49
  128. data/doc/frames.html +0 -13
  129. data/doc/index.html +0 -250
  130. data/doc/js/app.js +0 -205
  131. data/doc/js/full_list.js +0 -167
  132. data/doc/js/jquery.js +0 -16
  133. data/doc/method_list.html +0 -1806
  134. data/doc/top-level-namespace.html +0 -103
data/README.md CHANGED
@@ -5,7 +5,7 @@ Mushikago SDK for Ruby.
5
5
  - **Author**: Toru Matsuoka
6
6
  - **Copyright**: 2011
7
7
  - **License**: Apache License, Version 2.0
8
- - **Latest Version**: 0.4.0
8
+ - **Latest Version**: 1.3-beta
9
9
  - **Release Date**: January 27th 2012
10
10
 
11
11
 
@@ -153,6 +153,8 @@ $ export MUSHIKAGO_SECRET_KEY=<シークレットキー>
153
153
  変更履歴
154
154
  --------
155
155
 
156
+ - **May.23.12**: 1.3-beta release
157
+ - haanmgriのベータサポート
156
158
  - **Feb.20.12**: 0.4.2 release
157
159
  - tomboのcaptureオプション「delay_time」に対応
158
160
  - **Feb.20.12**: 0.4.0 release
data/Rakefile CHANGED
@@ -2,6 +2,7 @@ $:.unshift File.expand_path('../lib', __FILE__)
2
2
  require 'rubygems'
3
3
  require 'bundler'
4
4
  Bundler.setup :default, :test, :development
5
+ require 'ci/reporter/rake/rspec'
5
6
 
6
7
  Bundler::GemHelper.install_tasks
7
8
 
@@ -0,0 +1,264 @@
1
+ # -*- coding : utf-8 -*-
2
+ module Mushikago
3
+ module Hanamgri
4
+ # Hanamgriサービスを利用する
5
+ #
6
+ # @example
7
+ # client = Mushikago::Hanamgri::Client.new(:api_key => '<api_key>', :secret_key => '<secret_key>')
8
+ #
9
+ # @example APIキーをファイルから読み込む場合
10
+ # Mushikago.config.load(YAML.load(File.read('config.yml')))
11
+ # client = Mushikago::Hanamgri::Client.new
12
+ class Client < Mushikago::Http::Client
13
+ # ドメインを新規作成する
14
+ #
15
+ # @example
16
+ # schema = Mushikago::Hanamgri::Schema.new do
17
+ # add Mushikago::Hanamgri::Field.new('name', true, :string)
18
+ # add Mushikago::Hanamgri::Field.new('price', true, :number)
19
+ # add {:name => 'shipping', :required => true, :type => :number, :knowledge_name => 'mushikago/ec/shipping'} # <= Hashでも追加できます
20
+ # end
21
+ # client.create_domain('ec', '税込', schema)
22
+ #
23
+ # @param [String] domain_name ドメイン名
24
+ # @param [String] seeds 初期キーワード
25
+ # @param [String] schema スキーマ
26
+ # @param [Hash] options オプション
27
+ # @option options [String] :description ドメインの説明
28
+ # @option options [String] :dictionary_name 初期辞書
29
+ def create_domain domain_name, seeds, schema, options={}
30
+ request = Hanamgri::CreateDomainRequest.new(domain_name, seeds, schema, options)
31
+ send_request(request)
32
+ end
33
+
34
+ # ドメインを削除する
35
+ #
36
+ # @example
37
+ # client.delete_domain('ec')
38
+ #
39
+ # @param [String] domain_name ドメイン名
40
+ # @param [Hash] options オプション
41
+ # @option options [String] :description ドメインの説明
42
+ def delete_domain domain_name, options={}
43
+ request = Hanamgri::DeleteDomainRequest.new(domain_name, options)
44
+ send_request(request)
45
+ end
46
+
47
+ # 解析リクエストを送信する
48
+ #
49
+ # @example
50
+ # client.request_analysis('ec', 'http://shop.example.com/')
51
+ #
52
+ # @param [String] domain_name ドメイン名
53
+ # @param [String] url 解析対象URL
54
+ # @param [Hash] options オプション
55
+ # @option options [String] :charset 解析対象ページ文字コード
56
+ # @option options [String] :tag 解析結果識別用タグ
57
+ # @option options [String] :auto_feedback 解析のみ。もしくは解析と学習を行う
58
+ def request_analysis domain_name, url, options={}
59
+ request = Hanamgri::RequestAnalysisRequest.new(domain_name, url, options)
60
+ send_request(request)
61
+ end
62
+
63
+ # 解析結果を取得する
64
+ #
65
+ # @example
66
+ # client.get_analysis('ec', 'xxxxxx-xxxxxx-xxxxxx')
67
+ #
68
+ # @param [String] domain_name ドメイン名
69
+ # @param [String] request_id 解析リクエストID
70
+ # @param [Hash] options リクエストのオプション
71
+ # @return [Mushikago::Http::Response] リクエストの結果
72
+ def get_analysis domain_name, request_id, options={}
73
+ request = Hanamgri::GetAnalysisRequest.new(domain_name, request_id, options)
74
+ send_request(request)
75
+ end
76
+
77
+ # ドメイン内の残タスク数を取得する
78
+ #
79
+ # @example
80
+ # ret = client.get_queue_size('ec')
81
+ # puts ret['queue_size']
82
+ #
83
+ # @param [String] domain_name ドメイン名
84
+ # @param [Hash] options リクエストのオプション
85
+ # @return [Mushikago::Http::Response] リクエストの結果
86
+ def get_queue_size domain_name, options={}
87
+ request = Hanamgri::GetQueueSizeRequest.new(domain_name, options)
88
+ send_request(request)
89
+ end
90
+
91
+ # ドメインの情報を取得する
92
+ #
93
+ # @example
94
+ # client.get_information('ec')
95
+ #
96
+ # @param [String] domain_name ドメイン名
97
+ # @param [Hash] options リクエストのオプション
98
+ # @return [Mushikago::Http::Response] リクエストの結果
99
+ def get_information domain_name, options={}
100
+ request = Hanamgri::GetInformationRequest.new(domain_name, options)
101
+ send_request(request)
102
+ end
103
+
104
+ # ドメインの一覧を取得する
105
+ #
106
+ # @example
107
+ # client.list_domains(20, 10, 'ec')
108
+ #
109
+ # @param [Hash] options リクエストのオプション
110
+ # @option options [Integer] : limit 最大取得件数
111
+ # @option options [Integer] : offset 開始位置
112
+ # @option options [String] : filter 検索文字(先頭一致)
113
+ # @return [Mushikago::Http::Response] リクエストの結果
114
+ def list_domains options={}
115
+ request = Hanamgri::GetListDomainsRequest.new(options)
116
+ send_request(request)
117
+ end
118
+
119
+ # ドメインの情報を更新する
120
+ #
121
+ # @example
122
+ # client.update_domain('ec', 'updateDescription')
123
+ #
124
+ # @param [Hash] options リクエストのオプション
125
+ # @option options [String] : domain_name ドメイン名
126
+ # @option options [String] : description ドメインの説明文
127
+ # @return [Mushikago::Http::Response] リクエストの結果
128
+ def update_domain domain_name, description, options={}
129
+ request = Hanamgri::UpdateDomainRequest.new(domain_name, description, options)
130
+ send_request(request)
131
+ end
132
+
133
+ # 解析結果の一覧を取得する
134
+ #
135
+ # @example
136
+ # client.list_analyses('ec', {:limit => '20', :offset => '5', :status => 'complete'})
137
+ #
138
+ # @param [String] domain_name ドメイン名
139
+ # @param [Hash] options リクエストのオプション
140
+ # @option options [Integer] : limit 最大取得件数
141
+ # @option options [Integer] : offset 開始位置
142
+ # @option options [String] : filter 検索文字
143
+ # @option options [String] : status 解析の状態
144
+ # @return [Mushikago::Http::Response] リクエストの結果
145
+ def list_analyses domain_name, options={}
146
+ request = Hanamgri::GetListAnalysesRequest.new(domain_name, options)
147
+ send_request(request)
148
+ end
149
+
150
+ # 解析結果を検索する
151
+ #
152
+ # @example
153
+ # client.search_schema('ec', 'name', 'something', {:limit => '20', :offset => '5'})
154
+ #
155
+ # @param [String] domain_name ドメイン名
156
+ # @param [String] query_key 検索対象のフィールド名
157
+ # @param [String] query_value 検索対象のフィールド値
158
+ # @option options [Integer] : limit 最大取得件数
159
+ # @option options [Integer] : offset 開始位置
160
+ # @return [Mushikagp::Http::Response] リクエストの結果
161
+ def search_schema domain_name, query_key, query_value, options={}
162
+ request = Hanamgri::SearchSchemaRequest.new(domain_name, query_key, query_value, options)
163
+ send_request(request)
164
+ end
165
+
166
+ # 解析結果を検索する
167
+ #
168
+ # @example
169
+ # training_data = Mushikago::Hanamgri::TrainingData.new do
170
+ # put('name', 'mushikago')
171
+ # end
172
+ # client.train('ec', 'http://www.mushikago.org/', training_data) # URLを指定する例
173
+ # client.train('ec', '<div>hello mushikago</div>', training_data) # HTML文字列を指定する例
174
+ # client.train('ec', File.read('./mushikago.html'), training_data) # HTMLをファイルから読み込んで指定する例
175
+ #
176
+ # @param [String] domain_name ドメイン名
177
+ # @param [String] url_or_html 学習対象のURLもしくはHTML文字列
178
+ # @param [Mushikago::Hanamgri::TrainingData] training_data 学習データ
179
+ # @return [Mushikagp::Http::Response] リクエストの結果
180
+ def train domain_name, url_or_html, training_data, options={}
181
+ request = Hanamgri::TrainRequest.new(domain_name, url_or_html, training_data, options)
182
+ send_request(request)
183
+ end
184
+
185
+ # 辞書を保存する
186
+ #
187
+ # @example
188
+ # client.save_dictionary('ec', {:description => '辞書の説明'})
189
+ #
190
+ # @param [String] domain_name ドメイン名
191
+ # @param [Hash] options オプション
192
+ # @option options [String] :description 辞書の説明
193
+ def save_dictionary domain_name, options={}
194
+ request = Hanamgri::SaveDictionaryRequest.new(domain_name, options)
195
+ send_request(request)
196
+ end
197
+
198
+ # 辞書の一覧を取得する
199
+ #
200
+ # @example
201
+ # client.list_dictionaries(20, 10)
202
+ #
203
+ # @param [Hash] options リクエストのオプション
204
+ # @option options [Integer] : limit 最大取得件数
205
+ # @option options [Integer] : offset 開始位置
206
+ # @return [Mushikago::Http::Response] リクエストの結果
207
+ def list_dictionaries options={}
208
+ request = Hanamgri::ListDictionariesRequest.new(options)
209
+ send_request(request)
210
+ end
211
+
212
+ # 辞書の情報を削除する
213
+ #
214
+ # @example
215
+ # client.delete_dictionary('ec-UUID')
216
+ #
217
+ # @param [String] dictionary_name 辞書名
218
+ def delete_dictionary dictionary_name, options={}
219
+ request = Hanamgri::DeleteDictionaryRequest.new(dictionary_name,options)
220
+ send_request(request)
221
+ end
222
+
223
+ # 学習データを保存する
224
+ #
225
+ # @example
226
+ # client.save_knowledge('ec', {:description => '学習データの説明'})
227
+ #
228
+ # @param [String] domain_name ドメイン名
229
+ # @param [Hash] options オプション
230
+ # @option options [String] :description 学習データの説明
231
+ def save_knowledge domain_name, options={}
232
+ request = Hanamgri::SaveKnowledgeRequest.new(domain_name, options)
233
+ send_request(request)
234
+ end
235
+
236
+ # 学習データの一覧を取得する
237
+ #
238
+ # @example
239
+ # client.list_knowledges(20, 10, 'complete')
240
+ #
241
+ # @param [Hash] options リクエストのオプション
242
+ # @option options [Integer] : limit 最大取得件数
243
+ # @option options [Integer] : offset 開始位置
244
+ # @option options [String] : status 学習データ保存の進捗状況
245
+ # @return [Mushikago::Http::Response] リクエストの結果
246
+ def list_knowledges options={}
247
+ request = Hanamgri::ListKnowledgesRequest.new(options)
248
+ send_request(request)
249
+ end
250
+
251
+ # 学習データの情報を削除する
252
+ #
253
+ # @example
254
+ # client.delete_knowledge('ec/price-UUID')
255
+ #
256
+ # @param [String] knowledge_name 学習データ名
257
+ def delete_knowledge knowledge_name, options={}
258
+ request = Hanamgri::DeleteKnowledgeRequest.new(knowledge_name,options)
259
+ send_request(request)
260
+ end
261
+
262
+ end
263
+ end
264
+ end
@@ -0,0 +1,25 @@
1
+ # -*- coding : utf-8 -*-
2
+ module Mushikago
3
+ module Hanamgri
4
+ class CreateDomainRequest < Mushikago::Http::PutRequest
5
+ def path; "/1/hanamgri/domains/#{domain_name}" end
6
+ attr_accessor :domain_name
7
+ request_parameter :seeds
8
+ request_parameter :schema do |s| s.to_json end
9
+ request_parameter :dictionary_name
10
+ request_parameter :description
11
+
12
+ def initialize domain_name, seeds, schema, options={}
13
+ super(options)
14
+ raise unless schema.kind_of? Mushikago::Hanamgri::Schema
15
+ self.domain_name = domain_name
16
+ self.seeds = seeds
17
+ self.schema = schema
18
+ self.description = options[:description] if options.has_key?(:description)
19
+ self.dictionary_name = options[:dictionary_name] if options.has_key?(:dictionary_name)
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+
@@ -0,0 +1,14 @@
1
+ # -*- coding : utf-8 -*-
2
+ module Mushikago
3
+ module Hanamgri
4
+ class DeleteDictionaryRequest < Mushikago::Http::DeleteRequest
5
+ def path; "/1/hanamgri/dictionary" end
6
+ request_parameter :dictionary_name
7
+
8
+ def initialize dictionary_name, options={}
9
+ super(options)
10
+ self.dictionary_name = dictionary_name
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,16 @@
1
+ # -*- coding : utf-8 -*-
2
+ module Mushikago
3
+ module Hanamgri
4
+ class DeleteDomainRequest < Mushikago::Http::DeleteRequest
5
+ def path; "/1/hanamgri/domains/#{domain_name}" end
6
+ attr_accessor :domain_name
7
+
8
+ def initialize domain_name, options={}
9
+ super(options)
10
+ self.domain_name = domain_name
11
+ end
12
+ end
13
+ end
14
+ end
15
+
16
+
@@ -0,0 +1,15 @@
1
+ # -*- coding : utf-8 -*-
2
+ module Mushikago
3
+ module Hanamgri
4
+ class DeleteKnowledgeRequest < Mushikago::Http::DeleteRequest
5
+ def path; "/1/hanamgri/knowledge" end
6
+ request_parameter :knowledge_name
7
+
8
+ def initialize knowledge_name, options={}
9
+ super(options)
10
+ raise 'Unsupported Operation.'
11
+ self.knowledge_name = knowledge_name
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,20 @@
1
+ # -*- coding : utf-8 -*-
2
+ require 'json'
3
+ module Mushikago
4
+ module Hanamgri
5
+ class Field < Struct.new(:name, :required, :type, :knowledge_name)
6
+ def validate!
7
+ raise "Invalid Type Value [#{type}]" unless [:string, :number].include?(type)
8
+ end
9
+
10
+ def required?
11
+ !!required
12
+ end
13
+
14
+ def to_json *args
15
+ {:name => name.to_s, :required => required?, :type => type}.to_json(args)
16
+ end
17
+ end
18
+ end
19
+ end
20
+
@@ -0,0 +1,16 @@
1
+ # -*- coding: utf-8 -*-
2
+ module Mushikago
3
+ module Hanamgri
4
+ class GetAnalysisRequest < Mushikago::Http::GetRequest
5
+ def path; "/1/hanamgri/domains/#{domain_name}/analyses/#{request_id}" end
6
+ attr_accessor :domain_name
7
+ attr_accessor :request_id
8
+
9
+ def initialize domain_name, request_id, options={}
10
+ super(options)
11
+ self.domain_name = domain_name
12
+ self.request_id = request_id
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ # -*- coding: utf-8 -*-
2
+ module Mushikago
3
+ module Hanamgri
4
+ class GetInformationRequest < Mushikago::Http::GetRequest
5
+ def path; "/1/hanamgri/domains/#{domain_name}" end
6
+ attr_accessor :domain_name
7
+
8
+ def initialize domain_name, options={}
9
+ super(options)
10
+ self.domain_name = domain_name
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ # -*- coding: utf-8 -*-
2
+ module Mushikago
3
+ module Hanamgri
4
+ class GetQueueSizeRequest < Mushikago::Http::GetRequest
5
+ def path; "/1/hanamgri/domains/#{domain_name}/queues" end
6
+ attr_accessor :domain_name
7
+
8
+ def initialize domain_name, options={}
9
+ super(options)
10
+ self.domain_name = domain_name
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,24 @@
1
+ # -*- coding : utf-8 -*-
2
+ module Mushikago
3
+ module Hanamgri
4
+ class GetListAnalysesRequest < Mushikago::Http::GetRequest
5
+ def path; "/1/hanamgri/domains/#{domain_name}/analyses" end
6
+ attr_accessor :domain_name
7
+ request_parameter :limit
8
+ request_parameter :offset
9
+ request_parameter :filter
10
+ request_parameter :status
11
+
12
+ def initialize domain_name, options={}
13
+ super(options)
14
+ self.domain_name = domain_name
15
+ self.limit = options[:limit] if options.has_key?(:limit)
16
+ self.offset = options[:offset] if options.has_key?(:offset)
17
+ self.filter = options[:filter] if options.has_key?(:filter)
18
+ self.status = options[:status] if options.has_key?(:status)
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+
@@ -0,0 +1,17 @@
1
+ # -*- coding : utf-8 -*-
2
+ module Mushikago
3
+ module Hanamgri
4
+ class ListDictionariesRequest < Mushikago::Http::GetRequest
5
+ def path; "/1/hanamgri/dictionaries" end
6
+ request_parameter :limit
7
+ request_parameter :offset
8
+
9
+ def initialize options={}
10
+ super(options)
11
+ self.limit = options[:limit] if options.has_key?(:limit)
12
+ self.offset = options[:offset] if options.has_key?(:offset)
13
+ end
14
+ end
15
+ end
16
+ end
17
+
@@ -0,0 +1,20 @@
1
+ # -*- coding : utf-8 -*-
2
+ module Mushikago
3
+ module Hanamgri
4
+ class GetListDomainsRequest < Mushikago::Http::GetRequest
5
+ def path; "/1/hanamgri/domains" end
6
+ request_parameter :limit
7
+ request_parameter :offset
8
+ request_parameter :filter
9
+
10
+ def initialize options={}
11
+ super(options)
12
+ self.limit = options[:limit] if options.has_key?(:limit)
13
+ self.offset = options[:offset] if options.has_key?(:offset)
14
+ self.filter = options[:filter] if options.has_key?(:filter)
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+
@@ -0,0 +1,20 @@
1
+ # -*- coding : utf-8 -*-
2
+ module Mushikago
3
+ module Hanamgri
4
+ class ListKnowledgesRequest < Mushikago::Http::GetRequest
5
+ def path; "/1/hanamgri/knowledges" end
6
+ request_parameter :limit
7
+ request_parameter :offset
8
+ request_parameter :status
9
+
10
+ def initialize options={}
11
+ super(options)
12
+ raise 'Unsupported Operation.'
13
+ self.limit = options[:limit] if options.has_key?(:limit)
14
+ self.offset = options[:offset] if options.has_key?(:offset)
15
+ self.status = options[:status] if options.has_key?(:status)
16
+ end
17
+ end
18
+ end
19
+ end
20
+
@@ -0,0 +1,21 @@
1
+ # -*- coding : utf-8 -*-
2
+ module Mushikago
3
+ module Hanamgri
4
+ class RequestAnalysisRequest < Mushikago::Http::PutRequest
5
+ def path; "/1/hanamgri/domains/#{domain_name}/analysis" end
6
+ attr_accessor :domain_name
7
+ request_parameter :url
8
+ request_parameter :charset
9
+ request_parameter :tag
10
+ request_parameter :auto_feedback
11
+ def initialize domain_name, url, options={}
12
+ super(options)
13
+ self.domain_name = domain_name
14
+ self.url = url
15
+ self.charset = options[:charset] if options.has_key?(:charset)
16
+ self.tag = options[:tag] if options.has_key?(:tag)
17
+ self.tag = options[:auto_feedback] if options.has_key?(:auto_feedback)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,18 @@
1
+ # -*- coding : utf-8 -*-
2
+ module Mushikago
3
+ module Hanamgri
4
+ class SaveDictionaryRequest < Mushikago::Http::PutRequest
5
+ def path; "/1/hanamgri/dictionary" end
6
+ request_parameter :domain_name
7
+ request_parameter :description
8
+
9
+ def initialize domain_name, options={}
10
+ super(options)
11
+ self.domain_name = domain_name
12
+ self.description = options[:description] if options.has_key?(:description)
13
+ end
14
+ end
15
+ end
16
+ end
17
+
18
+
@@ -0,0 +1,19 @@
1
+ # -*- coding : utf-8 -*-
2
+ module Mushikago
3
+ module Hanamgri
4
+ class SaveKnowledgeRequest < Mushikago::Http::PutRequest
5
+ def path; "/1/hanamgri/knowledge" end
6
+ request_parameter :domain_name
7
+ request_parameter :description
8
+
9
+ def initialize domain_name, options={}
10
+ super(options)
11
+ raise 'Unsupported Operation.'
12
+ self.domain_name = domain_name
13
+ self.description = options[:description] if options.has_key?(:description)
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+
@@ -0,0 +1,28 @@
1
+ # -*- coding : utf-8 -*-
2
+ require 'json'
3
+ module Mushikago
4
+ module Hanamgri
5
+ class Schema
6
+ attr_reader :fields
7
+
8
+ def initialize(&block)
9
+ @fields = []
10
+ instance_eval(&block) if block_given?
11
+ end
12
+
13
+ def add field_or_hash
14
+ field = field_or_hash
15
+ if field.kind_of?(Hash)
16
+ field = Mushikago::Hanamgri::Field.new(field[:name], field[:required], field[:type], field[:knowledge_name])
17
+ end
18
+ field.validate!
19
+ @fields << field
20
+ end
21
+
22
+ def to_json *args
23
+ {:fields => @fields}.to_json(args)
24
+ end
25
+ end
26
+ end
27
+ end
28
+
@@ -0,0 +1,19 @@
1
+ # -*- coding: utf-8 -*-
2
+ module Mushikago
3
+ module Hanamgri
4
+ class SearchSchemaRequest < Mushikago::Http::GetRequest
5
+ def path; "/1/hanamgri/domains/#{domain_name}/schema/search" end
6
+ attr_accessor :domain_name
7
+ attr_accessor :query_key
8
+ attr_accessor :query_value
9
+
10
+ def initialize domain_name, query_key, query_value, options={}
11
+ super(options)
12
+ raise 'Unsupported Operation.'
13
+ self.domain_name = domain_name
14
+ self.query_key = query_key
15
+ self.query_value = query_value
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,21 @@
1
+ # -*- coding : utf-8 -*-
2
+ module Mushikago
3
+ module Hanamgri
4
+ class TrainRequest < Mushikago::Http::PostRequest
5
+ def path; "/1/hanamgri/domains/#{domain_name}/train" end
6
+ attr_accessor :domain_name
7
+ request_parameter :url_or_html
8
+ request_parameter :training_data do |s| s.to_json end
9
+
10
+ def initialize domain_name, url_or_html, training_data, options={}
11
+ super(options)
12
+ raise unless training_data.kind_of? Mushikago::Hanamgri::TrainingData
13
+ self.domain_name = domain_name
14
+ self.url_or_html = url_or_html
15
+ self.training_data = training_data
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+