nlpcloud 1.0.7 → 1.0.11

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 +7 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c8a08233de83602a883f76f24b1be58b8d6fa909b9194b3b1deeb2d9018d4987
4
- data.tar.gz: 73830d3e197ff7727371d66f24f24b6829322ec04dafae682fcb3a03750716a3
3
+ metadata.gz: a39b2bf884144622e741cf6de5e6ec38a9d19ef1379dcc54d1c6d5b8a4f4aeeb
4
+ data.tar.gz: 0b15ca98c9731449ee6ecab93d298eeb0e673ecac512643c359e282ea2958649
5
5
  SHA512:
6
- metadata.gz: ffb8e5c89f39e339c1163679b3596b3567018c52e51b626351e186162a13d5bf7ac0258387dba2190d856faa9139788a3871a2fe07efbb76b8ca26d09db2a8af
7
- data.tar.gz: 3216fbd124155653a20ea661a8fae938ddd8305b43bd08495b360b91cb57eb1d81a55b6aa774be2e36722f0cd1edbc644bcf6a1abb482eefb352500e1d151bd1
6
+ metadata.gz: 299e5bddc247032e76dd556bad12fa86dc1b88170335061c2d4f7be468e5ccfff317677549066b88266935746fcdec4a4a7e37928df919c329718f56285d0ffc
7
+ data.tar.gz: fb23ed98fa5e1baa7177f7d66020135ac9252737c9f7f30e7a32da97fa59030a8795297d31a830e4fb674be7eef510e288ffdce6ba242508cb3b14bfd7a68453
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": 'nlploud-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.7
4
+ version: 1.0.11
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-03-04 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 models for NER, sentiment-analysis, classification, summarization, question
15
- answering, and POS tagging, ready for production, served through a REST API. More
16
- 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: []