nlpcloud 1.0.9 → 1.0.13

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 +53 -4
  3. metadata +7 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab6ad951a1b80b36984a5b46365fe4ee273aa9d8bfc488b13007649d322860fb
4
- data.tar.gz: 3f03bc5ec2be3f45f8e84271ba2ae506804ad9a038f6778f22bf372009429b6b
3
+ metadata.gz: 5530e1eddfaa48e0547b69a03e6cdb60227db948d0a105a828ec3510f0413a80
4
+ data.tar.gz: 9b43269b64b3837523a63e3864100ff310008390ad0206af9217f33f7de43dd4
5
5
  SHA512:
6
- metadata.gz: bd06ca4a59eeeea5a8b00355d0d6a986505c4c17b666d535c17854ce10fa9b3f7f01480cc3efd1b2c7f29a9fe67005e022a6c37b2dbcbada289dec05f6fc3538
7
- data.tar.gz: b6552e52e42447424c88573caca8e4d9bdee93c4ec2f5ab5e180bf1dfc3da2d71bd4a187aa41a2bf34af02a9c9fa8dcb61887bdc7ee916cb5700120252341ca6
6
+ metadata.gz: d174e5a6af642c508f59f273e02e38765de36afcb8792c8312f47f2295f5773d63540d641895bdd4364ca01158e0374e5610786909ab9c1a20fe2c41aaecf60d
7
+ data.tar.gz: f412ad06bdfadad1b1e0bcf8408e20c51ccfa99753756411ab1d235c2ad9a11702f1e32287a5a46c333ff55ef63fe609ed011747d27e10b6de01ceecc3f533b4
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,33 @@ 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, do_sample: nil, num_beams: nil, early_stopping: nil,
45
+ no_repeat_ngram_size: nil, num_return_sequences: nil, top_k: nil, top_p: nil,
46
+ temperature: nil, repetition_penalty: nil, length_penalty: nil, bad_words: nil)
47
+ payload = {
48
+ 'text' => text,
49
+ 'min_length' => min_length,
50
+ 'max_length' => max_length,
51
+ 'length_no_input' => length_no_input,
52
+ 'end_sequence' => end_sequence,
53
+ 'remove_input' => remove_input,
54
+ 'do_sample' => do_sample,
55
+ 'num_beams' => num_beams,
56
+ 'early_stopping' => early_stopping,
57
+ 'no_repeat_ngram_size' => no_repeat_ngram_size,
58
+ 'num_return_sequences' => num_return_sequences,
59
+ 'top_k' => top_k,
60
+ 'top_p' => top_p,
61
+ 'temperature' => temperature,
62
+ 'repetition_penalty' => repetition_penalty,
63
+ 'length_penalty' => length_penalty,
64
+ 'bad_words' => bad_words
65
+ }
66
+ response = RestClient.post("#{@root_url}/generation", payload.to_json, @headers)
67
+ JSON.parse(response.body)
68
+ end
69
+
37
70
  def sentiment(text)
38
71
  payload = {
39
72
  'text' => text
@@ -67,6 +100,22 @@ module NLPCloud
67
100
  JSON.parse(response.body)
68
101
  end
69
102
 
103
+ def langdetection(text)
104
+ payload = {
105
+ 'text' => text
106
+ }
107
+ response = RestClient.post("#{@root_url}/langdetection", payload.to_json, @headers)
108
+ JSON.parse(response.body)
109
+ end
110
+
111
+ def tokens(text)
112
+ payload = {
113
+ 'text' => text
114
+ }
115
+ response = RestClient.post("#{@root_url}/tokens", payload.to_json, @headers)
116
+ JSON.parse(response.body)
117
+ end
118
+
70
119
  def dependencies(text)
71
120
  payload = {
72
121
  '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.9
4
+ version: 1.0.13
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-27 00:00:00.000000000 Z
11
+ date: 2021-09-28 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: []