nlpcloud 1.0.6 → 1.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nlpcloud.rb +80 -17
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33a4b97770d4b1a6f6daf5c3365f5dbe266e82113ab54b4219cf414458aa7907
|
4
|
+
data.tar.gz: ec629fbc99105b49cb4f90b90b42b2ad812d509c808d28b77859b61dc7c2b4e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a618257dc0d197126b16698d51957209989b533bbcaf731c6ac4a7987c25ad83b712688d14ea5b3bccdf61c5c8a7675bd0786f30ca5ddb8dca6a6a69f1307f7c
|
7
|
+
data.tar.gz: db964aa4c66127a60c64e19b21c8377969f83eec024b1dab3dd3d85ed47d31ece8458ee7cebca7c664b3bb993eae69d028bdfe04c3f5fa2afc965f92c827e49a
|
data/lib/nlpcloud.rb
CHANGED
@@ -9,41 +9,104 @@ 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
|
-
|
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
|
-
def entities(
|
20
|
-
|
25
|
+
def entities(text)
|
26
|
+
payload = {
|
27
|
+
'text' => text
|
28
|
+
}
|
29
|
+
response = RestClient.post("#{@root_url}/entities", payload.to_json, @headers)
|
30
|
+
JSON.parse(response.body)
|
21
31
|
end
|
22
32
|
|
23
|
-
def
|
24
|
-
|
33
|
+
def classification(text, labels, multi_class)
|
34
|
+
payload = {
|
35
|
+
'text' => text,
|
36
|
+
'labels' => labels,
|
37
|
+
'multi_class' => multi_class
|
38
|
+
}
|
39
|
+
response = RestClient.post("#{@root_url}/classification", payload.to_json, @headers)
|
40
|
+
JSON.parse(response.body)
|
25
41
|
end
|
26
42
|
|
27
|
-
def
|
28
|
-
|
43
|
+
def sentiment(text)
|
44
|
+
payload = {
|
45
|
+
'text' => text
|
46
|
+
}
|
47
|
+
response = RestClient.post("#{@root_url}/sentiment", payload.to_json, @headers)
|
48
|
+
JSON.parse(response.body)
|
29
49
|
end
|
30
50
|
|
31
|
-
def
|
32
|
-
|
51
|
+
def question(context, question)
|
52
|
+
payload = {
|
53
|
+
'context' => context,
|
54
|
+
'question' => question
|
55
|
+
}
|
56
|
+
response = RestClient.post("#{@root_url}/question", payload.to_json, @headers)
|
57
|
+
JSON.parse(response.body)
|
33
58
|
end
|
34
59
|
|
35
|
-
|
60
|
+
def summarization(text)
|
61
|
+
payload = {
|
62
|
+
'text' => text
|
63
|
+
}
|
64
|
+
response = RestClient.post("#{@root_url}/summarization", payload.to_json, @headers)
|
65
|
+
JSON.parse(response.body)
|
66
|
+
end
|
36
67
|
|
37
|
-
def
|
68
|
+
def translation(text)
|
38
69
|
payload = {
|
39
|
-
'text' =>
|
70
|
+
'text' => text
|
40
71
|
}
|
41
|
-
response = RestClient.post("#{@root_url}
|
72
|
+
response = RestClient.post("#{@root_url}/translation", payload.to_json, @headers)
|
42
73
|
JSON.parse(response.body)
|
43
74
|
end
|
44
75
|
|
45
|
-
def
|
46
|
-
|
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
|
+
|
92
|
+
def dependencies(text)
|
93
|
+
payload = {
|
94
|
+
'text' => text
|
95
|
+
}
|
96
|
+
response = RestClient.post("#{@root_url}/dependencies", payload.to_json, @headers)
|
97
|
+
JSON.parse(response.body)
|
98
|
+
end
|
99
|
+
|
100
|
+
def sentence_dependencies(text)
|
101
|
+
payload = {
|
102
|
+
'text' => text
|
103
|
+
}
|
104
|
+
response = RestClient.post("#{@root_url}/sentence-dependencies", payload.to_json, @headers)
|
105
|
+
JSON.parse(response.body)
|
106
|
+
end
|
107
|
+
|
108
|
+
def lib_versions
|
109
|
+
response = RestClient.get("#{@root_url}/versions", @headers)
|
47
110
|
JSON.parse(response.body)
|
48
111
|
end
|
49
112
|
end
|
metadata
CHANGED
@@ -1,18 +1,20 @@
|
|
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.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-
|
11
|
+
date: 2021-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: '
|
14
|
-
|
15
|
-
|
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.'
|
16
18
|
email: all@juliensalinas.com
|
17
19
|
executables: []
|
18
20
|
extensions: []
|