nlpcloud 1.0.14 → 1.0.17
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 +4 -4
- data/lib/nlpcloud.rb +25 -4
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba0ea165110cdb347d71a03eecfee3f90683d64526af1f26ee2b01a90818fd09
|
4
|
+
data.tar.gz: daf9745041d2cc720d5df0ef37275f44b320f8a760f985d264ae8173f287c150
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51c84014d9fbf0816ee3727ff013a809aa104be22cb79463a47b0ad2cdfd7b1458e2068ff92c153758e666fd2f349d1e99ba70170f3c8b3d60882153d1d320d0
|
7
|
+
data.tar.gz: d86e7c59c918f9c1d95b36e696eac83a1627096fd0a09c795802092c4f83ebfbe5a402fd482b98c63a8fefb63a02cd76ae1feb2fa5b2ead83bac5ed2cac1e656
|
data/lib/nlpcloud.rb
CHANGED
@@ -9,15 +9,19 @@ module NLPCloud
|
|
9
9
|
|
10
10
|
# Client requests the API.
|
11
11
|
class Client
|
12
|
-
def initialize(model, token, gpu: false)
|
12
|
+
def initialize(model, token, gpu: false, lang: '')
|
13
13
|
@headers = {
|
14
14
|
'Authorization' => "Token #{token}",
|
15
15
|
'Content-Type' => 'application/json',
|
16
16
|
'User-Agent' => 'nlpcloud-ruby-client'
|
17
17
|
}
|
18
18
|
|
19
|
-
@root_url = if gpu
|
19
|
+
@root_url = if gpu && (lang != '')
|
20
|
+
"#{BASE_URL}/#{API_VERSION}/gpu/#{lang}/#{model}"
|
21
|
+
elsif gpu && (lang == '')
|
20
22
|
"#{BASE_URL}/#{API_VERSION}/gpu/#{model}"
|
23
|
+
elsif !gpu && (lang != '')
|
24
|
+
"#{BASE_URL}/#{API_VERSION}/#{lang}/#{model}"
|
21
25
|
else
|
22
26
|
"#{BASE_URL}/#{API_VERSION}/#{model}"
|
23
27
|
end
|
@@ -44,7 +48,7 @@ module NLPCloud
|
|
44
48
|
def generation(text, min_length: nil, max_length: nil, length_no_input: nil,
|
45
49
|
end_sequence: nil, remove_input: nil, do_sample: nil, num_beams: nil, early_stopping: nil,
|
46
50
|
no_repeat_ngram_size: nil, num_return_sequences: nil, top_k: nil, top_p: nil,
|
47
|
-
temperature: nil, repetition_penalty: nil, length_penalty: nil, bad_words: nil)
|
51
|
+
temperature: nil, repetition_penalty: nil, length_penalty: nil, bad_words: nil, remove_end_sequence: nil)
|
48
52
|
payload = {
|
49
53
|
'text' => text,
|
50
54
|
'min_length' => min_length,
|
@@ -62,7 +66,8 @@ module NLPCloud
|
|
62
66
|
'temperature' => temperature,
|
63
67
|
'repetition_penalty' => repetition_penalty,
|
64
68
|
'length_penalty' => length_penalty,
|
65
|
-
'bad_words' => bad_words
|
69
|
+
'bad_words' => bad_words,
|
70
|
+
'remove_end_sequence' => remove_end_sequence
|
66
71
|
}
|
67
72
|
response = RestClient.post("#{@root_url}/generation", payload.to_json, @headers)
|
68
73
|
JSON.parse(response.body)
|
@@ -109,6 +114,14 @@ module NLPCloud
|
|
109
114
|
JSON.parse(response.body)
|
110
115
|
end
|
111
116
|
|
117
|
+
def semantic_similarity(sentences)
|
118
|
+
payload = {
|
119
|
+
'sentences' => sentences
|
120
|
+
}
|
121
|
+
response = RestClient.post("#{@root_url}/semantic_similarity", payload.to_json, @headers)
|
122
|
+
JSON.parse(response.body)
|
123
|
+
end
|
124
|
+
|
112
125
|
def tokens(text)
|
113
126
|
payload = {
|
114
127
|
'text' => text
|
@@ -133,6 +146,14 @@ module NLPCloud
|
|
133
146
|
JSON.parse(response.body)
|
134
147
|
end
|
135
148
|
|
149
|
+
def embeddings(sentences)
|
150
|
+
payload = {
|
151
|
+
'sentences' => sentences
|
152
|
+
}
|
153
|
+
response = RestClient.post("#{@root_url}/embeddings", payload.to_json, @headers)
|
154
|
+
JSON.parse(response.body)
|
155
|
+
end
|
156
|
+
|
136
157
|
def lib_versions
|
137
158
|
response = RestClient.get("#{@root_url}/versions", @headers)
|
138
159
|
JSON.parse(response.body)
|
metadata
CHANGED
@@ -1,20 +1,21 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nlpcloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julien Salinas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01
|
11
|
+
date: 2022-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: 'NLP Cloud serves high performance pre-trained or custom models for NER,
|
14
14
|
sentiment-analysis, classification, summarization, text generation, question answering,
|
15
|
-
machine translation, language detection, tokenization, POS
|
16
|
-
parsing. It is ready for production, served
|
17
|
-
client for the API. More details here: https://nlpcloud.io.
|
15
|
+
machine translation, language detection, semantic similarity, tokenization, POS
|
16
|
+
tagging, embeddings, and dependency parsing. It is ready for production, served
|
17
|
+
through a REST API. This is the Ruby client for the API. More details here: https://nlpcloud.io.
|
18
|
+
Documentation: https://docs.nlpcloud.io.'
|
18
19
|
email: all@juliensalinas.com
|
19
20
|
executables: []
|
20
21
|
extensions: []
|