maluuba_napi2 0.0.2

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 10ae2f49206b60bb08ec09ff00fa69d44af1540a
4
+ data.tar.gz: f124ee964e5c5ba8254aab08fa2b012425b32fbf
5
+ SHA512:
6
+ metadata.gz: 166b172e3bb550100cb8bb0d5d11f86efafe0b4b20bdadb4942c67b4732c62b1b07f44a94f910765a30b4386a7f9664d21c25ad31ad172b03e4e4dcb6880218f
7
+ data.tar.gz: 27bb0c965d012bac04645ecea97400ae723606b3645237210c81a43e90b50e05afc93622a6dc361c2a697db305cb8f3343d1724d13b91b9d00a8d1d7a8161742
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in maluuba_napi.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Maluuba
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,96 @@
1
+ require 'maluuba_napi/version'
2
+ require 'maluuba_napi/configuration'
3
+ require 'maluuba_napi/categories'
4
+ require 'maluuba_napi/actions'
5
+ require 'httparty'
6
+ require 'uri'
7
+
8
+ module MaluubaNapi
9
+ # Provides simple access to the Maluuba NLP API (http://developer.maluuba.com)
10
+ # for Ruby scripts.
11
+ #
12
+ # Basic Usage:
13
+ #
14
+ # client = MaluubaNapi::Client.new 'your_apikey_here'
15
+ # client.interpret phrase: 'who is barack obama'
16
+ # client.normalize phrase: 'tomorrow', type: 'daterange', timezone: 'EST'
17
+ #
18
+ # Your apikey is your 'Consumer Key' on (http://developer.maluuba.com)
19
+ #
20
+ # For more information see (http://github.com/Maluuba/napi-ruby)
21
+ # Also visit us on our IRC channel at #maluuba on irc.freenode.net
22
+ class Client
23
+
24
+ include HTTParty
25
+ base_uri MaluubaNapi::Configuration::BASE_URI
26
+
27
+ # Creates a new client object
28
+ # @param [String] apikey the consumer_key given
29
+ # @param option [Hash] options optional parameters
30
+ def initialize(apikey, options={})
31
+ @auth = {}
32
+ @auth[:apikey] = apikey
33
+ end
34
+
35
+ # Calls the {http://developer.maluuba.com/interpret-api Interpret Endpoint}
36
+ # @param [Hash] query_parameters a hash of query parameters, :phrase is required
37
+ # @return [Hash] a hash consisting of :entities, :category and :action
38
+ def interpret(query_parameters={})
39
+ response = query "/#{MaluubaNapi::Configuration::VERSION}/interpret", query_parameters
40
+ response[:category] = response[:category].to_sym
41
+ response[:action] = response[:action].to_sym
42
+ response
43
+ end
44
+
45
+ # Calls the {http://developer.maluuba.com/normalize-api Normalize Endpoint}
46
+ # @param [Hash] query_parameters a hash of query parameters, :phrase and :type required
47
+ # @return [Hash] a hash consisting of :entities and :context
48
+ def normalize(query_parameters={})
49
+ query "/#{MaluubaNapi::Configuration::VERSION}/normalize", query_parameters
50
+ end
51
+
52
+ private
53
+
54
+ def query(endpoint, query_parameters)
55
+ response = self.class.get create_get_request(endpoint, query_parameters)
56
+ symbolize_response response.parsed_response
57
+ end
58
+
59
+ def create_get_request(endpoint, query_parameters)
60
+ endpoint + "?" + encode_query_parameters(query_parameters.merge(@auth))
61
+ end
62
+
63
+ def encode_query_parameters(query_parameters)
64
+ URI.encode_www_form(query_parameters)
65
+ end
66
+
67
+ # Helper method to turn response a ruby formatted hash
68
+ # @param [Hash] h a response hash where all the keys are strings and camel cased
69
+ # @return [Hash] a Ruby friendly hash where all the keys are lower cased symbols
70
+ def symbolize_response(h)
71
+ if Hash === h
72
+ Hash[
73
+ h.map do |k, v|
74
+ [k.respond_to?(:to_sym) ? k.downcase.to_sym : k, symbolize_response(v)]
75
+ end
76
+ ]
77
+ elsif Array === h
78
+ h.map do |e|
79
+ if Hash === e
80
+ e = Hash[
81
+ e.map do |k, v|
82
+ [k.respond_to?(:to_sym) ? k.downcase.to_sym : k, symbolize_response(v)]
83
+ end
84
+ ]
85
+ else
86
+ e
87
+ end
88
+ end
89
+ else
90
+ h
91
+ end
92
+ end
93
+
94
+ end
95
+
96
+ end
@@ -0,0 +1,84 @@
1
+ module MaluubaNapi
2
+ class Actions
3
+
4
+ ALL = [
5
+ :BUSINESS_SEARCH,
6
+ :BUSINESS_RESERVATION,
7
+ :CALL_DIAL,
8
+ :CALL_CHECK_MISSED,
9
+ :CALL_RESPOND_MISSED,
10
+ :CALL_ACCEPT_INCOMING,
11
+ :CONTACT_SEARCH,
12
+ :CONTACT_ADD,
13
+ :CONTACT_SET_ALIAS,
14
+ :KNOWLEDGE_SEARCH,
15
+ :ENTERTAINMENT_MOVIE,
16
+ :ENTERTAINMENT_EVENT,
17
+ :ENTERTAINMENT_AMBIGUOUS,
18
+ :EMAIL_SEND,
19
+ :EMAIL_DISPLAY,
20
+ :HELP_HELP,
21
+ :TRAVEL_FLIGHT,
22
+ :MUSIC_PLAY,
23
+ :MUSIC_PAUSE,
24
+ :CALENDAR_CREATE_EVENT,
25
+ :CALENDAR_SEARCH,
26
+ :CALENDAR_REMOVE_EVENT,
27
+ :CALENDAR_MODIFY_EVENT,
28
+ :CALENDAR_AVAILABILITY,
29
+ :WEATHER_STATUS,
30
+ :WEATHER_DETAILS,
31
+ :WEATHER_SUNSET,
32
+ :WEATHER_SUNRISE,
33
+ :REMINDER_SET,
34
+ :REMINDER_SEARCH,
35
+ :ALARM_SET,
36
+ :ALARM_SET_RECURRING,
37
+ :ALARM_MODIFY,
38
+ :ALARM_CANCEL,
39
+ :ALARM_CANCEL_ALL_ALARMS,
40
+ :ALARM_SEARCH,
41
+ :TIMER_START,
42
+ :TIMER_DISPLAY,
43
+ :TIMER_CANCEL,
44
+ :TIMER_PAUSE,
45
+ :STOPWATCH_START,
46
+ :STOPWATCH_STOP,
47
+ :STOPWATCH_RESET,
48
+ :STOPWATCH_DISPLAY,
49
+ :NAVIGATION_DIRECTIONS,
50
+ :NAVIGATION_WHERE_AM_I,
51
+ :TRANSIT_NEXT_BUS,
52
+ :TRANSIT_NEARBY_STOPS,
53
+ :TRANSIT_SCHEDULE,
54
+ :TRANSIT_STATIONS,
55
+ :SEARCH_AMAZON,
56
+ :SEARCH_BING,
57
+ :SEARCH_EBAY,
58
+ :SEARCH_DEFAULT,
59
+ :SEARCH_GOOGLE,
60
+ :SEARCH_RECIPES,
61
+ :SEARCH_WIKIPEDIA,
62
+ :TEXT_DISPLAY,
63
+ :TEXT_SEND,
64
+ :SOCIAL_FACEBOOK_SEND_MESSAGE,
65
+ :SOCIAL_FACEBOOK_SHOW_NEWSFEED,
66
+ :SOCIAL_FACEBOOK_SHOW_PHOTOS,
67
+ :SOCIAL_FACEBOOK_SHOW_WALL,
68
+ :SOCIAL_FACEBOOK_WRITE_ON_WALL,
69
+ :SOCIAL_FOURSQUARE_CHECK_IN,
70
+ :SOCIAL_FOURSQUARE_SHOW_CHECKINS,
71
+ :SOCIAL_TWITTER_SHOW_FOLLOWER,
72
+ :SOCIAL_TWITTER_SHOW_TRENDING,
73
+ :SOCIAL_TWITTER_TWEET,
74
+ :SPORTS_MISC,
75
+ :APPLICATION_LAUNCH
76
+
77
+ ].freeze
78
+
79
+ def self.valid?(arg)
80
+ ALL.include? arg
81
+ end
82
+ end
83
+
84
+ end
@@ -0,0 +1,34 @@
1
+ module MaluubaNapi
2
+ class Categories
3
+
4
+ ALL = [
5
+ :BUSINESS,
6
+ :CALL,
7
+ :CONTACT,
8
+ :KNOWLEDGE,
9
+ :ENTERTAINMENT,
10
+ :EMAIL,
11
+ :HELP,
12
+ :TRAVEL,
13
+ :MUSIC,
14
+ :CALENDAR,
15
+ :WEATHER,
16
+ :REMINDER,
17
+ :ALARM,
18
+ :TIMER,
19
+ :STOPWATCH,
20
+ :NAVIGATION,
21
+ :TRANSIT,
22
+ :SEARCH,
23
+ :TEXT,
24
+ :SOCIAL,
25
+ :SPORTS,
26
+ :APPLICATION
27
+ ].freeze
28
+
29
+ def self.valid?(arg)
30
+ ALL.include? arg
31
+ end
32
+ end
33
+
34
+ end
@@ -0,0 +1,6 @@
1
+ module MaluubaNapi
2
+ class Configuration
3
+ BASE_URI = "http://napi.maluuba.com"
4
+ VERSION = "v0"
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module MaluubaNapi
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/maluuba_napi/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Andrew McNamara"]
6
+ gem.email = ["andrew.mcnamara@maluuba.com"]
7
+ gem.description = %q{MaluubaNapi allows you to easily consume Maluuba's NLP API}
8
+ gem.summary = %q{MaluubaNapi is a simple wrapper for consuming the Maluuba NLP API}
9
+ gem.homepage = "http://github.com/Maluuba/napi-ruby"
10
+
11
+ gem.add_dependency 'httparty', '~> 0.10.0'
12
+
13
+ gem.add_development_dependency 'rspec'
14
+ gem.add_development_dependency 'yard'
15
+
16
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ gem.files = `git ls-files`.split("\n")
18
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ gem.name = "maluuba_napi2"
20
+ gem.require_paths = ["lib"]
21
+ gem.version = MaluubaNapi::VERSION
22
+ end
@@ -0,0 +1,692 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Test Interpret Endpoint" do
4
+
5
+ before do
6
+ @client = MaluubaNapi::Client.new 'your_apikey_here'
7
+ end
8
+
9
+
10
+ describe "category: BUSINESS" do
11
+ describe "action: BUSINESS_SEARCH" do
12
+
13
+ it "should test: where can I buy a hammer" do
14
+ response = @client.interpret phrase: 'where can I buy a hammer'
15
+ assert_intepret response, :BUSINESS, :BUSINESS_SEARCH
16
+ end
17
+
18
+ it "should test: i am hungry" do
19
+ response = @client.interpret phrase: 'i am hungry'
20
+ assert_intepret response, :BUSINESS, :BUSINESS_SEARCH
21
+ end
22
+
23
+ it "should test: i want some pizza" do
24
+ response = @client.interpret phrase: 'i want some pizza'
25
+ assert_intepret response, :BUSINESS, :BUSINESS_SEARCH
26
+ end
27
+ end
28
+
29
+ describe "action: BUSINESS_RESERVATION" do
30
+ it "should test: book a table for 2 at an italian restaurant nearby" do
31
+ response = @client.interpret phrase: 'book a table for 2 at an italian restaurant nearby'
32
+ assert_intepret response, :BUSINESS, :BUSINESS_RESERVATION
33
+ end
34
+
35
+ it "should test: reserve a room at a hotel" do
36
+ response = @client.interpret phrase: 'reserve a room at a hotel'
37
+ assert_intepret response, :BUSINESS, :BUSINESS_RESERVATION
38
+ end
39
+
40
+ end
41
+ end
42
+
43
+ describe "category: CALL" do
44
+ describe "action: CALL_DIAL" do
45
+
46
+ it "should test: call josh" do
47
+ response = @client.interpret phrase: 'call josh'
48
+ assert_intepret response, :CALL, :CALL_DIAL
49
+ end
50
+
51
+ it "should test: call josh" do
52
+ response = @client.interpret phrase: 'call josh'
53
+ assert_intepret response, :CALL, :CALL_DIAL
54
+ end
55
+
56
+ end
57
+ describe "action: CALL_CHECK_MISSED" do
58
+
59
+ it "should test: did i miss any calls" do
60
+ response = @client.interpret phrase: 'did i miss any calls'
61
+ assert_intepret response, :CALL, :CALL_CHECK_MISSED
62
+ end
63
+
64
+ end
65
+ describe "action: CALL_RESPOND_MISSED" do
66
+
67
+ it "should test: respond to that missed call" do
68
+ response = @client.interpret phrase: 'respond to that missed call'
69
+ assert_intepret response, :CALL, :CALL_RESPOND_MISSED
70
+ end
71
+ end
72
+ describe "action: CALL_ACCEPT_INCOMING" do
73
+
74
+ it "should test: accept this call" do
75
+ response = @client.interpret phrase: 'accept this call'
76
+ assert_intepret response, :CALL, :CALL_ACCEPT_INCOMING
77
+ end
78
+ end
79
+
80
+ end
81
+
82
+ describe "category: CONTACT" do
83
+ describe "action: CONTACT_ADD" do
84
+
85
+ it "should test: add josh 5551234" do
86
+ response = @client.interpret phrase: 'add josh 5551234'
87
+ assert_intepret response, :CONTACT, :CONTACT_ADD
88
+ end
89
+
90
+ end
91
+ describe "action: CONTACT_SEARCH" do
92
+
93
+ it "should test: show me adrians information" do
94
+ response = @client.interpret phrase: 'show me adrians information'
95
+ assert_intepret response, :CONTACT, :CONTACT_SEARCH
96
+ end
97
+
98
+ it "should test: what is josh's phone number" do
99
+ response = @client.interpret phrase: "what is josh's phone number"
100
+ assert_intepret response, :CONTACT, :CONTACT_SEARCH
101
+ end
102
+
103
+ end
104
+ describe "action: CONTACT_SET_ALIAS" do
105
+
106
+ it "should test: elizabeth is my mom" do
107
+ response = @client.interpret phrase: 'elizabeth is my mom'
108
+ assert_intepret response, :CONTACT, :CONTACT_SET_ALIAS
109
+ end
110
+
111
+ end
112
+ end
113
+
114
+ describe "category: KNOWLEDGE" do
115
+ describe "action: KNOWLEDGE_SEARCH" do
116
+
117
+ it "should test: who is Barack Obama" do
118
+ response = @client.interpret phrase: 'who is Barack Obama'
119
+ assert_intepret response, :KNOWLEDGE, :KNOWLEDGE_SEARCH
120
+ end
121
+
122
+ it "should test: who is the president" do
123
+ response = @client.interpret phrase: 'who is the president'
124
+ assert_intepret response, :KNOWLEDGE, :KNOWLEDGE_SEARCH
125
+ end
126
+
127
+ it "should test: what is two plus two" do
128
+ response = @client.interpret phrase: 'what is two plus two'
129
+ assert_intepret response, :KNOWLEDGE, :KNOWLEDGE_SEARCH
130
+ end
131
+
132
+ it "should test: what is the tallest mountain" do
133
+ response = @client.interpret phrase: 'what is the tallest mountain'
134
+ assert_intepret response, :KNOWLEDGE, :KNOWLEDGE_SEARCH
135
+ end
136
+
137
+ end
138
+ end
139
+
140
+ describe "category: ENTERTAINMENT" do
141
+ describe "action: ENTERTAINMENT_MOVIE" do
142
+
143
+ it "should test: I want to see a funny movie" do
144
+ response = @client.interpret phrase: 'I want to see a funny movie'
145
+ assert_intepret response, :ENTERTAINMENT, :ENTERTAINMENT_MOVIE
146
+ end
147
+
148
+ it "should test: I want to see skyfall" do
149
+ response = @client.interpret phrase: 'I want to see skyfall'
150
+ assert_intepret response, :ENTERTAINMENT, :ENTERTAINMENT_MOVIE
151
+ end
152
+
153
+ end
154
+ describe "action: ENTERTAINMENT_EVENT" do
155
+
156
+ it "should test: I want to see a funny movie" do
157
+ response = @client.interpret phrase: 'I want to see justin bieber'
158
+ assert_intepret response, :ENTERTAINMENT, :ENTERTAINMENT_EVENT
159
+ end
160
+
161
+ it "should test: I want to see skyfall" do
162
+ response = @client.interpret phrase: 'when do the leafs play'
163
+ assert_intepret response, :ENTERTAINMENT, :ENTERTAINMENT_EVENT
164
+ end
165
+
166
+
167
+ end
168
+ describe "action: ENTERTAINMENT_AMBIGUOUS" do
169
+
170
+ it "should test: I want to see a funny movie" do
171
+ response = @client.interpret phrase: "What's fun to do on the weekend"
172
+ assert_intepret response, :ENTERTAINMENT, :ENTERTAINMENT_AMBIGUOUS
173
+ end
174
+
175
+ end
176
+ end
177
+
178
+ describe "category: EMAIL" do
179
+ describe "action: EMAIL_SEND" do
180
+
181
+ it "should test: email adrian about the api" do
182
+ response = @client.interpret phrase: "email adrian about the api"
183
+ assert_intepret response, :EMAIL, :EMAIL_SEND
184
+ end
185
+
186
+ end
187
+ describe "action: EMAIL_DISPLAY" do
188
+
189
+ it "should test: show me emails from josh" do
190
+ response = @client.interpret phrase: "show me emails from josh"
191
+ assert_intepret response, :EMAIL, :EMAIL_DISPLAY
192
+ end
193
+
194
+ end
195
+ end
196
+
197
+ describe "category: HELP" do
198
+ describe "action: HELP_HELP" do
199
+
200
+ it "should test: help" do
201
+ response = @client.interpret phrase: "help"
202
+ assert_intepret response, :HELP, :HELP_HELP
203
+ end
204
+
205
+ it "should test: what can you do" do
206
+ response = @client.interpret phrase: "what can you do"
207
+ assert_intepret response, :HELP, :HELP_HELP
208
+ end
209
+
210
+ end
211
+ end
212
+
213
+ describe "category: TRAVEL" do
214
+ describe "action: TRAVEL_FLIGHT" do
215
+
216
+ it "should test: i would like a first class ticket to new york leaving from toronto on the day before christmas returning a week after christmas" do
217
+ response = @client.interpret phrase: "i would like a first class ticket to new york leaving from toronto on the day before christmas returning a week after christmas"
218
+ assert_intepret response, :TRAVEL, :TRAVEL_FLIGHT
219
+ end
220
+
221
+ end
222
+ end
223
+
224
+ describe "category: MUSIC" do
225
+ describe "action: MUSIC_PLAY" do
226
+
227
+ it "should test: play the song firework" do
228
+ response = @client.interpret phrase: "play the song firework"
229
+ assert_intepret response, :MUSIC, :MUSIC_PLAY
230
+ end
231
+
232
+ end
233
+ describe "action: MUSIC_PAUSE" do
234
+
235
+ it "should test: please pause the music" do
236
+ response = @client.interpret phrase: "please pause the music"
237
+ assert_intepret response, :MUSIC, :MUSIC_PAUSE
238
+ end
239
+
240
+ end
241
+ end
242
+
243
+ describe "category: CALENDAR" do
244
+ describe "action: CALENDAR_CREATE_EVENT" do
245
+
246
+ it "should test: Set up a meeting from 8 to 10" do
247
+ response = @client.interpret phrase: "Set up a meeting from 8 to 10"
248
+ assert_intepret response, :CALENDAR, :CALENDAR_CREATE_EVENT
249
+ end
250
+
251
+ end
252
+ describe "action: CALENDAR_SEARCH" do
253
+
254
+ it "should test: what meetings do I have on Friday" do
255
+ response = @client.interpret phrase: "what meetings do I have on Friday"
256
+ assert_intepret response, :CALENDAR, :CALENDAR_SEARCH
257
+ end
258
+
259
+ end
260
+ describe "action: CALENDAR_REMOVE_EVENT" do
261
+
262
+ it "should test: Cancel my next meeting" do
263
+ response = @client.interpret phrase: "Cancel my next meeting"
264
+ assert_intepret response, :CALENDAR, :CALENDAR_REMOVE_EVENT
265
+ end
266
+
267
+ end
268
+ describe "action: CALENDAR_MODIFY_EVENT" do
269
+
270
+ it "should test: Move my 5 o'clock to 7" do
271
+ response = @client.interpret phrase: "Move my 5 o'clock to 7"
272
+ assert_intepret response, :CALENDAR, :CALENDAR_MODIFY_EVENT
273
+ end
274
+
275
+ end
276
+ describe "action: CALENDAR_AVAILABILITY" do
277
+
278
+ it "should test: When am I available" do
279
+ response = @client.interpret phrase: "When am I available"
280
+ assert_intepret response, :CALENDAR, :CALENDAR_AVAILABILITY
281
+ end
282
+
283
+ end
284
+ end
285
+
286
+ describe "category: WEATHER" do
287
+ describe "action: WEATHER_STATUS" do
288
+
289
+ it "should test: What is the weather outside?" do
290
+ response = @client.interpret phrase: "What is the weather outside?"
291
+ assert_intepret response, :WEATHER, :WEATHER_STATUS
292
+ end
293
+
294
+ end
295
+ describe "action: WEATHER_DETAILS" do
296
+
297
+ it "should test: What is the wind speed?" do
298
+ response = @client.interpret phrase: "What is the wind speed?"
299
+ assert_intepret response, :WEATHER, :WEATHER_DETAILS
300
+ end
301
+
302
+ end
303
+ describe "action: WEATHER_SUNSET" do
304
+
305
+ it "should test: When is the sunset?" do
306
+ response = @client.interpret phrase: "When is the sunset?"
307
+ assert_intepret response, :WEATHER, :WEATHER_SUNSET
308
+ end
309
+
310
+ end
311
+ describe "action: WEATHER_SUNRISE" do
312
+
313
+ it "should test: When is sunrise for Friday?" do
314
+ response = @client.interpret phrase: "When is sunrise for Friday?"
315
+ assert_intepret response, :WEATHER, :WEATHER_SUNRISE
316
+ end
317
+
318
+ end
319
+ end
320
+
321
+ describe "category: REMINDER" do
322
+ describe "action: REMINDER_SET" do
323
+
324
+ it "should test: Remind me to put out the garbage tonight" do
325
+ response = @client.interpret phrase: "Remind me to put out the garbage tonight"
326
+ assert_intepret response, :REMINDER, :REMINDER_SET
327
+ end
328
+
329
+ end
330
+ describe "action: REMINDER_SEARCH" do
331
+
332
+ it "should test: Find me reminders for this week" do
333
+ response = @client.interpret phrase: "Find me reminders for this week"
334
+ assert_intepret response, :REMINDER, :REMINDER_SEARCH
335
+ end
336
+
337
+ end
338
+ end
339
+
340
+ describe "category: ALARM" do
341
+ describe "action: ALARM_SET" do
342
+
343
+ it "should test: set an alarm for five thirty" do
344
+ response = @client.interpret phrase: "set an alarm for five thirty"
345
+ assert_intepret response, :ALARM, :ALARM_SET
346
+ end
347
+
348
+ end
349
+ describe "action: ALARM_SET_RECURRING" do
350
+
351
+ it "should test: Set an alarm at five thirty every morning" do
352
+ response = @client.interpret phrase: "Set an alarm at five thirty every morning"
353
+ assert_intepret response, :ALARM, :ALARM_SET_RECURRING
354
+ end
355
+
356
+ end
357
+ describe "action: ALARM_MODIFY" do
358
+
359
+ it "should test: Change my morning alarms from 5 to 7" do
360
+ response = @client.interpret phrase: "Change my morning alarms from 5 to 7"
361
+ assert_intepret response, :ALARM, :ALARM_MODIFY
362
+ end
363
+
364
+ end
365
+ describe "action: ALARM_CANCEL" do
366
+
367
+ it "should test: Cancel my alarm at 6 tonight" do
368
+ response = @client.interpret phrase: "Cancel my alarm at 6 tonight"
369
+ assert_intepret response, :ALARM, :ALARM_CANCEL
370
+ end
371
+
372
+ end
373
+ describe "action: ALARM_CANCEL_ALL_ALARMS" do
374
+
375
+ it "should test: Remove all my alarms" do
376
+ response = @client.interpret phrase: "Remove all my alarms"
377
+ assert_intepret response, :ALARM, :ALARM_CANCEL_ALL_ALARMS
378
+ end
379
+
380
+ end
381
+ describe "action: ALARM_SEARCH" do
382
+
383
+ it "should test: Find my alarms" do
384
+ response = @client.interpret phrase: "Find my alarms"
385
+ assert_intepret response, :ALARM, :ALARM_SEARCH
386
+ end
387
+
388
+ end
389
+ end
390
+
391
+ describe "TIMER" do
392
+ describe "TIMER_START" do
393
+
394
+ it "should test: Set a 30 minute timer" do
395
+ response = @client.interpret phrase: "Set a 30 minute timer"
396
+ assert_intepret response, :TIMER, :TIMER_START
397
+ end
398
+
399
+ end
400
+ describe "TIMER_DISPLAY" do
401
+
402
+ it "should test: show my timer" do
403
+ response = @client.interpret phrase: "show my timer"
404
+ assert_intepret response, :TIMER, :TIMER_DISPLAY
405
+ end
406
+
407
+ end
408
+ describe "TIMER_CANCEL" do
409
+
410
+ it "should test: cancel the timer" do
411
+ response = @client.interpret phrase: "cancel the timer"
412
+ assert_intepret response, :TIMER, :TIMER_CANCEL
413
+ end
414
+
415
+ end
416
+ describe "TIMER_PAUSE" do
417
+
418
+ it "should test: pause timer" do
419
+ response = @client.interpret phrase: "pause timer"
420
+ assert_intepret response, :TIMER, :TIMER_PAUSE
421
+ end
422
+
423
+ end
424
+ end
425
+
426
+ describe "category: STOPWATCH" do
427
+ describe "action: STOPWATCH_START" do
428
+
429
+ it "should test: start a stopwatch" do
430
+ response = @client.interpret phrase: "start a stopwatch"
431
+ assert_intepret response, :STOPWATCH, :STOPWATCH_START
432
+ end
433
+
434
+ end
435
+ describe "action: STOPWATCH_STOP" do
436
+
437
+ it "should test: stop a stopwatch" do
438
+ response = @client.interpret phrase: "stop a stopwatch"
439
+ assert_intepret response, :STOPWATCH, :STOPWATCH_STOP
440
+ end
441
+
442
+ end
443
+ describe "action: STOPWATCH_DISPLAY" do
444
+
445
+ it "should test: display the stopwatch" do
446
+ response = @client.interpret phrase: "display the stopwatch"
447
+ assert_intepret response, :STOPWATCH, :STOPWATCH_DISPLAY
448
+ end
449
+
450
+ end
451
+ end
452
+
453
+ describe "category: NAVIGATION" do
454
+ describe "action: NAVIGATION_DIRECTIONS" do
455
+
456
+ it "should test: How do I get to the mall from my house" do
457
+ response = @client.interpret phrase: "How do I get to the mall from my house"
458
+ assert_intepret response, :NAVIGATION, :NAVIGATION_DIRECTIONS
459
+ end
460
+
461
+ it "should test: How do I get to the mall from my house" do
462
+ response = @client.interpret phrase: "How do I get to the mall from my house"
463
+ assert_intepret response, :NAVIGATION, :NAVIGATION_DIRECTIONS
464
+ end
465
+
466
+ end
467
+ describe "action: NAVIGATION_WHERE_AM_I" do
468
+
469
+ it "should test: Show my current location" do
470
+ response = @client.interpret phrase: "Show my current location"
471
+ assert_intepret response, :NAVIGATION, :NAVIGATION_WHERE_AM_I
472
+ end
473
+
474
+ end
475
+ end
476
+
477
+ describe "category: TRANSIT" do
478
+ describe "action: TRANSIT_NEXT_BUS" do
479
+
480
+ it "should test: When will the next bus come to the university" do
481
+ response = @client.interpret phrase: "When will the next bus come to the university"
482
+ assert_intepret response, :TRANSIT, :TRANSIT_NEXT_BUS
483
+ end
484
+
485
+ end
486
+ describe "action: TRANSIT_NEARBY_STOPS" do
487
+
488
+ it "should test: bus stops near the mall" do
489
+ response = @client.interpret phrase: "bus stops near the mall"
490
+ assert_intepret response, :TRANSIT, :TRANSIT_NEARBY_STOPS
491
+ end
492
+
493
+ end
494
+ describe "action: TRANSIT_SCHEDULE" do
495
+
496
+ it "should test: What is the schedule for the green route tomorrow" do
497
+ response = @client.interpret phrase: "What is the schedule for the green route tomorrow"
498
+ assert_intepret response, :TRANSIT, :TRANSIT_SCHEDULE
499
+ end
500
+
501
+ end
502
+ end
503
+
504
+ describe "category: SEARCH" do
505
+ describe "action: SEARCH_AMAZON" do
506
+
507
+ it "should test: i want to buy a book on amazon" do
508
+ response = @client.interpret phrase: "i want to buy a book on amazon"
509
+ assert_intepret response, :SEARCH, :SEARCH_AMAZON
510
+ end
511
+
512
+ it "should test: search amazon for electronics" do
513
+ response = @client.interpret phrase: "search amazon for electronics"
514
+ assert_intepret response, :SEARCH, :SEARCH_AMAZON
515
+ end
516
+
517
+ end
518
+ describe "action: SEARCH_BING" do
519
+
520
+ it "should test: bing search ryan seacrest" do
521
+ response = @client.interpret phrase: "bing search ryan seacrest"
522
+ assert_intepret response, :SEARCH, :SEARCH_BING
523
+ end
524
+
525
+ end
526
+ describe "action: SEARCH_EBAY" do
527
+
528
+ it "should test: search ebay for socks" do
529
+ response = @client.interpret phrase: "search ebay for socks"
530
+ assert_intepret response, :SEARCH, :SEARCH_EBAY
531
+ end
532
+
533
+ end
534
+ describe "action: SEARCH_DEFAULT" do
535
+
536
+ it "should test: search the web for cheese" do
537
+ response = @client.interpret phrase: "search the web for cheese"
538
+ assert_intepret response, :SEARCH, :SEARCH_DEFAULT
539
+ end
540
+
541
+ end
542
+ describe "action: SEARCH_GOOGLE" do
543
+
544
+ it "should test: google search androids" do
545
+ response = @client.interpret phrase: "google search androids"
546
+ assert_intepret response, :SEARCH, :SEARCH_GOOGLE
547
+ end
548
+
549
+ end
550
+ describe "action: SEARCH_RECIPES" do
551
+
552
+ it "should test: how do i make butter chicken" do
553
+ response = @client.interpret phrase: "how do i make butter chicken"
554
+ assert_intepret response, :SEARCH, :SEARCH_RECIPES
555
+ end
556
+
557
+ end
558
+ describe "action: SEARCH_WIKIPEDIA" do
559
+
560
+ it "should test: search wikipedia for the romans" do
561
+ response = @client.interpret phrase: "search wikipedia for the romans"
562
+ assert_intepret response, :SEARCH, :SEARCH_WIKIPEDIA
563
+ end
564
+
565
+ end
566
+ end
567
+
568
+ describe "category: TEXT" do
569
+ describe "action: TEXT_DISPLAY" do
570
+
571
+ it "should test: show unread texts" do
572
+ response = @client.interpret phrase: "show unread texts"
573
+ assert_intepret response, :TEXT, :TEXT_DISPLAY
574
+ end
575
+
576
+ end
577
+ describe "action: TEXT_SEND" do
578
+
579
+ it "should test: send a text to rob how is the law stuff" do
580
+ response = @client.interpret phrase: "send a text to rob how is the law stuff"
581
+ assert_intepret response, :TEXT, :TEXT_SEND
582
+ end
583
+
584
+ end
585
+ end
586
+
587
+ describe "SOCIAL" do
588
+ describe "SOCIAL_FACEBOOK_SEND_MESSAGE" do
589
+
590
+ it "should test: send a facebook message to zhiyuan hey g" do
591
+ response = @client.interpret phrase: "send a facebook message to zhiyuan hey g"
592
+ assert_intepret response, :SOCIAL, :SOCIAL_FACEBOOK_SEND_MESSAGE
593
+ end
594
+
595
+ end
596
+ describe "SOCIAL_FACEBOOK_SHOW_NEWSFEED" do
597
+
598
+ it "should test: show me my facebook newsfeed" do
599
+ response = @client.interpret phrase: "show me my facebook newsfeed"
600
+ assert_intepret response, :SOCIAL, :SOCIAL_FACEBOOK_SHOW_NEWSFEED
601
+ end
602
+
603
+ end
604
+ describe "SOCIAL_FACEBOOK_SHOW_PHOTOS" do
605
+
606
+ it "should test: show me pictures of irene" do
607
+ response = @client.interpret phrase: "show me pictures of irene"
608
+ assert_intepret response, :SOCIAL, :SOCIAL_FACEBOOK_SHOW_PHOTOS
609
+ end
610
+
611
+ end
612
+ describe "SOCIAL_FACEBOOK_SHOW_WALL" do
613
+
614
+ it "should test: take me to cynthia's facebook wall" do
615
+ response = @client.interpret phrase: "take me to cynthia's facebook wall"
616
+ assert_intepret response, :SOCIAL, :SOCIAL_FACEBOOK_SHOW_WALL
617
+ end
618
+
619
+ end
620
+ describe "SOCIAL_FACEBOOK_WRITE_ON_WALL" do
621
+
622
+ it "should test: write on sam's wall good luck in korea" do
623
+ response = @client.interpret phrase: "write on sam's wall good luck in korea"
624
+ assert_intepret response, :SOCIAL, :SOCIAL_FACEBOOK_WRITE_ON_WALL
625
+ end
626
+
627
+ end
628
+ describe "SOCIAL_FOURSQUARE_CHECK_IN" do
629
+
630
+ it "should test: check me in at communitech" do
631
+ response = @client.interpret phrase: "check me in at communitech"
632
+ assert_intepret response, :SOCIAL, :SOCIAL_FOURSQUARE_CHECK_IN
633
+ end
634
+
635
+ end
636
+ describe "SOCIAL_FOURSQUARE_SHOW_CHECKINS" do
637
+
638
+ it "should test: where have i checked in" do
639
+ response = @client.interpret phrase: "where have i checked in"
640
+ assert_intepret response, :SOCIAL, :SOCIAL_FOURSQUARE_SHOW_CHECKINS
641
+ end
642
+
643
+ end
644
+ describe "SOCIAL_TWITTER_SHOW_FOLLOWER" do
645
+
646
+ it "should test: show my twitter timeline" do
647
+ response = @client.interpret phrase: "show my twitter timeline"
648
+ assert_intepret response, :SOCIAL, :SOCIAL_TWITTER_SHOW_FOLLOWER
649
+ end
650
+
651
+ end
652
+ describe "SOCIAL_TWITTER_SHOW_TRENDING" do
653
+
654
+ it "should test: what is trending on twitter" do
655
+ response = @client.interpret phrase: "what is trending on twitter"
656
+ assert_intepret response, :SOCIAL, :SOCIAL_TWITTER_SHOW_TRENDING
657
+ end
658
+
659
+ end
660
+ describe "SOCIAL_TWITTER_TWEET" do
661
+
662
+ it "should test: tweet i want a burrito" do
663
+ response = @client.interpret phrase: "tweet i want a burrito"
664
+ assert_intepret response, :SOCIAL, :SOCIAL_TWITTER_TWEET
665
+ end
666
+
667
+ end
668
+ end
669
+
670
+ describe "category: SPORTS" do
671
+ describe "action: SPORTS_MISC" do
672
+
673
+ it "should test: what was the score of the game last night" do
674
+ response = @client.interpret phrase: "what was the score of the game last night"
675
+ assert_intepret response, :SPORTS, :SPORTS_MISC
676
+ end
677
+
678
+ end
679
+ end
680
+
681
+ describe "category: APPLICATION" do
682
+ describe "action: APPLICATION_LAUNCH" do
683
+
684
+ it "should test: launch angry birds" do
685
+ response = @client.interpret phrase: "launch angry birds"
686
+ assert_intepret response, :APPLICATION, :APPLICATION_LAUNCH
687
+ end
688
+
689
+ end
690
+ end
691
+
692
+ end
@@ -0,0 +1,11 @@
1
+ require 'rspec'
2
+ require 'maluuba_napi'
3
+ require 'maluuba_napi/categories'
4
+ require 'maluuba_napi/actions'
5
+
6
+ def assert_intepret(response, category, action)
7
+ response[:category].should eql category
8
+ response[:action].should eql action
9
+ MaluubaNapi::Categories.valid?(category).should eql true
10
+ MaluubaNapi::Actions.valid?(action).should eql true
11
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: maluuba_napi2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Andrew McNamara
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-05-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.10.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.10.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: yard
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: MaluubaNapi allows you to easily consume Maluuba's NLP API
56
+ email:
57
+ - andrew.mcnamara@maluuba.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - Gemfile
63
+ - LICENSE
64
+ - Rakefile
65
+ - lib/maluuba_napi.rb
66
+ - lib/maluuba_napi/actions.rb
67
+ - lib/maluuba_napi/categories.rb
68
+ - lib/maluuba_napi/configuration.rb
69
+ - lib/maluuba_napi/version.rb
70
+ - maluuba_napi.gemspec
71
+ - spec/maluuba-napi/interpret_spec.rb
72
+ - spec/spec_helper.rb
73
+ homepage: http://github.com/Maluuba/napi-ruby
74
+ licenses: []
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.0.3
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: MaluubaNapi is a simple wrapper for consuming the Maluuba NLP API
96
+ test_files: []