google-prediction 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/google-prediction.rb +6 -7
- metadata +3 -3
data/lib/google-prediction.rb
CHANGED
@@ -124,7 +124,7 @@ class GooglePrediction
|
|
124
124
|
end
|
125
125
|
|
126
126
|
# Submission must be either a string, a single number,
|
127
|
-
# or an array of numbers
|
127
|
+
# or an array of strings or numbers
|
128
128
|
#
|
129
129
|
# Gets the prediction for the label of the submission based on the training.
|
130
130
|
#
|
@@ -135,14 +135,13 @@ class GooglePrediction
|
|
135
135
|
url = PREDICTION_URL_PREFIX + "/" + @bucket + "%2F" + @object + "/predict"
|
136
136
|
curl = Curl::Easy.new(url)
|
137
137
|
post_body = {:data => {:input => {}}}
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
elsif submission.is_a? Array
|
138
|
+
submission = [submission] unless submission.is_a? Array
|
139
|
+
if submission[0].is_a? String
|
140
|
+
post_body[:data][:input] = {:text => submission}
|
141
|
+
elsif submission[0].is_a? Fixnum
|
143
142
|
post_body[:data][:input] = {:numeric => submission}
|
144
143
|
else
|
145
|
-
raise Exception.new("submission must be String, Fixnum, or Array")
|
144
|
+
raise Exception.new("submission must be String, Fixnum, or Array of Strings / Fixnums")
|
146
145
|
end
|
147
146
|
curl.post_body = JSON.generate(post_body)
|
148
147
|
curl.headers = {"Content-Type" => "application/json",
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-prediction
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sam King
|