nlpcloud 1.0.9 → 1.0.10

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 +25 -3
  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: 33a4b97770d4b1a6f6daf5c3365f5dbe266e82113ab54b4219cf414458aa7907
4
+ data.tar.gz: ec629fbc99105b49cb4f90b90b42b2ad812d509c808d28b77859b61dc7c2b4e1
5
5
  SHA512:
6
- metadata.gz: bd06ca4a59eeeea5a8b00355d0d6a986505c4c17b666d535c17854ce10fa9b3f7f01480cc3efd1b2c7f29a9fe67005e022a6c37b2dbcbada289dec05f6fc3538
7
- data.tar.gz: b6552e52e42447424c88573caca8e4d9bdee93c4ec2f5ab5e180bf1dfc3da2d71bd4a187aa41a2bf34af02a9c9fa8dcb61887bdc7ee916cb5700120252341ca6
6
+ metadata.gz: a618257dc0d197126b16698d51957209989b533bbcaf731c6ac4a7987c25ad83b712688d14ea5b3bccdf61c5c8a7675bd0786f30ca5ddb8dca6a6a69f1307f7c
7
+ data.tar.gz: db964aa4c66127a60c64e19b21c8377969f83eec024b1dab3dd3d85ed47d31ece8458ee7cebca7c664b3bb993eae69d028bdfe04c3f5fa2afc965f92c827e49a
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)
@@ -67,6 +73,22 @@ module NLPCloud
67
73
  JSON.parse(response.body)
68
74
  end
69
75
 
76
+ def langdetection(text)
77
+ payload = {
78
+ 'text' => text
79
+ }
80
+ response = RestClient.post("#{@root_url}/langdetection", payload.to_json, @headers)
81
+ JSON.parse(response.body)
82
+ end
83
+
84
+ def tokens(text)
85
+ payload = {
86
+ 'text' => text
87
+ }
88
+ response = RestClient.post("#{@root_url}/tokens", payload.to_json, @headers)
89
+ JSON.parse(response.body)
90
+ end
91
+
70
92
  def dependencies(text)
71
93
  payload = {
72
94
  '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.10
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-07-25 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: []