monkeylearn 0.1 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b8b41d5910d61c77645da60123ad508a1e444eb0
4
- data.tar.gz: 6d385382a783204a3e8cfa9d8044a755815e206f
3
+ metadata.gz: 3ec517084ef75738ba6423156f745ea98276f30d
4
+ data.tar.gz: 612bdf407268f030674086083cb64328c73d6484
5
5
  SHA512:
6
- metadata.gz: 5138110e12266e1fc4841a75ddf8928b5c3aa222d09236773cf76172443857451de6ede605201f99f488ccba5b7d03485fd96d52b8e7dac5802e12040f71548c
7
- data.tar.gz: 551435a4e5a476e335d67db0631db44dfea2f663df04a6f19ca7b199b4355c3d3d5859b85b9757c732f8668024f2e5b95cd4b80bb8bc521b841c529b1c4b7ce5
6
+ metadata.gz: 8857e3a142c1da9aa2ce513b23dbe640d18c7a6531a265b890e27bf294d593f3544652cda3c563bc8df505774645a98bee2f323b8cb02ee1d12a6b64a101c74a
7
+ data.tar.gz: eeaf7ae4022a18376f6a892ad088ee22b50805467e82b2c671490337d9068af286d4686253f9ff38a4915057166e22ae3ce293e30beb21fbaa43bd0f5a425108
data/README.md CHANGED
@@ -88,10 +88,13 @@ negative_category_id = r.result['result']['category']['id']
88
88
  Upload some samples to each category:
89
89
 
90
90
  ```ruby
91
- samples = {
92
- positive_category_id => ['Nice beatiful', 'awesome excelent'],
93
- negative_category_id => ['Awful bad', 'sad pale'],
94
- }
91
+ samples = [
92
+ ['Nice beatiful', positive_category_id],
93
+ ['awesome excelent', positive_category_id],
94
+ ['Awful bad', negative_category_id],
95
+ ['sad pale', negative_category_id],
96
+ ['happy sad both multilabel', [positive_category_id, negative_category_id]]
97
+ ]
95
98
  r = Monkeylearn.classifiers.upload_samples(classifier_id, samples)
96
99
  ```
97
100
 
@@ -74,11 +74,14 @@ module Monkeylearn
74
74
  end
75
75
 
76
76
  def upload_samples(module_id, samples_with_categories)
77
+ unless samples_with_categories.respond_to? :each
78
+ raise MonkeylearnError, "The second param must be an enumerable type (i.e. an Array)."
79
+ end
77
80
  endpoint = build_endpoint(module_id, 'samples')
78
81
  data = {
79
- samples: samples_with_categories.collect do |category_id, texts|
80
- texts.collect { |text| {text: text, category_id: category_id} }
81
- end.flatten(1)
82
+ samples: samples_with_categories.collect do |text, category_ids|
83
+ {text: text, category_id: category_ids}
84
+ end
82
85
  }
83
86
  request :post, endpoint, data
84
87
  end
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ['hello@monkeylearn.com']
11
11
  spec.homepage = 'https://github.com/monkeylearn/monkeylearn-ruby'
12
12
 
13
- spec.version = '0.1'
13
+ spec.version = '0.2'
14
14
  spec.add_dependency 'faraday', '>= 0.9.2'
15
15
 
16
16
  spec.licenses = ['MIT']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monkeylearn
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Monkeylearn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-09 00:00:00.000000000 Z
11
+ date: 2016-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday