nlpcloud 1.0.8 → 1.0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nlpcloud.rb +54 -4
  3. metadata +8 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 10c0a4d3c5d521504f79e2f5fff0299d84555508e86257a7b110a3cb6d4483ae
4
- data.tar.gz: 64d3bee78530167352fc1b91c5d617844e44b237d714ca52c53119c0f7e8123c
3
+ metadata.gz: 0d15c8d10001f6858a03294421913df01689dc776786f22292ec4f02f0d73a83
4
+ data.tar.gz: 3b1bfc5e7dd10844cb6f714e4d6749579c81528fd5599cf76b52129677f2d510
5
5
  SHA512:
6
- metadata.gz: 4e23aae57e6591d27673d8a20eec8f9b47149a3c1d24448eac02d5892b64fefa0a105d664da04150548b10033c57c3eabc4f5db9b5a730553b6d72525c314fc0
7
- data.tar.gz: 34de7fba883dbc73ac045b227ff227d917458dc9190ca77ca259e6232e803ef181b0a640c463e1820eda0534db74b8de2893ec7c353bebe5c92a2293bca60405
6
+ metadata.gz: 701204c9a11f8000d618ffd9bab25f922e2607d48790931669843371927601336aa0d06ed9a8e4f911d7bc00a0c4f2e829b23d57c230530d941157f5c61367cb
7
+ data.tar.gz: cc2d2bab211b74a071aab5f9262360b81517d0f82bad2b8081981ffeb6f35ac3e3f1fb2e3546d57c9b7fa2623bf4b137069bd4cb27a9fa6ef2592a3ada1da294
data/lib/nlpcloud.rb CHANGED
@@ -9,11 +9,17 @@ module NLPCloud
9
9
 
10
10
  # Client requests the API.
11
11
  class Client
12
- def initialize(model, token)
12
+ def initialize(model, token, gpu: false)
13
13
  @headers = {
14
- 'Authorization' => "Token #{token}"
14
+ 'Authorization' => "Token #{token}",
15
+ 'User-Agent' => 'nlpcloud-ruby-client'
15
16
  }
16
- @root_url = "#{BASE_URL}/#{API_VERSION}/#{model}"
17
+
18
+ @root_url = if gpu
19
+ "#{BASE_URL}/#{API_VERSION}/gpu/#{model}"
20
+ else
21
+ "#{BASE_URL}/#{API_VERSION}/#{model}"
22
+ end
17
23
  end
18
24
 
19
25
  def entities(text)
@@ -24,7 +30,7 @@ module NLPCloud
24
30
  JSON.parse(response.body)
25
31
  end
26
32
 
27
- def classification(text, labels, multi_class)
33
+ def classification(text, labels, multi_class: nil)
28
34
  payload = {
29
35
  'text' => text,
30
36
  'labels' => labels,
@@ -34,6 +40,26 @@ module NLPCloud
34
40
  JSON.parse(response.body)
35
41
  end
36
42
 
43
+ def generation(text, min_length: nil, max_length: nil, length_no_input: nil,
44
+ end_sequence: nil, remove_input: nil, top_k: nil, top_p: nil,
45
+ temperature: nil, repetition_penalty: nil, length_penalty: nil)
46
+ payload = {
47
+ 'text' => text,
48
+ 'min_length' => min_length,
49
+ 'max_length' => max_length,
50
+ 'length_no_input' => length_no_input,
51
+ 'end_sequence' => end_sequence,
52
+ 'remove_input' => remove_input,
53
+ 'top_k' => top_k,
54
+ 'top_p' => top_p,
55
+ 'temperature' => temperature,
56
+ 'repetition_penalty' => repetition_penalty,
57
+ 'length_penalty' => length_penalty
58
+ }
59
+ response = RestClient.post("#{@root_url}/generation", payload.to_json, @headers)
60
+ JSON.parse(response.body)
61
+ end
62
+
37
63
  def sentiment(text)
38
64
  payload = {
39
65
  'text' => text
@@ -59,6 +85,30 @@ module NLPCloud
59
85
  JSON.parse(response.body)
60
86
  end
61
87
 
88
+ def translation(text)
89
+ payload = {
90
+ 'text' => text
91
+ }
92
+ response = RestClient.post("#{@root_url}/translation", payload.to_json, @headers)
93
+ JSON.parse(response.body)
94
+ end
95
+
96
+ def langdetection(text)
97
+ payload = {
98
+ 'text' => text
99
+ }
100
+ response = RestClient.post("#{@root_url}/langdetection", payload.to_json, @headers)
101
+ JSON.parse(response.body)
102
+ end
103
+
104
+ def tokens(text)
105
+ payload = {
106
+ 'text' => text
107
+ }
108
+ response = RestClient.post("#{@root_url}/tokens", payload.to_json, @headers)
109
+ JSON.parse(response.body)
110
+ end
111
+
62
112
  def dependencies(text)
63
113
  payload = {
64
114
  'text' => text
metadata CHANGED
@@ -1,19 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nlpcloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien Salinas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-26 00:00:00.000000000 Z
11
+ date: 2021-08-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: 'Ruby client for the NLP Cloud API. NLP Cloud serves high performance
14
- pre-trained or custom models for NER, sentiment-analysis, classification, summarization,
15
- question answering, and POS tagging, ready for production, served through a REST
16
- API. More details here: https://nlpcloud.io. Documentation: https://docs.nlpcloud.io.'
13
+ description: 'NLP Cloud serves high performance pre-trained or custom models for NER,
14
+ sentiment-analysis, classification, summarization, text generation, question answering,
15
+ machine translation, language detection, tokenization, POS tagging, and dependency
16
+ parsing. It is ready for production, served through a REST API. This is the Ruby
17
+ client for the API. More details here: https://nlpcloud.io. Documentation: https://docs.nlpcloud.io.'
17
18
  email: all@juliensalinas.com
18
19
  executables: []
19
20
  extensions: []
@@ -42,7 +43,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
42
43
  - !ruby/object:Gem::Version
43
44
  version: '0'
44
45
  requirements: []
45
- rubygems_version: 3.1.2
46
+ rubygems_version: 3.1.4
46
47
  signing_key:
47
48
  specification_version: 4
48
49
  summary: Ruby client for the NLP Cloud API